From 9ecb931c5e1f17ea1db880fc61ce39fbb44fe94d Mon Sep 17 00:00:00 2001 From: Connor Brewster Date: Tue, 18 Jul 2017 10:06:10 -0600 Subject: [PATCH] Fix adopted and connected callback reactions --- components/script/dom/node.rs | 25 +++++++---- .../custom-elements/adopted-callback.html.ini | 42 ------------------- .../connected-callbacks.html.ini | 24 ----------- .../custom-element-reaction-queue.html.ini | 3 -- .../reactions/Document.html.ini | 3 -- .../reactions/HTMLOptionsCollection.html.ini | 8 ---- .../custom-elements/reactions/Range.html.ini | 3 -- 7 files changed, 16 insertions(+), 92 deletions(-) delete mode 100644 tests/wpt/metadata/custom-elements/reactions/HTMLOptionsCollection.html.ini diff --git a/components/script/dom/node.rs b/components/script/dom/node.rs index 1c25567cb2d9..94ab6f18dc87 100644 --- a/components/script/dom/node.rs +++ b/components/script/dom/node.rs @@ -1422,13 +1422,12 @@ impl Node { for descendant in node.traverse_preorder() { descendant.set_owner_doc(document); } - for descendant in node.traverse_preorder() { + for descendant in node.traverse_preorder().filter_map(|d| d.as_custom_element()) { // Step 3.2. - if let Some(element) = node.as_custom_element() { - ScriptThread::enqueue_callback_reaction(&*element, - CallbackReaction::Adopted(old_doc.clone(), Root::from_ref(document))); - } - + ScriptThread::enqueue_callback_reaction(&*descendant, + CallbackReaction::Adopted(old_doc.clone(), Root::from_ref(document))); + } + for descendant in node.traverse_preorder() { // Step 3.3. vtable_for(&descendant).adopting_steps(&old_doc); } @@ -1636,9 +1635,17 @@ impl Node { for kid in new_nodes { // Step 7.1. parent.add_child(*kid, child); - // Step 7.2: insertion steps. - if let Some(element) = kid.as_custom_element() { - ScriptThread::enqueue_callback_reaction(&*element, CallbackReaction::Connected); + // Step 7.7. + for descendant in kid.traverse_preorder().filter_map(Root::downcast::) { + // Step 7.7.2. + if descendant.is_connected() { + // Step 7.7.2.1. + if descendant.get_custom_element_definition().is_some() { + ScriptThread::enqueue_callback_reaction(&*descendant, CallbackReaction::Connected); + } + // TODO: Step 7.7.2.2. + // Try to upgrade descendant. + } } } if let SuppressObserver::Unsuppressed = suppress_observers { diff --git a/tests/wpt/metadata/custom-elements/adopted-callback.html.ini b/tests/wpt/metadata/custom-elements/adopted-callback.html.ini index 264f98e82dec..e35f704acf07 100644 --- a/tests/wpt/metadata/custom-elements/adopted-callback.html.ini +++ b/tests/wpt/metadata/custom-elements/adopted-callback.html.ini @@ -1,11 +1,5 @@ [adopted-callback.html] type: testharness - [Inserting an ancestor of custom element into the document of the template elements must enqueue and invoke adoptedCallback] - expected: FAIL - - [Moving an ancestor of custom element from the owner document into the document of the template elements must enqueue and invoke adoptedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in the document of the template elements must enqueue and invoke adoptedCallback] expected: FAIL @@ -18,12 +12,6 @@ [Inserting a custom element into a detached shadow tree that belongs to the document of the template elements must enqueue and invoke adoptedCallback] expected: FAIL - [Inserting an ancestor of custom element into a new document must enqueue and invoke adoptedCallback] - expected: FAIL - - [Moving an ancestor of custom element from the owner document into a new document must enqueue and invoke adoptedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in a new document must enqueue and invoke adoptedCallback] expected: FAIL @@ -36,12 +24,6 @@ [Inserting a custom element into a detached shadow tree that belongs to a new document must enqueue and invoke adoptedCallback] expected: FAIL - [Inserting an ancestor of custom element into a cloned document must enqueue and invoke adoptedCallback] - expected: FAIL - - [Moving an ancestor of custom element from the owner document into a cloned document must enqueue and invoke adoptedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in a cloned document must enqueue and invoke adoptedCallback] expected: FAIL @@ -54,12 +36,6 @@ [Inserting a custom element into a detached shadow tree that belongs to a cloned document must enqueue and invoke adoptedCallback] expected: FAIL - [Inserting an ancestor of custom element into a document created by createHTMLDocument must enqueue and invoke adoptedCallback] - expected: FAIL - - [Moving an ancestor of custom element from the owner document into a document created by createHTMLDocument must enqueue and invoke adoptedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in a document created by createHTMLDocument must enqueue and invoke adoptedCallback] expected: FAIL @@ -72,12 +48,6 @@ [Inserting a custom element into a detached shadow tree that belongs to a document created by createHTMLDocument must enqueue and invoke adoptedCallback] expected: FAIL - [Inserting an ancestor of custom element into an HTML document created by createDocument must enqueue and invoke adoptedCallback] - expected: FAIL - - [Moving an ancestor of custom element from the owner document into an HTML document created by createDocument must enqueue and invoke adoptedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in an HTML document created by createDocument must enqueue and invoke adoptedCallback] expected: FAIL @@ -90,12 +60,6 @@ [Inserting a custom element into a detached shadow tree that belongs to an HTML document created by createDocument must enqueue and invoke adoptedCallback] expected: FAIL - [Inserting an ancestor of custom element into the document of an iframe must enqueue and invoke adoptedCallback] - expected: FAIL - - [Moving an ancestor of custom element from the owner document into the document of an iframe must enqueue and invoke adoptedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in the document of an iframe must enqueue and invoke adoptedCallback] expected: FAIL @@ -108,12 +72,6 @@ [Inserting a custom element into a detached shadow tree that belongs to the document of an iframe must enqueue and invoke adoptedCallback] expected: FAIL - [Inserting an ancestor of custom element into an HTML document fetched by XHR must enqueue and invoke adoptedCallback] - expected: FAIL - - [Moving an ancestor of custom element from the owner document into an HTML document fetched by XHR must enqueue and invoke adoptedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in an HTML document fetched by XHR must enqueue and invoke adoptedCallback] expected: FAIL diff --git a/tests/wpt/metadata/custom-elements/connected-callbacks.html.ini b/tests/wpt/metadata/custom-elements/connected-callbacks.html.ini index 7832c3612582..c8a99d69594f 100644 --- a/tests/wpt/metadata/custom-elements/connected-callbacks.html.ini +++ b/tests/wpt/metadata/custom-elements/connected-callbacks.html.ini @@ -1,8 +1,5 @@ [connected-callbacks.html] type: testharness - [Inserting an ancestor of custom element into the document must enqueue and invoke connectedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in the document must enqueue and invoke connectedCallback] expected: FAIL @@ -12,9 +9,6 @@ [Inserting a custom element into a detached shadow tree that belongs to the document must not enqueue and invoke connectedCallback] expected: FAIL - [Inserting an ancestor of custom element into the document of the template elements must enqueue and invoke connectedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in the document of the template elements must enqueue and invoke connectedCallback] expected: FAIL @@ -24,9 +18,6 @@ [Inserting a custom element into a detached shadow tree that belongs to the document of the template elements must not enqueue and invoke connectedCallback] expected: FAIL - [Inserting an ancestor of custom element into a new document must enqueue and invoke connectedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in a new document must enqueue and invoke connectedCallback] expected: FAIL @@ -36,9 +27,6 @@ [Inserting a custom element into a detached shadow tree that belongs to a new document must not enqueue and invoke connectedCallback] expected: FAIL - [Inserting an ancestor of custom element into a cloned document must enqueue and invoke connectedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in a cloned document must enqueue and invoke connectedCallback] expected: FAIL @@ -48,9 +36,6 @@ [Inserting a custom element into a detached shadow tree that belongs to a cloned document must not enqueue and invoke connectedCallback] expected: FAIL - [Inserting an ancestor of custom element into a document created by createHTMLDocument must enqueue and invoke connectedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in a document created by createHTMLDocument must enqueue and invoke connectedCallback] expected: FAIL @@ -60,9 +45,6 @@ [Inserting a custom element into a detached shadow tree that belongs to a document created by createHTMLDocument must not enqueue and invoke connectedCallback] expected: FAIL - [Inserting an ancestor of custom element into an HTML document created by createDocument must enqueue and invoke connectedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in an HTML document created by createDocument must enqueue and invoke connectedCallback] expected: FAIL @@ -72,9 +54,6 @@ [Inserting a custom element into a detached shadow tree that belongs to an HTML document created by createDocument must not enqueue and invoke connectedCallback] expected: FAIL - [Inserting an ancestor of custom element into the document of an iframe must enqueue and invoke connectedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in the document of an iframe must enqueue and invoke connectedCallback] expected: FAIL @@ -84,9 +63,6 @@ [Inserting a custom element into a detached shadow tree that belongs to the document of an iframe must not enqueue and invoke connectedCallback] expected: FAIL - [Inserting an ancestor of custom element into an HTML document fetched by XHR must enqueue and invoke connectedCallback] - expected: FAIL - [Inserting a custom element into a shadow tree in an HTML document fetched by XHR must enqueue and invoke connectedCallback] expected: FAIL diff --git a/tests/wpt/metadata/custom-elements/custom-element-reaction-queue.html.ini b/tests/wpt/metadata/custom-elements/custom-element-reaction-queue.html.ini index c4add79aa306..b36672713c36 100644 --- a/tests/wpt/metadata/custom-elements/custom-element-reaction-queue.html.ini +++ b/tests/wpt/metadata/custom-elements/custom-element-reaction-queue.html.ini @@ -6,6 +6,3 @@ [Mutating a undefined custom element while upgrading a custom element must not enqueue or invoke reactions on the mutated element] expected: FAIL - [Mutating another custom element inside adopted callback must invoke all pending callbacks on the mutated element] - expected: FAIL - diff --git a/tests/wpt/metadata/custom-elements/reactions/Document.html.ini b/tests/wpt/metadata/custom-elements/reactions/Document.html.ini index c2973361a0ac..c9319bdc3305 100644 --- a/tests/wpt/metadata/custom-elements/reactions/Document.html.ini +++ b/tests/wpt/metadata/custom-elements/reactions/Document.html.ini @@ -9,9 +9,6 @@ [body on Document must enqueue disconnectedCallback when removing a custom element] expected: FAIL - [body on Document must enqueue connectedCallback when inserting a custom element] - expected: FAIL - [open on Document must enqueue disconnectedCallback when removing a custom element] expected: FAIL diff --git a/tests/wpt/metadata/custom-elements/reactions/HTMLOptionsCollection.html.ini b/tests/wpt/metadata/custom-elements/reactions/HTMLOptionsCollection.html.ini deleted file mode 100644 index 88525dabcb32..000000000000 --- a/tests/wpt/metadata/custom-elements/reactions/HTMLOptionsCollection.html.ini +++ /dev/null @@ -1,8 +0,0 @@ -[HTMLOptionsCollection.html] - type: testharness - [The indexed setter on HTMLOptionsCollection must enqueue connectedCallback when inserting a custom element] - expected: FAIL - - [add on HTMLOptionsCollection must enqueue connectedCallback when inserting a custom element] - expected: FAIL - diff --git a/tests/wpt/metadata/custom-elements/reactions/Range.html.ini b/tests/wpt/metadata/custom-elements/reactions/Range.html.ini index 662e10a7c436..678971e6eaff 100644 --- a/tests/wpt/metadata/custom-elements/reactions/Range.html.ini +++ b/tests/wpt/metadata/custom-elements/reactions/Range.html.ini @@ -1,8 +1,5 @@ [Range.html] type: testharness - [extractContents on Range must enqueue a disconnected reaction] - expected: FAIL - [cloneContents on Range must enqueue an attributeChanged reaction when cloning an element with an observed attribute] expected: FAIL