Changeset 285740 in webkit
- Timestamp:
- Nov 12, 2021 2:11:13 PM (8 months ago)
- Location:
- trunk
- Files:
-
- 11 edited
-
LayoutTests/imported/w3c/ChangeLog (modified) (1 diff)
-
LayoutTests/imported/w3c/web-platform-tests/custom-elements/CustomElementRegistry-expected.txt (modified) (3 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading-expected.txt (modified) (2 diffs)
-
LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element-expected.txt (modified) (1 diff)
-
Source/WebCore/ChangeLog (modified) (1 diff)
-
Source/WebCore/bindings/js/JSCustomElementInterface.cpp (modified) (2 diffs)
-
Source/WebCore/bindings/js/JSCustomElementInterface.h (modified) (2 diffs)
-
Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp (modified) (1 diff)
-
Source/WebCore/dom/CustomElementRegistry.cpp (modified) (1 diff)
-
Source/WebCore/dom/CustomElementRegistry.h (modified) (3 diffs)
-
Source/WebCore/dom/Element.cpp (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/imported/w3c/ChangeLog
r285738 r285740 1 2021-11-12 Alexey Shvayka <ashvayka@apple.com> 2 3 Implement custom element definition's *disable shadow* flag 4 https://bugs.webkit.org/show_bug.cgi?id=233023 5 6 Reviewed by Geoffrey Garen. 7 8 Rebaseline WPT tests now that more checks are passing or failing later on. 9 10 * web-platform-tests/custom-elements/CustomElementRegistry-expected.txt: 11 * web-platform-tests/custom-elements/upgrading-expected.txt: 12 * web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element-expected.txt: 13 1 14 2021-11-12 Commit Queue <commit-queue@webkit.org> 2 15 -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/CustomElementRegistry-expected.txt
r267651 r285740 10 10 PASS customElements.define must validate the custom element name before checking the element definition is running flag 11 11 PASS customElements.define unset the element definition is running flag before upgrading custom elements 12 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 112 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 13 13 PASS Custom Elements: CustomElementRegistry interface 14 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 114 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 15 15 PASS customElements.define must rethrow an exception thrown while getting "prototype" property of the constructor 16 16 PASS customElements.define must throw when "prototype" property of the constructor is not an object … … 18 18 PASS customElements.define must rethrow an exception thrown while getting callbacks on the constructor prototype 19 19 PASS customElements.define must rethrow an exception thrown while converting a callback value to Function callback type 20 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 420 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 21 21 PASS customElements.define must rethrow an exception thrown while getting observedAttributes on the constructor prototype 22 22 PASS customElements.define must rethrow an exception thrown while converting the value of observedAttributes to sequence<DOMString> … … 24 24 PASS customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on observedAttributes 25 25 PASS customElements.define must not throw even if "observedAttributes" fails to convert if "attributeChangedCallback" is not defined 26 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 27 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 28 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 29 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 26 PASS customElements.define must rethrow an exception thrown while getting disabledFeatures on the constructor prototype 27 PASS customElements.define must rethrow an exception thrown while converting the value of disabledFeatures to sequence<DOMString> 28 PASS customElements.define must rethrow an exception thrown while iterating over disabledFeatures to sequence<DOMString> 29 PASS customElements.define must rethrow an exception thrown while retrieving Symbol.iterator on disabledFeatures 30 30 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 31 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 131 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 32 32 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 33 33 PASS customElements.define must define an instantiatable custom element -
trunk/LayoutTests/imported/w3c/web-platform-tests/custom-elements/upgrading-expected.txt
r267651 r285740 1 CONSOLE MESSAGE: NotSupportedError: Failed to upgrade an element with shadow root: the custom element definition disallows shadow roots. 1 2 2 3 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 … … 25 26 PASS Adopting (and leaving disconnceted) an unresolved custom element into the document of an iframe must not enqueue a custom element upgrade reaction 26 27 PASS Adopting and inserting an unresolved custom element into the document of an iframe must enqueue a custom element upgrade reaction 27 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 28 PASS If definition's disable shadow is true and element's shadow root is non-null, then throw a "NotSupportedError" DOMException. 28 29 PASS Infinite constructor recursion with upgrade(this) should not be possible 29 30 PASS Infinite constructor recursion with appendChild should not be possible -
trunk/LayoutTests/imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element-expected.txt
r267647 r285740 2 2 PASS Element.attachShadow must create an instance of ShadowRoot for autonomous custom elements 3 3 PASS Element.attachShadow must create an instance of ShadowRoot for undefined autonomous custom elements 4 FAIL Element.attachShadow for an autonomous custom element with disabledFeatures=["shadow"] should throw a NotSupportedError assert_throws_dom: Definition, not a host function "() => { 5 document.createElement('shadow-disabled-element').attachShadow({mode: 'closed'}); 6 }" did not throw 4 PASS Element.attachShadow for an autonomous custom element with disabledFeatures=["shadow"] should throw a NotSupportedError 7 5 FAIL Element.attachShadow for a customized built-in element with disabledFeatures=["shadow"] should throw a NotSupportedError assert_throws_dom: Definition, not a host function "() => { 8 6 h2.attachShadow({mode: 'closed'}); -
trunk/Source/WebCore/ChangeLog
r285738 r285740 1 2021-11-12 Alexey Shvayka <ashvayka@apple.com> 2 3 Implement custom element definition's *disable shadow* flag 4 https://bugs.webkit.org/show_bug.cgi?id=233023 5 6 Reviewed by Geoffrey Garen. 7 8 This change implements *disable shadow* flag that precludes attachShadow() [1] 9 as well as upgrading an element with already attached shadow root [2]. 10 11 Aligns WebKit with Blink and Gecko. 12 Preserves the fast path for non-custom elements. 13 14 [1] https://dom.spec.whatwg.org/#ref-for-concept-custom-element-definition-disable-shadow 15 [2] https://html.spec.whatwg.org/multipage/custom-elements.html#upgrades:concept-custom-element-definition-disable-shadow 16 17 Tests: imported/w3c/web-platform-tests/custom-elements/CustomElementRegistry.html 18 imported/w3c/web-platform-tests/custom-elements/upgrading.html 19 imported/w3c/web-platform-tests/shadow-dom/Element-interface-attachShadow-custom-element.html 20 21 * bindings/js/JSCustomElementInterface.cpp: 22 (WebCore::JSCustomElementInterface::JSCustomElementInterface): 23 (WebCore::JSCustomElementInterface::upgradeElement): 24 * bindings/js/JSCustomElementInterface.h: 25 (WebCore::JSCustomElementInterface::disableShadow): 26 (WebCore::JSCustomElementInterface::isShadowDisabled const): 27 * bindings/js/JSCustomElementRegistryCustom.cpp: 28 (WebCore::JSCustomElementRegistry::define): 29 * dom/CustomElementRegistry.cpp: 30 (WebCore::CustomElementRegistry::addElementDefinition): 31 * dom/CustomElementRegistry.h: 32 (WebCore::CustomElementRegistry::isShadowDisabled const): 33 * dom/Element.cpp: 34 (WebCore::canAttachAuthorShadowRoot): 35 1 36 2021-11-12 Commit Queue <commit-queue@webkit.org> 2 37 -
trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp
r284857 r285740 51 51 , m_constructor(constructor) 52 52 , m_isolatedWorld(globalObject->world()) 53 , m_isShadowDisabled(false) 53 54 { 54 55 } … … 208 209 m_constructionStack.append(&element); 209 210 211 if (m_isShadowDisabled && element.shadowRoot()) { 212 element.clearReactionQueueFromFailedCustomElement(); 213 reportException(lexicalGlobalObject, createDOMException(lexicalGlobalObject, NotSupportedError, "Failed to upgrade an element with shadow root: the custom element definition disallows shadow roots.")); 214 return; 215 } 216 210 217 MarkedArgumentBuffer args; 211 218 ASSERT(!args.hasOverflowed()); -
trunk/Source/WebCore/bindings/js/JSCustomElementInterface.h
r284857 r285740 79 79 void invokeAttributeChangedCallback(Element&, const QualifiedName&, const AtomString& oldValue, const AtomString& newValue); 80 80 81 void disableShadow() { m_isShadowDisabled = true; } 82 bool isShadowDisabled() const { return m_isShadowDisabled; } 83 81 84 ScriptExecutionContext* scriptExecutionContext() const { return ContextDestructionObserver::scriptExecutionContext(); } 82 85 JSC::JSObject* constructor() { return m_constructor.get(); } … … 106 109 Vector<RefPtr<Element>, 1> m_constructionStack; 107 110 HashSet<AtomString> m_observedAttributes; 111 bool m_isShadowDisabled : 1; 108 112 }; 109 113 -
trunk/Source/WebCore/bindings/js/JSCustomElementRegistryCustom.cpp
r266142 r285740 157 157 } 158 158 159 auto disabledFeaturesValue = constructor->get(&lexicalGlobalObject, Identifier::fromString(vm, "disabledFeatures")); 160 RETURN_IF_EXCEPTION(scope, { }); 161 if (!disabledFeaturesValue.isUndefined()) { 162 auto disabledFeatures = convert<IDLSequence<IDLDOMString>>(lexicalGlobalObject, disabledFeaturesValue); 163 RETURN_IF_EXCEPTION(scope, { }); 164 if (disabledFeatures.contains("shadow"_s)) 165 elementInterface->disableShadow(); 166 } 167 159 168 auto addToGlobalObjectWithPrivateName = [&] (JSObject* objectToAdd) { 160 169 if (objectToAdd) { -
trunk/Source/WebCore/dom/CustomElementRegistry.cpp
r266269 r285740 74 74 m_nameMap.add(localName, elementInterface.copyRef()); 75 75 76 if (elementInterface->isShadowDisabled()) 77 m_disabledShadowSet.add(localName); 78 76 79 if (auto* document = m_window.document()) 77 80 enqueueUpgradeInShadowIncludingTreeOrder(*document, elementInterface.get()); -
trunk/Source/WebCore/dom/CustomElementRegistry.h
r266142 r285740 29 29 #include "QualifiedName.h" 30 30 #include <wtf/HashMap.h> 31 #include <wtf/HashSet.h> 31 32 #include <wtf/text/AtomString.h> 32 33 #include <wtf/text/AtomStringHash.h> … … 68 69 69 70 HashMap<AtomString, Ref<DeferredPromise>>& promiseMap() { return m_promiseMap; } 71 bool isShadowDisabled(const AtomString& name) const { return m_disabledShadowSet.contains(name); } 70 72 71 73 private: … … 76 78 HashMap<const JSC::JSObject*, JSCustomElementInterface*> m_constructorMap; 77 79 HashMap<AtomString, Ref<DeferredPromise>> m_promiseMap; 80 HashSet<AtomString> m_disabledShadowSet; 78 81 79 82 bool m_elementDefinitionIsRunning { false }; -
trunk/Source/WebCore/dom/Element.cpp
r285640 r285740 2486 2486 2487 2487 const auto& localName = element.localName(); 2488 return tagNames.get().contains(localName) || Document::validateCustomElementName(localName) == CustomElementNameValidationStatus::Valid; 2488 if (tagNames.get().contains(localName)) 2489 return true; 2490 2491 if (Document::validateCustomElementName(localName) == CustomElementNameValidationStatus::Valid) { 2492 if (auto* window = element.document().domWindow()) { 2493 auto* registry = window->customElementRegistry(); 2494 if (registry && registry->isShadowDisabled(localName)) 2495 return false; 2496 } 2497 2498 return true; 2499 } 2500 2501 return false; 2489 2502 } 2490 2503
Note: See TracChangeset
for help on using the changeset viewer.