Changeset 205060 in webkit
- Timestamp:
- Aug 26, 2016 5:04:08 PM (8 years ago)
- Location:
- trunk
- Files:
-
- 3 added
- 15 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/LayoutTests/ChangeLog
r205059 r205060 1 2016-08-23 Ryosuke Niwa <rniwa@webkit.org> 2 3 Adopted custom element's callbacks should continue to work 4 https://bugs.webkit.org/show_bug.cgi?id=161065 5 6 Reviewed by Andreas Kling. 7 8 Added test cases for adopting custom elements into various kinds of documents. 9 10 * fast/custom-elements/connected-callbacks-expected.txt: 11 * fast/custom-elements/connected-callbacks.html: 12 * fast/custom-elements/defined-pseudo-class-expected.txt: 13 * fast/custom-elements/defined-pseudo-class.html: 14 * fast/custom-elements/disconnected-callbacks-expected.txt: 15 * fast/custom-elements/disconnected-callbacks.html: 16 * fast/custom-elements/resources/document-types.js: Added. 17 * fast/custom-elements/resources/empty-html-document.html: Added. 18 1 19 2016-08-26 Ryan Haddad <ryanhaddad@apple.com> 2 20 -
trunk/LayoutTests/fast/custom-elements/connected-callbacks-expected.txt
r204611 r205060 1 1 2 2 PASS Inserting a custom element into a document must enqueue and invoke connectedCallback 3 PASS Inserting a custom element into a detached node must not enqueue and invoke connectedCallback 4 FAIL Inserting a custom element into a window-less document must enqueue and invoke connectedCallback assert_array_equals: lengths differ, expected 2 got 0 5 PASS Inserting an ancestor of a custom element into a document must enqueue and invoke connectedCallback 6 FAIL Inserting an ancestor of custom element into a window-less document must enqueue and invoke connectedCallback assert_array_equals: lengths differ, expected 2 got 0 7 PASS Inserting a custom element into a connected shadow tree must enqueue and invoke connectedCallback 8 PASS Inserting the shadow host of a shadow tree with a custom element into a document must enqueue and invoke connectedCallback 9 PASS Inserting a custom element into a detached shadow tree must not enqueue and invoke connectedCallback 3 PASS Inserting an ancestor of custom element into a document must enqueue and invoke connectedCallback 4 PASS Inserting a custom element into a shadow tree in a document must enqueue and invoke connectedCallback 5 PASS Inserting the shadow host of a custom element into a document must enqueue and invoke connectedCallback 6 PASS Inserting a custom element into a detached shadow tree that belongs to a document must not enqueue and invoke connectedCallback 7 PASS Inserting a custom element into a document of a template element must enqueue and invoke connectedCallback 8 PASS Inserting an ancestor of custom element into a document of a template element must enqueue and invoke connectedCallback 9 PASS Inserting a custom element into a shadow tree in a document of a template element must enqueue and invoke connectedCallback 10 PASS Inserting the shadow host of a custom element into a document of a template element must enqueue and invoke connectedCallback 11 PASS Inserting a custom element into a detached shadow tree that belongs to a document of a template element must not enqueue and invoke connectedCallback 12 PASS Inserting a custom element into a new document must enqueue and invoke connectedCallback 13 PASS Inserting an ancestor of custom element into a new document must enqueue and invoke connectedCallback 14 PASS Inserting a custom element into a shadow tree in a new document must enqueue and invoke connectedCallback 15 PASS Inserting the shadow host of a custom element into a new document must enqueue and invoke connectedCallback 16 PASS Inserting a custom element into a detached shadow tree that belongs to a new document must not enqueue and invoke connectedCallback 17 PASS Inserting a custom element into a cloned document must enqueue and invoke connectedCallback 18 PASS Inserting an ancestor of custom element into a cloned document must enqueue and invoke connectedCallback 19 PASS Inserting a custom element into a shadow tree in a cloned document must enqueue and invoke connectedCallback 20 PASS Inserting the shadow host of a custom element into a cloned document must enqueue and invoke connectedCallback 21 PASS Inserting a custom element into a detached shadow tree that belongs to a cloned document must not enqueue and invoke connectedCallback 22 PASS Inserting a custom element into a document created by createHTMLDocument must enqueue and invoke connectedCallback 23 PASS Inserting an ancestor of custom element into a document created by createHTMLDocument must enqueue and invoke connectedCallback 24 PASS Inserting a custom element into a shadow tree in a document created by createHTMLDocument must enqueue and invoke connectedCallback 25 PASS Inserting the shadow host of a custom element into a document created by createHTMLDocument must enqueue and invoke connectedCallback 26 PASS Inserting a custom element into a detached shadow tree that belongs to a document created by createHTMLDocument must not enqueue and invoke connectedCallback 27 PASS Inserting a custom element into a HTML document created by createDocument must enqueue and invoke connectedCallback 28 PASS Inserting an ancestor of custom element into a HTML document created by createDocument must enqueue and invoke connectedCallback 29 PASS Inserting a custom element into a shadow tree in a HTML document created by createDocument must enqueue and invoke connectedCallback 30 PASS Inserting the shadow host of a custom element into a HTML document created by createDocument must enqueue and invoke connectedCallback 31 PASS Inserting a custom element into a detached shadow tree that belongs to a HTML document created by createDocument must not enqueue and invoke connectedCallback 32 PASS Inserting a custom element into a document in an iframe must enqueue and invoke connectedCallback 33 PASS Inserting an ancestor of custom element into a document in an iframe must enqueue and invoke connectedCallback 34 PASS Inserting a custom element into a shadow tree in a document in an iframe must enqueue and invoke connectedCallback 35 PASS Inserting the shadow host of a custom element into a document in an iframe must enqueue and invoke connectedCallback 36 PASS Inserting a custom element into a detached shadow tree that belongs to a document in an iframe must not enqueue and invoke connectedCallback 37 PASS Inserting a custom element into a HTML document fetched by XHR must enqueue and invoke connectedCallback 38 PASS Inserting an ancestor of custom element into a HTML document fetched by XHR must enqueue and invoke connectedCallback 39 PASS Inserting a custom element into a shadow tree in a HTML document fetched by XHR must enqueue and invoke connectedCallback 40 PASS Inserting the shadow host of a custom element into a HTML document fetched by XHR must enqueue and invoke connectedCallback 41 PASS Inserting a custom element into a detached shadow tree that belongs to a HTML document fetched by XHR must not enqueue and invoke connectedCallback 10 42 43 -
trunk/LayoutTests/fast/custom-elements/connected-callbacks.html
r204611 r205060 8 8 <script src="../../resources/testharness.js"></script> 9 9 <script src="../../resources/testharnessreport.js"></script> 10 <script src="./resources/document-types.js"></script> 10 11 <link rel='stylesheet' href='../../resources/testharness.css'> 11 12 </head> … … 21 22 customElements.define('my-custom-element', MyCustomElement); 22 23 23 test(function () { 24 var instance = document.createElement('my-custom-element'); 24 DocumentTypes.forEach(function (entry) { 25 var documentName = entry.name; 26 var getDocument = entry.create; 25 27 26 calls = []; 27 document.body.appendChild(instance); 28 assert_array_equals(calls, ['connected', instance]); 29 }, 'Inserting a custom element into a document must enqueue and invoke connectedCallback'); 28 promise_test(function () { 29 return getDocument().then(function (doc) { 30 var instance = document.createElement('my-custom-element'); 31 calls = []; 32 doc.documentElement.appendChild(instance); 33 assert_array_equals(calls, ['connected', instance]); 34 }); 35 }, 'Inserting a custom element into a ' + documentName + ' must enqueue and invoke connectedCallback'); 30 36 31 test(function () { 32 var instance = document.createElement('my-custom-element'); 37 promise_test(function () { 38 return getDocument().then(function (doc) { 39 var instance = document.createElement('my-custom-element'); 40 var parent = document.createElement('div'); 41 parent.appendChild(instance); 42 calls = []; 43 doc.documentElement.appendChild(parent); 44 assert_array_equals(calls, ['connected', instance]); 45 }); 46 }, 'Inserting an ancestor of custom element into a ' + documentName + ' must enqueue and invoke connectedCallback'); 33 47 34 calls = []; 35 var parent = document.createElement('div'); 36 parent.appendChild(instance); 37 assert_array_equals(calls, []); 38 }, 'Inserting a custom element into a detached node must not enqueue and invoke connectedCallback'); 48 promise_test(function () { 49 return getDocument().then(function (doc) { 50 var instance = document.createElement('my-custom-element'); 51 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div'); 52 var shadowRoot = host.attachShadow({mode: 'closed'}); 53 doc.documentElement.appendChild(host); 39 54 40 test(function () { 41 var instance = document.createElement('my-custom-element'); 42 var documentWithoutWindow = document.implementation.createHTMLDocument(); 55 calls = []; 56 shadowRoot.appendChild(instance); 57 assert_array_equals(calls, ['connected', instance]); 58 }); 59 }, 'Inserting a custom element into a shadow tree in a ' + documentName + ' must enqueue and invoke connectedCallback'); 43 60 44 calls = []; 45 documentWithoutWindow.body.appendChild(instance); 46 assert_array_equals(calls, ['connected', instance]); 47 }, 'Inserting a custom element into a window-less document must enqueue and invoke connectedCallback'); 61 promise_test(function () { 62 return getDocument().then(function (doc) { 63 var instance = document.createElement('my-custom-element'); 64 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div'); 65 var shadowRoot = host.attachShadow({mode: 'closed'}); 66 shadowRoot.appendChild(instance); 48 67 49 test(function () { 50 var instance = document.createElement('my-custom-element'); 51 var parent = document.createElement('div'); 52 parent.appendChild(instance); 68 calls = []; 69 doc.documentElement.appendChild(host); 70 assert_array_equals(calls, ['connected', instance]); 71 }); 72 }, 'Inserting the shadow host of a custom element into a ' + documentName + ' must enqueue and invoke connectedCallback'); 53 73 54 calls = []; 55 document.body.appendChild(parent); 56 assert_array_equals(calls, ['connected', instance]); 57 }, 'Inserting an ancestor of a custom element into a document must enqueue and invoke connectedCallback'); 74 promise_test(function () { 75 return getDocument().then(function (doc) { 76 var instance = document.createElement('my-custom-element'); 77 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div'); 78 var shadowRoot = host.attachShadow({mode: 'closed'}); 58 79 59 test(function () { 60 var instance = document.createElement('my-custom-element'); 61 var parent = document.createElement('div'); 62 parent.appendChild(instance); 63 var documentWithoutWindow = document.implementation.createHTMLDocument(); 64 65 calls = []; 66 documentWithoutWindow.body.appendChild(parent); 67 assert_array_equals(calls, ['connected', instance]); 68 }, 'Inserting an ancestor of custom element into a window-less document must enqueue and invoke connectedCallback'); 69 70 test(function () { 71 var instance = document.createElement('my-custom-element'); 72 var host = document.createElement('div'); 73 var shadowRoot = host.attachShadow({mode: 'closed'}); 74 document.body.appendChild(host); 75 76 calls = []; 77 shadowRoot.appendChild(instance); 78 assert_array_equals(calls, ['connected', instance]); 79 }, 'Inserting a custom element into a connected shadow tree must enqueue and invoke connectedCallback'); 80 81 test(function () { 82 var instance = document.createElement('my-custom-element'); 83 var host = document.createElement('div'); 84 var shadowRoot = host.attachShadow({mode: 'closed'}); 85 shadowRoot.appendChild(instance); 86 87 calls = []; 88 document.body.appendChild(host); 89 assert_array_equals(calls, ['connected', instance]); 90 }, 'Inserting the shadow host of a shadow tree with a custom element into a document must enqueue and invoke connectedCallback'); 91 92 test(function () { 93 var instance = document.createElement('my-custom-element'); 94 var host = document.createElement('div'); 95 var shadowRoot = host.attachShadow({mode: 'closed'}); 96 97 calls = []; 98 shadowRoot.appendChild(instance); 99 assert_array_equals(calls, []); 100 }, 'Inserting a custom element into a detached shadow tree must not enqueue and invoke connectedCallback'); 80 calls = []; 81 shadowRoot.appendChild(instance); 82 assert_array_equals(calls, []); 83 }); 84 }, 'Inserting a custom element into a detached shadow tree that belongs to a ' + documentName + ' must not enqueue and invoke connectedCallback'); 85 }); 101 86 102 87 </script> -
trunk/LayoutTests/fast/custom-elements/defined-pseudo-class-expected.txt
r197952 r205060 1 1 2 PASS The defined flag of a custom element must be set if a custom element has not been upgraded yet2 PASS The defined flag of a custom element must not be set if a custom element has not been upgraded yet 3 3 PASS The defined flag of a custom element must be set when a custom element is successfully upgraded 4 4 PASS The defined flag of a custom element must be set if there is a matching definition -
trunk/LayoutTests/fast/custom-elements/defined-pseudo-class.html
r204367 r205060 17 17 test(function () { 18 18 assert_false(upgradeCandidate.matches(':defined')); 19 }, 'The defined flag of a custom element must be set if a custom element has not been upgraded yet');19 }, 'The defined flag of a custom element must not be set if a custom element has not been upgraded yet'); 20 20 21 21 var matchInsideConstructor; -
trunk/LayoutTests/fast/custom-elements/disconnected-callbacks-expected.txt
r204611 r205060 1 1 2 2 PASS Removing a custom element from a document must enqueue and invoke disconnectedCallback 3 PASS Removing a custom element from a detahed node must not enqueue and invoke connectedCallback 4 FAIL Removing a custom element from a window-less document must enqueue and invoke disconnectedCallback assert_array_equals: lengths differ, expected 2 got 0 5 PASS Removing an ancestor of a custom element from a document must enqueue and invoke disconnectedCallback 6 FAIL Removing an ancestor of custom element from a a window-less document must enqueue and invoke disconnectedCallback assert_array_equals: lengths differ, expected 2 got 0 7 PASS Removing a custom element from a connected shadow tree must enqueue and invoke disconnectedCallback 8 PASS Removing the shadow host of a shadow tree with a custom element from a document must enqueue and invoke disconnectedCallback 9 PASS Removing a custom element from a detached shadow tree must not enqueue and invoke disconnectedCallback 3 PASS Removing an ancestor of custom element from a document must enqueue and invoke disconnectedCallback 4 PASS Removing a custom element from a shadow tree in a document must enqueue and invoke disconnectedCallback 5 PASS Removing the shadow host of a custom element from adocument must enqueue and invoke disconnectedCallback 6 PASS Removing a custom element from a detached shadow tree that belongs to a document must not enqueue and invoke disconnectedCallback 7 PASS Removing a custom element from a document of a template element must enqueue and invoke disconnectedCallback 8 PASS Removing an ancestor of custom element from a document of a template element must enqueue and invoke disconnectedCallback 9 PASS Removing a custom element from a shadow tree in a document of a template element must enqueue and invoke disconnectedCallback 10 PASS Removing the shadow host of a custom element from adocument of a template element must enqueue and invoke disconnectedCallback 11 PASS Removing a custom element from a detached shadow tree that belongs to a document of a template element must not enqueue and invoke disconnectedCallback 12 PASS Removing a custom element from a new document must enqueue and invoke disconnectedCallback 13 PASS Removing an ancestor of custom element from a new document must enqueue and invoke disconnectedCallback 14 PASS Removing a custom element from a shadow tree in a new document must enqueue and invoke disconnectedCallback 15 PASS Removing the shadow host of a custom element from anew document must enqueue and invoke disconnectedCallback 16 PASS Removing a custom element from a detached shadow tree that belongs to a new document must not enqueue and invoke disconnectedCallback 17 PASS Removing a custom element from a cloned document must enqueue and invoke disconnectedCallback 18 PASS Removing an ancestor of custom element from a cloned document must enqueue and invoke disconnectedCallback 19 PASS Removing a custom element from a shadow tree in a cloned document must enqueue and invoke disconnectedCallback 20 PASS Removing the shadow host of a custom element from acloned document must enqueue and invoke disconnectedCallback 21 PASS Removing a custom element from a detached shadow tree that belongs to a cloned document must not enqueue and invoke disconnectedCallback 22 PASS Removing a custom element from a document created by createHTMLDocument must enqueue and invoke disconnectedCallback 23 PASS Removing an ancestor of custom element from a document created by createHTMLDocument must enqueue and invoke disconnectedCallback 24 PASS Removing a custom element from a shadow tree in a document created by createHTMLDocument must enqueue and invoke disconnectedCallback 25 PASS Removing the shadow host of a custom element from adocument created by createHTMLDocument must enqueue and invoke disconnectedCallback 26 PASS Removing a custom element from a detached shadow tree that belongs to a document created by createHTMLDocument must not enqueue and invoke disconnectedCallback 27 PASS Removing a custom element from a HTML document created by createDocument must enqueue and invoke disconnectedCallback 28 PASS Removing an ancestor of custom element from a HTML document created by createDocument must enqueue and invoke disconnectedCallback 29 PASS Removing a custom element from a shadow tree in a HTML document created by createDocument must enqueue and invoke disconnectedCallback 30 PASS Removing the shadow host of a custom element from aHTML document created by createDocument must enqueue and invoke disconnectedCallback 31 PASS Removing a custom element from a detached shadow tree that belongs to a HTML document created by createDocument must not enqueue and invoke disconnectedCallback 32 PASS Removing a custom element from a document in an iframe must enqueue and invoke disconnectedCallback 33 PASS Removing an ancestor of custom element from a document in an iframe must enqueue and invoke disconnectedCallback 34 PASS Removing a custom element from a shadow tree in a document in an iframe must enqueue and invoke disconnectedCallback 35 PASS Removing the shadow host of a custom element from adocument in an iframe must enqueue and invoke disconnectedCallback 36 PASS Removing a custom element from a detached shadow tree that belongs to a document in an iframe must not enqueue and invoke disconnectedCallback 37 PASS Removing a custom element from a HTML document fetched by XHR must enqueue and invoke disconnectedCallback 38 PASS Removing an ancestor of custom element from a HTML document fetched by XHR must enqueue and invoke disconnectedCallback 39 PASS Removing a custom element from a shadow tree in a HTML document fetched by XHR must enqueue and invoke disconnectedCallback 40 PASS Removing the shadow host of a custom element from aHTML document fetched by XHR must enqueue and invoke disconnectedCallback 41 PASS Removing a custom element from a detached shadow tree that belongs to a HTML document fetched by XHR must not enqueue and invoke disconnectedCallback 10 42 43 -
trunk/LayoutTests/fast/custom-elements/disconnected-callbacks.html
r204611 r205060 8 8 <script src="../../resources/testharness.js"></script> 9 9 <script src="../../resources/testharnessreport.js"></script> 10 <script src="./resources/document-types.js"></script> 10 11 <link rel='stylesheet' href='../../resources/testharness.css'> 11 12 </head> … … 21 22 customElements.define('my-custom-element', MyCustomElement); 22 23 23 test(function () {24 var instance = document.createElement('my-custom-element');25 document.body.appendChild(instance);24 DocumentTypes.forEach(function (entry) { 25 var documentName = entry.name; 26 var getDocument = entry.create; 26 27 27 calls = []; 28 document.body.removeChild(instance); 29 assert_array_equals(calls, ['disconnected', instance]); 30 }, 'Removing a custom element from a document must enqueue and invoke disconnectedCallback'); 28 promise_test(function () { 29 return getDocument().then(function (doc) { 30 var instance = document.createElement('my-custom-element'); 31 doc.documentElement.appendChild(instance); 32 calls = []; 33 doc.documentElement.removeChild(instance); 34 assert_array_equals(calls, ['disconnected', instance]); 35 }); 36 }, 'Removing a custom element from a ' + documentName + ' must enqueue and invoke disconnectedCallback'); 31 37 32 test(function () { 33 var instance = document.createElement('my-custom-element'); 34 var parent = document.createElement('div'); 35 parent.appendChild(instance); 38 promise_test(function () { 39 return getDocument().then(function (doc) { 40 var instance = document.createElement('my-custom-element'); 41 var parent = document.createElement('div'); 42 parent.appendChild(instance); 43 doc.documentElement.appendChild(parent); 44 calls = []; 45 doc.documentElement.removeChild(parent); 46 assert_array_equals(calls, ['disconnected', instance]); 47 }); 48 }, 'Removing an ancestor of custom element from a ' + documentName + ' must enqueue and invoke disconnectedCallback'); 36 49 37 calls = []; 38 parent.removeChild(instance); 39 assert_array_equals(calls, []); 40 }, 'Removing a custom element from a detahed node must not enqueue and invoke connectedCallback'); 50 promise_test(function () { 51 return getDocument().then(function (doc) { 52 var instance = document.createElement('my-custom-element'); 53 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div'); 54 var shadowRoot = host.attachShadow({mode: 'closed'}); 55 doc.documentElement.appendChild(host); 56 shadowRoot.appendChild(instance); 41 57 42 test(function () { 43 var instance = document.createElement('my-custom-element'); 44 var documentWithoutWindow = document.implementation.createHTMLDocument(); 45 documentWithoutWindow.body.appendChild(instance); 58 calls = []; 59 shadowRoot.removeChild(instance); 60 assert_array_equals(calls, ['disconnected', instance]); 61 }); 62 }, 'Removing a custom element from a shadow tree in a ' + documentName + ' must enqueue and invoke disconnectedCallback'); 46 63 47 calls = []; 48 documentWithoutWindow.body.removeChild(instance); 49 assert_array_equals(calls, ['disconnected', instance]); 50 }, 'Removing a custom element from a window-less document must enqueue and invoke disconnectedCallback'); 64 promise_test(function () { 65 return getDocument().then(function (doc) { 66 var instance = document.createElement('my-custom-element'); 67 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div'); 68 var shadowRoot = host.attachShadow({mode: 'closed'}); 69 shadowRoot.appendChild(instance); 70 doc.documentElement.appendChild(host); 51 71 52 test(function () { 53 var instance = document.createElement('my-custom-element');54 var parent = document.createElement('div');55 parent.appendChild(instance);56 document.body.appendChild(parent);72 calls = []; 73 doc.documentElement.removeChild(host); 74 assert_array_equals(calls, ['disconnected', instance]); 75 }); 76 }, 'Removing the shadow host of a custom element from a' + documentName + ' must enqueue and invoke disconnectedCallback'); 57 77 58 calls = []; 59 document.body.removeChild(parent); 60 assert_array_equals(calls, ['disconnected', instance]); 61 }, 'Removing an ancestor of a custom element from a document must enqueue and invoke disconnectedCallback'); 78 promise_test(function () { 79 return getDocument().then(function (doc) { 80 var instance = document.createElement('my-custom-element'); 81 var host = doc.createElementNS('http://www.w3.org/1999/xhtml', 'div'); 82 var shadowRoot = host.attachShadow({mode: 'closed'}); 83 shadowRoot.appendChild(instance); 62 84 63 test(function () { 64 var instance = document.createElement('my-custom-element'); 65 var parent = document.createElement('div'); 66 parent.appendChild(instance); 67 var documentWithoutWindow = document.implementation.createHTMLDocument(); 68 documentWithoutWindow.body.appendChild(parent); 69 70 calls = []; 71 documentWithoutWindow.body.removeChild(parent); 72 assert_array_equals(calls, ['disconnected', instance]); 73 }, 'Removing an ancestor of custom element from a a window-less document must enqueue and invoke disconnectedCallback'); 74 75 test(function () { 76 var instance = document.createElement('my-custom-element'); 77 var host = document.createElement('div'); 78 document.body.appendChild(host); 79 var shadowRoot = host.attachShadow({mode: 'closed'}); 80 shadowRoot.appendChild(instance); 81 82 calls = []; 83 shadowRoot.removeChild(instance); 84 assert_array_equals(calls, ['disconnected', instance]); 85 }, 'Removing a custom element from a connected shadow tree must enqueue and invoke disconnectedCallback'); 86 87 test(function () { 88 var instance = document.createElement('my-custom-element'); 89 var host = document.createElement('div'); 90 var shadowRoot = host.attachShadow({mode: 'closed'}); 91 shadowRoot.appendChild(instance); 92 document.body.appendChild(host); 93 94 calls = []; 95 document.body.removeChild(host); 96 assert_array_equals(calls, ['disconnected', instance]); 97 }, 'Removing the shadow host of a shadow tree with a custom element from a document must enqueue and invoke disconnectedCallback'); 98 99 test(function () { 100 var instance = document.createElement('my-custom-element'); 101 var host = document.createElement('div'); 102 var shadowRoot = host.attachShadow({mode: 'closed'}); 103 shadowRoot.appendChild(instance); 104 105 calls = []; 106 shadowRoot.removeChild(instance); 107 assert_array_equals(calls, []); 108 }, 'Removing a custom element from a detached shadow tree must not enqueue and invoke disconnectedCallback'); 109 85 calls = []; 86 shadowRoot.removeChild(instance); 87 assert_array_equals(calls, []); 88 }); 89 }, 'Removing a custom element from a detached shadow tree that belongs to a ' + documentName + ' must not enqueue and invoke disconnectedCallback'); 90 }); 110 91 111 92 </script> -
trunk/Source/WebCore/ChangeLog
r205056 r205060 1 2016-08-23 Ryosuke Niwa <rniwa@webkit.org> 2 3 Adopted custom element's callbacks should continue to work 4 https://bugs.webkit.org/show_bug.cgi?id=161065 5 6 Reviewed by Andreas Kling. 7 8 When a custom element is adopted into another document, its reaction callbacks need to continue to work. 9 Because a different document may have its own global object, each custom element needs to remember its 10 original global object or JSCustomElementInterface. This patch adds the latter to the element rare data. 11 12 Tests: fast/custom-elements/connected-callbacks.html 13 fast/custom-elements/disconnected-callbacks.html 14 15 * bindings/js/JSCustomElementInterface.cpp: 16 (WebCore::JSCustomElementInterface::constructElement): 17 (WebCore::JSCustomElementInterface::upgradeElement): 18 * dom/CustomElementReactionQueue.cpp: 19 (WebCore::findInterfaceForCustomElement): Deleted. 20 (WebCore::CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded): 21 (WebCore::CustomElementReactionQueue::enqueueDisconnectedCallbackIfNeeded): 22 (WebCore::CustomElementReactionQueue::enqueueAttributeChangedCallbackIfNeeded): 23 * dom/Element.cpp: 24 (WebCore::Element::insertedInto): Invoke callbacks even when the current document is not a HTML document. 25 (WebCore::Element::removedFrom): Ditto. 26 (WebCore::Element::setCustomElementIsResolved): Moved from Node. Add the element interface to the rare data. 27 (WebCore::Element::customElementInterface): Added. 28 * dom/Element.h: 29 * dom/ElementRareData.cpp: 30 * dom/ElementRareData.h: 31 (WebCore::ElementRareData::customElementInterface): Added. 32 (WebCore::ElementRareData::setCustomElementInterface): Added. 33 * dom/Node.h: 34 ((WebCore::Node::setCustomElementIsResolved): Deleted. 35 1 36 2016-08-26 Zalan Bujtas <zalan@apple.com> 2 37 -
trunk/Source/WebCore/bindings/js/JSCustomElementInterface.cpp
r204619 r205060 99 99 if (!wrappedElement) 100 100 return nullptr; 101 wrappedElement->setCustomElementIsResolved( );101 wrappedElement->setCustomElementIsResolved(*this); 102 102 return wrappedElement; 103 103 } … … 148 148 return; 149 149 } 150 wrappedElement->setCustomElementIsResolved(); 151 ASSERT(wrappedElement->isCustomElement()); 150 wrappedElement->setCustomElementIsResolved(*this); 152 151 } 153 152 -
trunk/Source/WebCore/dom/CustomElementReactionQueue.cpp
r204732 r205060 107 107 } 108 108 109 static JSCustomElementInterface* findInterfaceForCustomElement(Element& element)110 {111 ASSERT(element.isCustomElement());112 auto* window = element.document().domWindow();113 if (!window)114 return nullptr;115 116 auto* registry = window->customElementRegistry();117 if (!registry)118 return nullptr;119 120 return registry->findInterface(element.tagQName());121 }122 123 109 void CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded(Element& element) 124 110 { 125 auto* elementInterface = findInterfaceForCustomElement(element);111 auto* elementInterface = element.customElementInterface(); 126 112 if (!elementInterface) 127 113 return; … … 133 119 void CustomElementReactionQueue::enqueueDisconnectedCallbackIfNeeded(Element& element) 134 120 { 135 auto* elementInterface = findInterfaceForCustomElement(element);121 auto* elementInterface = element.customElementInterface(); 136 122 if (!elementInterface) 137 123 return; … … 143 129 void CustomElementReactionQueue::enqueueAttributeChangedCallbackIfNeeded(Element& element, const QualifiedName& attributeName, const AtomicString& oldValue, const AtomicString& newValue) 144 130 { 145 auto* elementInterface = findInterfaceForCustomElement(element);131 auto* elementInterface = element.customElementInterface(); 146 132 if (!elementInterface || !elementInterface->observesAttribute(attributeName.localName())) 147 133 return; -
trunk/Source/WebCore/dom/Element.cpp
r204732 r205060 1575 1575 // or its ancestor is inserted belongs to the same tree scope as this element's. 1576 1576 TreeScope* newScope = &insertionPoint.treeScope(); 1577 HTMLDocument* newDocument = !wasInDocument && inDocument() && is<HTMLDocument>(newScope->documentScope()) ? &downcast<HTMLDocument>(newScope->documentScope()) : nullptr; 1577 bool becomeConnected = !wasInDocument && inDocument(); 1578 HTMLDocument* newDocument = becomeConnected && is<HTMLDocument>(newScope->documentScope()) ? &downcast<HTMLDocument>(newScope->documentScope()) : nullptr; 1578 1579 if (newScope != &treeScope()) 1579 1580 newScope = nullptr; … … 1601 1602 1602 1603 #if ENABLE(CUSTOM_ELEMENTS) 1603 if ( newDocument&& UNLIKELY(isCustomElement()))1604 if (becomeConnected && UNLIKELY(isCustomElement())) 1604 1605 CustomElementReactionQueue::enqueueConnectedCallbackIfNeeded(*this); 1605 1606 #endif … … 1623 1624 if (insertionPoint.isInTreeScope()) { 1624 1625 TreeScope* oldScope = &insertionPoint.treeScope(); 1625 HTMLDocument* oldDocument = inDocument() && is<HTMLDocument>(oldScope->documentScope()) ? &downcast<HTMLDocument>(oldScope->documentScope()) : nullptr; 1626 bool becomeDisconnected = inDocument(); 1627 HTMLDocument* oldDocument = becomeDisconnected && is<HTMLDocument>(oldScope->documentScope()) ? &downcast<HTMLDocument>(oldScope->documentScope()) : nullptr; 1626 1628 1627 1629 // ContainerNode::removeBetween always sets the removed chid's tree scope to Document's but InTreeScope flag is unset in Node::removedFrom. … … 1652 1654 1653 1655 #if ENABLE(CUSTOM_ELEMENTS) 1654 if ( oldDocument&& UNLIKELY(isCustomElement()))1656 if (becomeDisconnected && UNLIKELY(isCustomElement())) 1655 1657 CustomElementReactionQueue::enqueueDisconnectedCallbackIfNeeded(*this); 1656 1658 #endif … … 1821 1823 return *shadowRoot; 1822 1824 } 1825 1826 1827 #if ENABLE(CUSTOM_ELEMENTS) 1828 1829 void Element::setCustomElementIsResolved(JSCustomElementInterface& elementInterface) 1830 { 1831 clearFlag(IsEditingTextOrUnresolvedCustomElementFlag); 1832 setFlag(IsCustomElement); 1833 ensureElementRareData().setCustomElementInterface(elementInterface); 1834 } 1835 1836 JSCustomElementInterface* Element::customElementInterface() const 1837 { 1838 ASSERT(isCustomElement()); 1839 if (!hasRareData()) 1840 return nullptr; 1841 return elementRareData()->customElementInterface(); 1842 } 1843 1844 #endif 1845 1823 1846 1824 1847 const AtomicString& Element::shadowPseudoId() const -
trunk/Source/WebCore/dom/Element.h
r204717 r205060 45 45 class HTMLDocument; 46 46 class IntSize; 47 class JSCustomElementInterface; 47 48 class KeyboardEvent; 48 49 class Locale; … … 272 273 ShadowRoot* userAgentShadowRoot() const; 273 274 WEBCORE_EXPORT ShadowRoot& ensureUserAgentShadowRoot(); 275 276 #if ENABLE(CUSTOM_ELEMENTS) 277 void setCustomElementIsResolved(JSCustomElementInterface&); 278 JSCustomElementInterface* customElementInterface() const; 279 #endif 274 280 275 281 // FIXME: this should not be virtual, do not override this. -
trunk/Source/WebCore/dom/ElementRareData.cpp
r197777 r205060 45 45 LayoutSize sizeForResizing; 46 46 IntPoint savedLayerScrollPosition; 47 #if ENABLE(CUSTOM_ELEMENTS) 48 void* pointers[8]; 49 #else 47 50 void* pointers[7]; 51 #endif 48 52 }; 49 53 -
trunk/Source/WebCore/dom/ElementRareData.h
r202607 r205060 25 25 #include "DOMTokenList.h" 26 26 #include "DatasetDOMStringMap.h" 27 #include "JSCustomElementInterface.h" 27 28 #include "NamedNodeMap.h" 28 29 #include "NodeRareData.h" … … 93 94 ShadowRoot* shadowRoot() const { return m_shadowRoot.get(); } 94 95 void setShadowRoot(RefPtr<ShadowRoot>&& shadowRoot) { m_shadowRoot = WTFMove(shadowRoot); } 96 97 #if ENABLE(CUSTOM_ELEMENTS) 98 JSCustomElementInterface* customElementInterface() { return m_customElementInterface.get(); } 99 void setCustomElementInterface(JSCustomElementInterface& customElementInterface) { m_customElementInterface = &customElementInterface; } 100 #endif 95 101 96 102 NamedNodeMap* attributeMap() const { return m_attributeMap.get(); } … … 150 156 std::unique_ptr<DOMTokenList> m_classList; 151 157 RefPtr<ShadowRoot> m_shadowRoot; 158 #if ENABLE(CUSTOM_ELEMENTS) 159 RefPtr<JSCustomElementInterface> m_customElementInterface; 160 #endif 152 161 std::unique_ptr<NamedNodeMap> m_attributeMap; 153 162 -
trunk/Source/WebCore/dom/Node.h
r204717 r205060 268 268 bool isUnresolvedCustomElement() const { return isElementNode() && getFlag(IsEditingTextOrUnresolvedCustomElementFlag); } 269 269 void setIsUnresolvedCustomElement() { setFlag(IsEditingTextOrUnresolvedCustomElementFlag); } 270 void setCustomElementIsResolved();271 270 #endif 272 271 … … 770 769 } 771 770 772 #if ENABLE(CUSTOM_ELEMENTS)773 774 inline void Node::setCustomElementIsResolved()775 {776 clearFlag(IsEditingTextOrUnresolvedCustomElementFlag);777 setFlag(IsCustomElement);778 }779 780 #endif781 782 771 } // namespace WebCore 783 772
Note: See TracChangeset
for help on using the changeset viewer.