From bb91a44b5af1aab05a49dc31fb2fc80cc810fe03 Mon Sep 17 00:00:00 2001 From: Mason Freed Date: Tue, 13 Feb 2024 11:55:30 -0800 Subject: [PATCH] Add shadowRootDelegatesFocus and shadowRootClonable reflection The `shadowRootDelegatesFocus` IDL is standardized [1], and was just never added to Chromium. This CL lands this addition behind a kill switch, but should be very safe to add. The `shadowRootClonable` IDL is being added as part of [2], which has support and should land soon. [1] https://html.spec.whatwg.org/multipage/scripting.html#htmltemplateelement [2] https://github.com/whatwg/html/pull/10117 Bug: 1510466 Change-Id: I708ec8d562fa4d0fc59c73a071dbb191e1bd276e --- .../declarative-shadow-dom-basic.html | 43 +++++++++++++++++++ 1 file changed, 43 insertions(+) diff --git a/shadow-dom/declarative/declarative-shadow-dom-basic.html b/shadow-dom/declarative/declarative-shadow-dom-basic.html index 8bc6bec5f50f741..4f174b8e5f7c4af 100644 --- a/shadow-dom/declarative/declarative-shadow-dom-basic.html +++ b/shadow-dom/declarative/declarative-shadow-dom-basic.html @@ -54,6 +54,49 @@ t.getAttribute('shadowrootmode', 'CLOSED'); }, 'Shadowrootmode reflection, setter'); +test(() => { + const t = document.createElement('template'); + t.setAttribute('shadowrootdelegatesfocus',''); + assert_equals(t.shadowRootDelegatesFocus,true,'The shadowRootDelegatesFocus IDL should reflect the content attribute'); + t.setAttribute('shadowrootdelegatesfocus','foobar'); + assert_equals(t.shadowRootDelegatesFocus,true,'The value doesn\'t matter'); + t.removeAttribute('shadowrootdelegatesfocus'); + assert_equals(t.shadowRootDelegatesFocus,false,'No shadowRootDelegatesFocus attribute maps to false'); +}, 'Shadowrootdelegatesfocus reflection'); + +test(() => { + const t = document.createElement('template'); + assert_equals(t.getAttribute('shadowrootdelegatesfocus'), null); + t.shadowRootDelegatesFocus = true; + assert_equals(t.getAttribute('shadowrootdelegatesfocus'), ''); + assert_equals(t.shadowRootDelegatesFocus, true); + t.shadowRootDelegatesFocus = false; + assert_equals(t.getAttribute('shadowrootdelegatesfocus'), null); + assert_equals(t.shadowRootDelegatesFocus, false); +}, 'Shadowrootdelegatesfocus reflection, setter'); + + +test(() => { + const t = document.createElement('template'); + t.setAttribute('shadowrootclonable',''); + assert_equals(t.shadowRootClonable,true,'The shadowRootClonable IDL should reflect the content attribute'); + t.setAttribute('shadowrootclonable','foobar'); + assert_equals(t.shadowRootClonable,true,'The value doesn\'t matter'); + t.removeAttribute('shadowrootclonable'); + assert_equals(t.shadowRootClonable,false,'No shadowRootClonable attribute maps to false'); +}, 'Shadowrootclonable reflection'); + +test(() => { + const t = document.createElement('template'); + assert_equals(t.getAttribute('shadowrootclonable'), null); + t.shadowRootClonable = true; + assert_equals(t.getAttribute('shadowrootclonable'), ''); + assert_equals(t.shadowRootClonable, true); + t.shadowRootClonable = false; + assert_equals(t.getAttribute('shadowrootclonable'), null); + assert_equals(t.shadowRootClonable, false); +}, 'Shadowrootclonable reflection, setter'); + test(() => { const div = document.createElement('div'); div.setHTMLUnsafe(`