Skip to content

Commit

Permalink
Fix adopted and connected callback reactions
Browse files Browse the repository at this point in the history
  • Loading branch information
cbrewster committed Jul 18, 2017
1 parent 77efab8 commit 9ecb931
Show file tree
Hide file tree
Showing 7 changed files with 16 additions and 92 deletions.
25 changes: 16 additions & 9 deletions components/script/dom/node.rs
Expand Up @@ -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);
}
Expand Down Expand Up @@ -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::<Element>) {
// 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 {
Expand Down
42 changes: 0 additions & 42 deletions 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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
24 changes: 0 additions & 24 deletions 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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand All @@ -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

Expand Down
Expand Up @@ -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

Expand Up @@ -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

Expand Down

This file was deleted.

3 changes: 0 additions & 3 deletions 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

Expand Down

0 comments on commit 9ecb931

Please sign in to comment.