<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN"
"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head><meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>[285740] trunk</title>
</head>
<body>

<style type="text/css"><!--
#msg dl.meta { border: 1px #006 solid; background: #369; padding: 6px; color: #fff; }
#msg dl.meta dt { float: left; width: 6em; font-weight: bold; }
#msg dt:after { content:':';}
#msg dl, #msg dt, #msg ul, #msg li, #header, #footer, #logmsg { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt;  }
#msg dl a { font-weight: bold}
#msg dl a:link    { color:#fc3; }
#msg dl a:active  { color:#ff0; }
#msg dl a:visited { color:#cc6; }
h3 { font-family: verdana,arial,helvetica,sans-serif; font-size: 10pt; font-weight: bold; }
#msg pre { overflow: auto; background: #ffc; border: 1px #fa0 solid; padding: 6px; }
#logmsg { background: #ffc; border: 1px #fa0 solid; padding: 1em 1em 0 1em; }
#logmsg p, #logmsg pre, #logmsg blockquote { margin: 0 0 1em 0; }
#logmsg p, #logmsg li, #logmsg dt, #logmsg dd { line-height: 14pt; }
#logmsg h1, #logmsg h2, #logmsg h3, #logmsg h4, #logmsg h5, #logmsg h6 { margin: .5em 0; }
#logmsg h1:first-child, #logmsg h2:first-child, #logmsg h3:first-child, #logmsg h4:first-child, #logmsg h5:first-child, #logmsg h6:first-child { margin-top: 0; }
#logmsg ul, #logmsg ol { padding: 0; list-style-position: inside; margin: 0 0 0 1em; }
#logmsg ul { text-indent: -1em; padding-left: 1em; }#logmsg ol { text-indent: -1.5em; padding-left: 1.5em; }
#logmsg > ul, #logmsg > ol { margin: 0 0 1em 0; }
#logmsg pre { background: #eee; padding: 1em; }
#logmsg blockquote { border: 1px solid #fa0; border-left-width: 10px; padding: 1em 1em 0 1em; background: white;}
#logmsg dl { margin: 0; }
#logmsg dt { font-weight: bold; }
#logmsg dd { margin: 0; padding: 0 0 0.5em 0; }
#logmsg dd:before { content:'\00bb';}
#logmsg table { border-spacing: 0px; border-collapse: collapse; border-top: 4px solid #fa0; border-bottom: 1px solid #fa0; background: #fff; }
#logmsg table th { text-align: left; font-weight: normal; padding: 0.2em 0.5em; border-top: 1px dotted #fa0; }
#logmsg table td { text-align: right; border-top: 1px dotted #fa0; padding: 0.2em 0.5em; }
#logmsg table thead th { text-align: center; border-bottom: 1px solid #fa0; }
#logmsg table th.Corner { text-align: left; }
#logmsg hr { border: none 0; border-top: 2px dashed #fa0; height: 1px; }
#header, #footer { color: #fff; background: #636; border: 1px #300 solid; padding: 6px; }
#patch { width: 100%; }
#patch h4 {font-family: verdana,arial,helvetica,sans-serif;font-size:10pt;padding:8px;background:#369;color:#fff;margin:0;}
#patch .propset h4, #patch .binary h4 {margin:0;}
#patch pre {padding:0;line-height:1.2em;margin:0;}
#patch .diff {width:100%;background:#eee;padding: 0 0 10px 0;overflow:auto;}
#patch .propset .diff, #patch .binary .diff  {padding:10px 0;}
#patch span {display:block;padding:0 10px;}
#patch .modfile, #patch .addfile, #patch .delfile, #patch .propset, #patch .binary, #patch .copfile {border:1px solid #ccc;margin:10px 0;}
#patch ins {background:#dfd;text-decoration:none;display:block;padding:0 10px;}
#patch del {background:#fdd;text-decoration:none;display:block;padding:0 10px;}
#patch .lines, .info {color:#888;background:#fff;}
--></style>
<div id="msg">
<dl class="meta">
<dt>Revision</dt> <dd><a href="http://trac.webkit.org/projects/webkit/changeset/285740">285740</a></dd>
<dt>Author</dt> <dd>commit-queue@webkit.org</dd>
<dt>Date</dt> <dd>2021-11-12 14:11:13 -0800 (Fri, 12 Nov 2021)</dd>
</dl>

