Implement declarative shadow dom (#34964)

* Implement declarative shadow dom

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Set allowDeclarativeShadowRoots false for innerHTML

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Enable allowDeclarativeShadowRoots for Document

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Expose HTMLTemplateElement to js

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Implemenet setHTMLUnsafe and add more test cases

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Declarative shadow dom: minor updates and expected test result update

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Shadow-dom: add more test cases

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Update comments according to the spec

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

* Bump html5ever version

Signed-off-by: batu_hoang <longvatrong111@gmail.com>

---------

Signed-off-by: batu_hoang <longvatrong111@gmail.com>
This commit is contained in:
batu_hoang 2025-03-17 17:41:34 +08:00 committed by GitHub
parent f483a3d34b
commit 28c8c1df0c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
44 changed files with 360 additions and 1965 deletions

View file

@ -1,9 +0,0 @@
[function-shadow-container.html]
[Can query named container in shadow]
expected: FAIL
[::part() can not see inner named containers]
expected: FAIL
[::slotted() can see inner named containers]
expected: FAIL

View file

@ -1,33 +0,0 @@
[function-shadow.html]
[@function works inside shadow]
expected: FAIL
[Looking up document-global function]
expected: FAIL
[@function works inside nested shadow]
expected: FAIL
[@function defined in outer shadow is visible]
expected: FAIL
[Combining functions from various scopes]
expected: FAIL
[::part() can not see inner functions]
expected: FAIL
[::slotted() can see inner functions]
expected: FAIL
[:host can see inner functions]
expected: FAIL
[Outer functions can't see inner functions]
expected: FAIL
[Outer functions can't see inner functions (local vars)]
expected: FAIL
[Function with same name in different scopes]
expected: FAIL

View file

@ -1,2 +1,78 @@
[host-has-shadow-tree-element-at-nonsubject-position.html]
expected: ERROR
[Initial color]
expected: FAIL
[Add .descendant to #shadow_child]
expected: FAIL
[Remove .descendant from #shadow_child]
expected: FAIL
[Add .descendant to #shadow_descendant]
expected: FAIL
[Add .ancestor to #shadow_child:has(.descendant)]
expected: FAIL
[Remove .ancestor from #shadow_child:has(.descendant)]
expected: FAIL
[Add .child to #shadow_child:has(.descendant)]
expected: FAIL
[Remove .child from #shadow_child:has(.descendant)]
expected: FAIL
[Remove .descendant from #shadow_descendant]
expected: FAIL
[Add .child to #shadow_child]
expected: FAIL
[Add .grand_child to #shadow_descendant]
expected: FAIL
[Add .host_context to #host]
expected: FAIL
[Add .descendant to #shadow_descendant.grand_child]
expected: FAIL
[Remove .descendant from #shadow_descendant.grand_child]
expected: FAIL
[Remove .grand_child from #shadow_descendant]
expected: FAIL
[Remove .child from #shadow_child]
expected: FAIL
[Add .child to #shadow_descendant]
expected: FAIL
[Remove .child from #shadow_descendant]
expected: FAIL
[Insert #first_child.descendant to shadow root]
expected: FAIL
[Remove #first_child.descendant from shadow root]
expected: FAIL
[Insert #last_child.descendant to shadow root]
expected: FAIL
[Remove #last_child.descendant from shadow root]
expected: FAIL
[Insert #child_in_middle.descendant before #shadow_child]
expected: FAIL
[Remove #child_in_middle.descendant from shadow root]
expected: FAIL
[Insert #grand_child.descendant before #shadow_descendant]
expected: FAIL
[Remove #grand_child.descendant from shadow tree]
expected: FAIL

View file

@ -1,2 +1,48 @@
[host-has-shadow-tree-element-at-subject-position.html]
expected: ERROR
[Add .descendant to #shadow_child]
expected: FAIL
[Add .descendant to #shadow_descendant]
expected: FAIL
[Add .ancestor to #shadow_child:has(.descendant)]
expected: FAIL
[Remove .ancestor from #shadow_child:has(.descendant)]
expected: FAIL
[Add .child to #shadow_child:has(.descendant)]
expected: FAIL
[Remove .child from #shadow_child:has(.descendant)]
expected: FAIL
[Add .child to #shadow_child]
expected: FAIL
[Add .grand_child to #shadow_descendant]
expected: FAIL
[Add .host_context to #host]
expected: FAIL
[Add .descendant to #shadow_descendant.grand_child]
expected: FAIL
[Remove .descendant from #shadow_descendant.grand_child]
expected: FAIL
[Remove .grand_child from #shadow_descendant]
expected: FAIL
[Insert #first_child.descendant to shadow root]
expected: FAIL
[Insert #last_child.descendant to shadow root]
expected: FAIL
[Insert #child_in_middle.descendant before #shadow_child]
expected: FAIL
[Insert #grand_child.descendant before #shadow_descendant]
expected: FAIL

View file

@ -4,6 +4,3 @@
[customElements on a failed custom element created by setting innerHTML should return the associated scoped registry]
expected: FAIL
[customElements on a failed custom element created by parser should return the specified custom regsitry]
expected: FAIL

View file

@ -4613,12 +4613,6 @@
[DOMStringList interface: calling contains(DOMString) on location.ancestorOrigins with too few arguments must throw TypeError]
expected: FAIL
[Element interface: document.createElement("noscript") must inherit property "setHTMLUnsafe((TrustedHTML or DOMString))" with the proper type]
expected: FAIL
[Element interface: calling setHTMLUnsafe((TrustedHTML or DOMString)) on document.createElement("noscript") with too few arguments must throw TypeError]
expected: FAIL
[Element interface: document.createElement("noscript") must inherit property "getHTML(optional GetHTMLOptions)" with the proper type]
expected: FAIL
@ -5927,9 +5921,6 @@
[ShadowRoot interface: operation getHTML(optional GetHTMLOptions)]
expected: FAIL
[Element interface: operation setHTMLUnsafe((TrustedHTML or DOMString))]
expected: FAIL
[Element interface: operation getHTML(optional GetHTMLOptions)]
expected: FAIL
@ -5975,12 +5966,6 @@
[OffscreenCanvasRenderingContext2D interface: attribute lang]
expected: FAIL
[Element interface: document.createElement("div") must inherit property "setHTMLUnsafe((TrustedHTML or DOMString))" with the proper type]
expected: FAIL
[Element interface: calling setHTMLUnsafe((TrustedHTML or DOMString)) on document.createElement("div") with too few arguments must throw TypeError]
expected: FAIL
[Element interface: document.createElement("div") must inherit property "getHTML(optional GetHTMLOptions)" with the proper type]
expected: FAIL
@ -7810,30 +7795,6 @@
[HTMLScriptElement interface: calling supports(DOMString) on document.createElement("script") with too few arguments must throw TypeError]
expected: FAIL
[HTMLTemplateElement interface: attribute shadowRootMode]
expected: FAIL
[HTMLTemplateElement interface: attribute shadowRootDelegatesFocus]
expected: FAIL
[HTMLTemplateElement interface: attribute shadowRootClonable]
expected: FAIL
[HTMLTemplateElement interface: attribute shadowRootSerializable]
expected: FAIL
[HTMLTemplateElement interface: document.createElement("template") must inherit property "shadowRootMode" with the proper type]
expected: FAIL
[HTMLTemplateElement interface: document.createElement("template") must inherit property "shadowRootDelegatesFocus" with the proper type]
expected: FAIL
[HTMLTemplateElement interface: document.createElement("template") must inherit property "shadowRootClonable" with the proper type]
expected: FAIL
[HTMLTemplateElement interface: document.createElement("template") must inherit property "shadowRootSerializable" with the proper type]
expected: FAIL
[HTMLMarqueeElement interface: existence and properties of interface object]
expected: FAIL

View file

@ -1,3 +0,0 @@
[form-indexed-element-shadow.html]
[form.elements: indexed access reflects DOM order, not flat tree]
expected: FAIL

View file

@ -1,3 +0,0 @@
[template-shadowrootmode-img-src.tentative.html]
[Speculative parsing, page load: template-shadowrootmode-img-src]
expected: FAIL

View file

@ -1,3 +0,0 @@
[template-shadowrootmode-link-stylesheet.tentative.html]
[Speculative parsing, page load: template-shadowrootmode-link-stylesheet]
expected: FAIL

View file

@ -1,3 +0,0 @@
[template-shadowrootmode-script-src.tentative.html]
[Speculative parsing, page load: template-shadowrootmode-script-src]
expected: FAIL

View file

@ -1,3 +0,0 @@
[Element-setHTMLUnsafe-04.html]
[setHTMLUnsafe should leave the removed children alone.]
expected: FAIL

View file

@ -1,6 +1,3 @@
[setHTMLUnsafe-CEReactions.html]
[Element.setHTMLUnsafe should trigger custom element reactions.]
expected: FAIL
[ShadowRoot.setHTMLUnsafe should trigger custom element reactions.]
expected: FAIL

View file

@ -1,6 +0,0 @@
[setHTMLUnsafe-xml.html]
[setHTMLUnsafe should still parse HTML even in XML documents.]
expected: FAIL
[setHTMLUnsafe should still parse HTML even in SVG documents.]
expected: FAIL

View file

@ -1,15 +1,6 @@
[setHTMLUnsafe.html]
[Element: setHTMLUnsafe with no shadowdom.]
expected: FAIL
[Element: setHTMLUnsafe with shadowdom.]
expected: FAIL
[ShadowRoot: setHTMLUnsafe with no shadowdom.]
expected: FAIL
[ShadowRoot: setHTMLUnsafe with shadowdom.]
expected: FAIL
[template.setHTMLUnsafe() should modify template content fragment rather than actual children.]
expected: FAIL

View file

@ -1,2 +0,0 @@
[cross-shadow-boundary-6.html]
expected: TIMEOUT

View file

@ -1,6 +1,3 @@
[Range-isPointInRange.html]
[isPointInRange() test for collapsed selection]
expected: FAIL
[isPointInRange() test for non-collapsed selection]
expected: FAIL

View file

@ -1,2 +1,9 @@
[Selection-getComposedRanges-range-update.html]
expected: ERROR
[modify getRangeAt() range.]
expected: FAIL
[modify createRange() range added to selection after setEnd call.]
expected: FAIL
[modify createRange() range added to selection before setStart/setEnd calls.]
expected: FAIL

View file

@ -1,2 +1,12 @@
[Selection-isCollapsed.html]
expected: ERROR
[Selection in light tree is not collapsed]
expected: FAIL
[Selection in shadow tree is not collapsed]
expected: FAIL
[Selection between light and shadow tree is not valid and is collapsed. Composed range is not collapsed]
expected: FAIL
[Selection between two shadow trees is not valid and is collapsed. Composed range is not collapsed]
expected: FAIL

View file

@ -1,7 +1,4 @@
[HighlightRegistry-highlightsFromPoint.html]
[CSS.highlights.highlightsFromPoint() should throw when called with nodes that are not ShadowRoot objects in options.]
expected: FAIL
[CSS.highlights.highlightsFromPoint() returns Highlights present at a given point inside a shadow tree in the right order.]
expected: FAIL

View file

@ -2,59 +2,8 @@
[Declarative Shadow DOM: Basic test]
expected: FAIL
[Declarative Shadow DOM: Feature detection]
expected: FAIL
[Shadowrootmode reflection]
expected: FAIL
[Shadowrootmode reflection, setter]
expected: FAIL
[Shadowrootdelegatesfocus reflection]
expected: FAIL
[Shadowrootdelegatesfocus reflection, setter]
expected: FAIL
[Shadowrootclonable reflection]
expected: FAIL
[Shadowrootclonable reflection, setter]
expected: FAIL
[Declarative Shadow DOM: Fragment parser basic test]
expected: FAIL
[Declarative Shadow DOM: Invalid shadow root attribute]
expected: FAIL
[Declarative Shadow DOM: Closed shadow root attribute]
expected: FAIL
[Declarative Shadow DOM: Missing closing tag]
expected: FAIL
[Declarative Shadow DOM: delegates focus attribute]
expected: FAIL
[Declarative Shadow DOM: clonable attribute]
expected: FAIL
[Declarative Shadow DOM: Multiple roots]
expected: FAIL
[Declarative Shadow DOM: template containing declarative shadow root (with shadowrootclonable)]
expected: FAIL
[Declarative Shadow DOM: template containing (deeply nested) declarative shadow root]
expected: FAIL
[Declarative Shadow DOM: template containing a template containing declarative shadow root]
expected: FAIL
[Declarative Shadow DOM: template containing declarative shadow root and UA shadow root]
expected: FAIL
[Declarative Shadow DOM: explicit test that exceptions are not thrown]
expected: FAIL

View file

@ -1,25 +1,10 @@
[declarative-shadow-dom-opt-in.html]
expected: TIMEOUT
[Non-fragment parsing needs no opt-in]
expected: FAIL
[innerHTML on shadowRoot]
expected: PASS
[document.write allowed from synchronous script loaded from main document]
expected: FAIL
[document.write disallowed on fresh document]
expected: FAIL
[iframe]
expected: FAIL
[iframe, no sandbox]
expected: FAIL
[sandboxed iframe allows declarative Shadow DOM]
expected: TIMEOUT
[iframe with no sandbox allows declarative Shadow DOM]
expected: FAIL

View file

@ -1,3 +0,0 @@
[declarative-shadow-dom-repeats-2.html]
[Repeated declarative shadow roots keep only the first]
expected: FAIL

View file

@ -1,7 +1,4 @@
[declarative-shadow-dom-repeats.html]
[Repeated declarative shadow roots keep only the first]
expected: FAIL
[Calling attachShadow() on declarative shadow root must match mode]
expected: FAIL

View file

@ -0,0 +1,3 @@
[declarative-with-disabled-shadow.html]
[Declarative Shadow DOM: declarative shadow should fail if attachShadow() already called]
expected: FAIL

View file

@ -1,2 +0,0 @@
[innerhtml-before-closing-tag.html]
expected: ERROR

View file

@ -1,6 +0,0 @@
[move-template-before-closing-tag.html]
[Moving the template node during parsing should attach to initial parent (content before observer)]
expected: FAIL
[Moving the template node during parsing should attach to initial parent (content after observer)]
expected: FAIL

View file

@ -1,2 +0,0 @@
[script-access.html]
expected: ERROR

View file

@ -4,3 +4,6 @@
[Verifies that HTMLElement.offsetTop accounts for shadow boundaries when nested in multiple shadow roots.]
expected: FAIL
[Verifies that HTMLElement.offsetLeft accounts for shadow boundaries.]
expected: FAIL

View file

@ -1,9 +0,0 @@
[shadow-root-clonable.html]
[declarative shadow roots do *not* get clonable: true automatically]
expected: FAIL
[declarative shadow roots can opt in to clonable with shadowrootclonable]
expected: FAIL
[declarative shadow roots inside templates do *not* get cloned automatically]
expected: FAIL