<h3>Log Message</h3>
<pre>Implement custom element definition's *disable shadow* flag
https://bugs.webkit.org/show_bug.cgi?id=233023

Patch by Alexey Shvayka <ashvayka@apple.com> on 2021-11-12
Reviewed by Geoffrey Garen.

LayoutTests/imported/w3c:

Rebaseline WPT tests now that more checks are passing or failing later on.

* web-platform-tests/custom-elements/CustomElementRegistry-expected.txt:
* web-platform-tests/custom-elements/upgrading-expected.txt:
* web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element-expected.txt:

Source/WebCore:

This change implements *disable shadow* flag that precludes attachShadow() [1]
as well as upgrading an element with already attached shadow root [2].

Aligns WebKit with Blink and Gecko.
Preserves the fast path for non-custom elements.

[1] https://dom.spec.whatwg.org/#ref-for-concept-custom-element-definition-disable-shadow
[2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades:concept-custom-element-definition-disable-shadow

Tests: imported/w3c/web-platform-tests/custom-elements/CustomElementRegistry.html
       imported/w3c/web-platform-tests/custom-elements/upgrading.html
       imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element.html

* bindings/js/JSCustomElementInterface.cpp:
(WebCore::JSCustomElementInterface::JSCustomElementInterface):
(WebCore::JSCustomElementInterface::upgradeElement):
* bindings/js/JSCustomElementInterface.h:
(WebCore::JSCustomElementInterface::disableShadow):
(WebCore::JSCustomElementInterface::isShadowDisabled const):
* bindings/js/JSCustomElementRegistryCustom.cpp:
(WebCore::JSCustomElementRegistry::define):
* dom/CustomElementRegistry.cpp:
(WebCore::CustomElementRegistry::addElementDefinition):
* dom/CustomElementRegistry.h:
(WebCore::CustomElementRegistry::isShadowDisabled const):
* dom/Element.cpp:
(WebCore::canAttachAuthorShadowRoot):</pre>

<h3>Modified Paths</h3>
<ul>
<li><a href="#trunkLayoutTestsimportedw3cChangeLog">trunk/LayoutTests/imported/w3c/ChangeLog</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscustomelementsCustomElementRegistryexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/CustomElementRegistry-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestscustomelementsupgradingexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading-expected.txt</a></li>
<li><a href="#trunkLayoutTestsimportedw3cwebplatformtestsshadowdomElementinterfaceattachShadowcustomelementexpectedtxt">trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element-expected.txt</a></li>
<li><a href="#trunkSourceWebCoreChangeLog">trunk/Source/WebCore/ChangeLog</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCustomElementInterfacecpp">trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCustomElementInterfaceh">trunk/Source/WebCore/bindings/js/JSCustomElementInterface.h</a></li>
<li><a href="#trunkSourceWebCorebindingsjsJSCustomElementRegistryCustomcpp">trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp</a></li>
<li><a href="#trunkSourceWebCoredomCustomElementRegistrycpp">trunk/Source/WebCore/dom/CustomElementRegistry.cpp</a></li>
<li><a href="#trunkSourceWebCoredomCustomElementRegistryh">trunk/Source/WebCore/dom/CustomElementRegistry.h</a></li>
<li><a href="#trunkSourceWebCoredomElementcpp">trunk/Source/WebCore/dom/Element.cpp</a></li>
</ul>

</div>
<div id="patch">
<h3>Diff</h3>
<a id="trunkLayoutTestsimportedw3cChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/ChangeLog (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/ChangeLog 2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/LayoutTests/imported/w3c/ChangeLog    2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -1,3 +1,16 @@
</span><ins>+2021-11-12  Alexey Shvayka  <ashvayka@apple.com>
+
+        Implement custom element definition's *disable shadow* flag
+        https://bugs.webkit.org/show_bug.cgi?id=233023
+
+        Reviewed by Geoffrey Garen.
+
+        Rebaseline WPT tests now that more checks are passing or failing later on.
+
+        * web-platform-tests/custom-elements/CustomElementRegistry-expected.txt:
+        * web-platform-tests/custom-elements/upgrading-expected.txt:
+        * web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element-expected.txt:
+
</ins><span class="cx"> 2021-11-12  Commit Queue  <commit-queue@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, reverting r285639.
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscustomelementsCustomElementRegistryexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/CustomElementRegistry-expected.txt (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/CustomElementRegistry-expected.txt     2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/CustomElementRegistry-expected.txt        2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -9,26 +9,26 @@
</span><span class="cx"> PASS customElements.define must check IsConstructor on the constructor before checking the element definition is running flag
</span><span class="cx"> PASS customElements.define must validate the custom element name before checking the element definition is running flag
</span><span class="cx"> PASS customElements.define unset the element definition is running flag before upgrading custom elements
</span><del>-FAIL customElements.define must not throw when defining another custom element in a different global object during Get(constructor, "prototype") assert_array_equals: customElements.define must get "prototype", "disabledFeatures", and "formAssociated" on the constructor lengths differ, expected array ["prototype", "disabledFeatures", "formAssociated"] length 3, got ["prototype"] length 1
</del><ins>+FAIL customElements.define must not throw when defining another custom element in a different global object during Get(constructor, "prototype") assert_array_equals: customElements.define must get "prototype", "disabledFeatures", and "formAssociated" on the constructor lengths differ, expected array ["prototype", "disabledFeatures", "formAssociated"] length 3, got ["prototype", "disabledFeatures"] length 2
</ins><span class="cx"> PASS Custom Elements: CustomElementRegistry interface
</span><del>-FAIL customElements.define must get "prototype", "disabledFeatures", and "formAssociated" property of the constructor assert_array_equals: lengths differ, expected array ["prototype", "disabledFeatures", "formAssociated"] length 3, got ["prototype"] length 1
</del><ins>+FAIL customElements.define must get "prototype", "disabledFeatures", and "formAssociated" property of the constructor assert_array_equals: lengths differ, expected array ["prototype", "disabledFeatures", "formAssociated"] length 3, got ["prototype", "disabledFeatures"] length 2
</ins><span class="cx"> PASS customElements.define must rethrow an exception thrown while getting "prototype" property of the constructor
</span><span class="cx"> PASS customElements.define must throw when "prototype" property of the constructor is not an object
</span><span class="cx"> PASS customElements.define must get callbacks of the constructor prototype
</span><span class="cx"> PASS customElements.define must rethrow an exception thrown while getting callbacks on the constructor prototype
</span><span class="cx"> PASS customElements.define must rethrow an exception thrown while converting a callback value to Function callback type
</span><del>-FAIL customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present assert_array_equals: lengths differ, expected array [0, "prototype", 5, "observedAttributes", 6, "disabledFeatures", 7, "formAssociated"] length 8, got [0, "prototype", 5, "observedAttributes"] length 4
</del><ins>+FAIL customElements.define must get "observedAttributes" property on the constructor prototype when "attributeChangedCallback" is present assert_array_equals: lengths differ, expected array [0, "prototype", 5, "observedAttributes", 6, "disabledFeatures", 7, "formAssociated"] length 8, got [0, "prototype", 5, "observedAttributes", 6, "disabledFeatures"] length 6
</ins><span class="cx"> PASS customElements.define must rethrow an exception thrown while getting observedAttributes on the constructor prototype
</span><span class="cx"> PASS customElements.define must rethrow an exception thrown while converting the value of observedAttributes to sequence<DOMString>
</span><span class="cx"> PASS customElements.define must rethrow an exception thrown while iterating over observedAttributes to sequence<DOMString>
</span><span class="cx"> PASS customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on observedAttributes
</span><span class="cx"> PASS customElements.define must not throw even if "observedAttributes" fails to convert if "attributeChangedCallback" is not defined
</span><del>-FAIL customElements.define must rethrow an exception thrown while getting disabledFeatures on the constructor prototype assert_throws_exactly: function "() => customElements.define('element-with-throwing-disabled-features', proxy)" did not throw
-FAIL customElements.define must rethrow an exception thrown while converting the value of disabledFeatures to sequence<DOMString> assert_throws_js: function "() => customElements.define('element-with-invalid-disabled-features', proxy)" did not throw
-FAIL customElements.define must rethrow an exception thrown while iterating over disabledFeatures to sequence<DOMString> assert_throws_exactly: function "() => customElements.define('element-with-generator-disabled-features', constructor)" did not throw
-FAIL customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on disabledFeatures assert_throws_js: function "() => customElements.define('element-with-disabled-features-with-uncallable-iterator', constructor)" did not throw
</del><ins>+PASS customElements.define must rethrow an exception thrown while getting disabledFeatures on the constructor prototype
+PASS customElements.define must rethrow an exception thrown while converting the value of disabledFeatures to sequence<DOMString>
+PASS customElements.define must rethrow an exception thrown while iterating over disabledFeatures to sequence<DOMString>
+PASS customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on disabledFeatures
</ins><span class="cx"> FAIL customElements.define must rethrow an exception thrown while getting formAssociated on the constructor prototype assert_throws_exactly: function "() => customElements.define('element-with-throwing-form-associated', proxy)" did not throw
</span><del>-FAIL customElements.define must get four additional callbacks on the prototype if formAssociated is converted to true assert_array_equals: customElements.define must get "prototype", "disabledFeatures", and "formAssociated" on the constructor lengths differ, expected array ["prototype", "disabledFeatures", "formAssociated"] length 3, got ["prototype"] length 1
</del><ins>+FAIL customElements.define must get four additional callbacks on the prototype if formAssociated is converted to true assert_array_equals: customElements.define must get "prototype", "disabledFeatures", and "formAssociated" on the constructor lengths differ, expected array ["prototype", "disabledFeatures", "formAssociated"] length 3, got ["prototype", "disabledFeatures"] length 2
</ins><span class="cx"> FAIL customElements.define must rethrow an exception thrown while getting additional formAssociated callbacks on the constructor prototype assert_throws_exactly: function "() => customElements.define('element-with-throwing-callback-2', proxy)" did not throw
</span><span class="cx"> PASS customElements.define must define an instantiatable custom element
</span><span class="cx"> PASS customElements.define must upgrade elements in the shadow-including tree order
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestscustomelementsupgradingexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading-expected.txt (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading-expected.txt 2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading-expected.txt    2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -1,3 +1,4 @@
</span><ins>+CONSOLE MESSAGE: NotSupportedError: Failed to upgrade an element with shadow root: the custom element definition disallows shadow roots.
</ins><span class="cx"> 
</span><span class="cx"> PASS Creating an element in the document of the template elements must not enqueue a custom element upgrade reaction because the document does not have a browsing context
</span><span class="cx"> PASS Creating an element in the document of the template elements and inserting into the document must not enqueue a custom element upgrade reaction
</span><span class="lines">@@ -24,7 +25,7 @@
</span><span class="cx"> PASS "define" in the document of an iframe must enqueue a custom element upgrade reaction on a connected unresolved custom element
</span><span class="cx"> PASS Adopting (and leaving disconnceted) an unresolved custom element into the document of an iframe must not enqueue a custom element upgrade reaction
</span><span class="cx"> PASS Adopting and inserting an unresolved custom element into the document of an iframe must enqueue a custom element upgrade reaction
</span><del>-FAIL If definition's disable shadow is true and element's shadow root is non-null, then throw a "NotSupportedError" DOMException. assert_false: Upgrading should fail. expected false got true
</del><ins>+PASS If definition's disable shadow is true and element's shadow root is non-null, then throw a "NotSupportedError" DOMException.
</ins><span class="cx"> PASS Infinite constructor recursion with upgrade(this) should not be possible
</span><span class="cx"> PASS Infinite constructor recursion with appendChild should not be possible
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkLayoutTestsimportedw3cwebplatformtestsshadowdomElementinterfaceattachShadowcustomelementexpectedtxt"></a>
<div class="modfile"><h4>Modified: trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element-expected.txt (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element-expected.txt  2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element-expected.txt     2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -1,9 +1,7 @@
</span><span class="cx"> 
</span><span class="cx"> PASS Element.attachShadow must create an instance of ShadowRoot for autonomous custom elements
</span><span class="cx"> PASS Element.attachShadow must create an instance of ShadowRoot for undefined autonomous custom elements
</span><del>-FAIL Element.attachShadow for an autonomous custom element with disabledFeatures=["shadow"] should throw a NotSupportedError assert_throws_dom: Definition, not a host function "() => {
-    document.createElement('shadow-disabled-element').attachShadow({mode: 'closed'});
-  }" did not throw
</del><ins>+PASS Element.attachShadow for an autonomous custom element with disabledFeatures=["shadow"] should throw a NotSupportedError
</ins><span class="cx"> FAIL Element.attachShadow for a customized built-in element with disabledFeatures=["shadow"] should throw a NotSupportedError assert_throws_dom: Definition, not a host function "() => {
</span><span class="cx">     h2.attachShadow({mode: 'closed'});
</span><span class="cx">   }" did not throw
</span></span></pre></div>
<a id="trunkSourceWebCoreChangeLog"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/ChangeLog (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/ChangeLog   2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/Source/WebCore/ChangeLog      2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -1,3 +1,38 @@
</span><ins>+2021-11-12  Alexey Shvayka  <ashvayka@apple.com>
+
+        Implement custom element definition's *disable shadow* flag
+        https://bugs.webkit.org/show_bug.cgi?id=233023
+
+        Reviewed by Geoffrey Garen.
+
+        This change implements *disable shadow* flag that precludes attachShadow() [1]
+        as well as upgrading an element with already attached shadow root [2].
+
+        Aligns WebKit with Blink and Gecko.
+        Preserves the fast path for non-custom elements.
+
+        [1] https://dom.spec.whatwg.org/#ref-for-concept-custom-element-definition-disable-shadow
+        [2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades:concept-custom-element-definition-disable-shadow
+
+        Tests: imported/w3c/web-platform-tests/custom-elements/CustomElementRegistry.html
+               imported/w3c/web-platform-tests/custom-elements/upgrading.html
+               imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element.html
+
+        * bindings/js/JSCustomElementInterface.cpp:
+        (WebCore::JSCustomElementInterface::JSCustomElementInterface):
+        (WebCore::JSCustomElementInterface::upgradeElement):
+        * bindings/js/JSCustomElementInterface.h:
+        (WebCore::JSCustomElementInterface::disableShadow):
+        (WebCore::JSCustomElementInterface::isShadowDisabled const):
+        * bindings/js/JSCustomElementRegistryCustom.cpp:
+        (WebCore::JSCustomElementRegistry::define):
+        * dom/CustomElementRegistry.cpp:
+        (WebCore::CustomElementRegistry::addElementDefinition):
+        * dom/CustomElementRegistry.h:
+        (WebCore::CustomElementRegistry::isShadowDisabled const):
+        * dom/Element.cpp:
+        (WebCore::canAttachAuthorShadowRoot):
+
</ins><span class="cx"> 2021-11-12  Commit Queue  <commit-queue@webkit.org>
</span><span class="cx"> 
</span><span class="cx">         Unreviewed, reverting r285639.
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCustomElementInterfacecpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp    2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp       2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -50,6 +50,7 @@
</span><span class="cx">     , m_name(name)
</span><span class="cx">     , m_constructor(constructor)
</span><span class="cx">     , m_isolatedWorld(globalObject->world())
</span><ins>+    , m_isShadowDisabled(false)
</ins><span class="cx"> {
</span><span class="cx"> }
</span><span class="cx"> 
</span><span class="lines">@@ -207,6 +208,12 @@
</span><span class="cx"> 
</span><span class="cx">     m_constructionStack.append(&element);
</span><span class="cx"> 
</span><ins>+    if (m_isShadowDisabled && element.shadowRoot()) {
+        element.clearReactionQueueFromFailedCustomElement();
+        reportException(lexicalGlobalObject, createDOMException(lexicalGlobalObject, NotSupportedError, "Failed to upgrade an element with shadow root: the custom element definition disallows shadow roots."));
+        return;
+    }
+
</ins><span class="cx">     MarkedArgumentBuffer args;
</span><span class="cx">     ASSERT(!args.hasOverflowed());
</span><span class="cx">     JSExecState::instrumentFunction(context, constructData);
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCustomElementInterfaceh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCustomElementInterface.h (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCustomElementInterface.h      2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementInterface.h 2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -78,6 +78,9 @@
</span><span class="cx">     bool observesAttribute(const AtomString& name) const { return m_observedAttributes.contains(name); }
</span><span class="cx">     void invokeAttributeChangedCallback(Element&, const QualifiedName&, const AtomString& oldValue, const AtomString& newValue);
</span><span class="cx"> 
</span><ins>+    void disableShadow() { m_isShadowDisabled = true; }
+    bool isShadowDisabled() const { return m_isShadowDisabled; }
+
</ins><span class="cx">     ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); }
</span><span class="cx">     JSC::JSObject* constructor() { return m_constructor.get(); }
</span><span class="cx"> 
</span><span class="lines">@@ -105,6 +108,7 @@
</span><span class="cx">     Ref<DOMWrapperWorld> m_isolatedWorld;
</span><span class="cx">     Vector<RefPtr<Element>, 1> m_constructionStack;
</span><span class="cx">     HashSet<AtomString> m_observedAttributes;
</span><ins>+    bool m_isShadowDisabled : 1;
</ins><span class="cx"> };
</span><span class="cx"> 
</span><span class="cx"> } // namespace WebCore
</span></span></pre></div>
<a id="trunkSourceWebCorebindingsjsJSCustomElementRegistryCustomcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp       2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp  2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -156,6 +156,15 @@
</span><span class="cx">         }
</span><span class="cx">     }
</span><span class="cx"> 
</span><ins>+    auto disabledFeaturesValue = constructor->get(&lexicalGlobalObject, Identifier::fromString(vm, "disabledFeatures"));
+    RETURN_IF_EXCEPTION(scope, { });
+    if (!disabledFeaturesValue.isUndefined()) {
+        auto disabledFeatures = convert<IDLSequence<IDLDOMString>>(lexicalGlobalObject, disabledFeaturesValue);
+        RETURN_IF_EXCEPTION(scope, { });
+        if (disabledFeatures.contains("shadow"_s))
+            elementInterface->disableShadow();
+    }
+
</ins><span class="cx">     auto addToGlobalObjectWithPrivateName = [&] (JSObject* objectToAdd) {
</span><span class="cx">         if (objectToAdd) {
</span><span class="cx">             PrivateName uniquePrivateName;
</span></span></pre></div>
<a id="trunkSourceWebCoredomCustomElementRegistrycpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/CustomElementRegistry.cpp (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CustomElementRegistry.cpp       2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/Source/WebCore/dom/CustomElementRegistry.cpp  2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -73,6 +73,9 @@
</span><span class="cx">     m_constructorMap.add(elementInterface->constructor(), elementInterface.ptr());
</span><span class="cx">     m_nameMap.add(localName, elementInterface.copyRef());
</span><span class="cx"> 
</span><ins>+    if (elementInterface->isShadowDisabled())
+        m_disabledShadowSet.add(localName);
+
</ins><span class="cx">     if (auto* document = m_window.document())
</span><span class="cx">         enqueueUpgradeInShadowIncludingTreeOrder(*document, elementInterface.get());
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomCustomElementRegistryh"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/CustomElementRegistry.h (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/CustomElementRegistry.h 2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/Source/WebCore/dom/CustomElementRegistry.h    2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -28,6 +28,7 @@
</span><span class="cx"> #include "ContextDestructionObserver.h"
</span><span class="cx"> #include "QualifiedName.h"
</span><span class="cx"> #include <wtf/HashMap.h>
</span><ins>+#include <wtf/HashSet.h>
</ins><span class="cx"> #include <wtf/text/AtomString.h>
</span><span class="cx"> #include <wtf/text/AtomStringHash.h>
</span><span class="cx"> 
</span><span class="lines">@@ -67,6 +68,7 @@
</span><span class="cx">     void upgrade(Node& root);
</span><span class="cx"> 
</span><span class="cx">     HashMap<AtomString, Ref<DeferredPromise>>& promiseMap() { return m_promiseMap; }
</span><ins>+    bool isShadowDisabled(const AtomString& name) const { return m_disabledShadowSet.contains(name); }
</ins><span class="cx"> 
</span><span class="cx"> private:
</span><span class="cx">     CustomElementRegistry(DOMWindow&, ScriptExecutionContext*);
</span><span class="lines">@@ -75,6 +77,7 @@
</span><span class="cx">     HashMap<AtomString, Ref<JSCustomElementInterface>> m_nameMap;
</span><span class="cx">     HashMap<const JSC::JSObject*, JSCustomElementInterface*> m_constructorMap;
</span><span class="cx">     HashMap<AtomString, Ref<DeferredPromise>> m_promiseMap;
</span><ins>+    HashSet<AtomString> m_disabledShadowSet;
</ins><span class="cx"> 
</span><span class="cx">     bool m_elementDefinitionIsRunning { false };
</span><span class="cx"> 
</span></span></pre></div>
<a id="trunkSourceWebCoredomElementcpp"></a>
<div class="modfile"><h4>Modified: trunk/Source/WebCore/dom/Element.cpp (285739 => 285740)</h4>
<pre class="diff"><span>
<span class="info">--- trunk/Source/WebCore/dom/Element.cpp     2021-11-12 21:23:59 UTC (rev 285739)
+++ trunk/Source/WebCore/dom/Element.cpp        2021-11-12 22:11:13 UTC (rev 285740)
</span><span class="lines">@@ -2485,7 +2485,20 @@
</span><span class="cx">         return false;
</span><span class="cx"> 
</span><span class="cx">     const auto& localName = element.localName();
</span><del>-    return tagNames.get().contains(localName) || Document::validateCustomElementName(localName) == CustomElementNameValidationStatus::Valid;
</del><ins>+    if (tagNames.get().contains(localName))
+        return true;
+
+    if (Document::validateCustomElementName(localName) == CustomElementNameValidationStatus::Valid) {
+        if (auto* window = element.document().domWindow()) {
+            auto* registry = window->customElementRegistry();
+            if (registry && registry->isShadowDisabled(localName))
+                return false;
+        }
+
+        return true;
+    }
+
+    return false;
</ins><span class="cx"> }
</span><span class="cx"> 
</span><span class="cx"> ExceptionOr<ShadowRoot&> Element::attachShadow(const ShadowRootInit& init)
</span></span></pre>
</div>
</div>

</body>
</html>