| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <title>Custom Elements: adopt node</title> | 2 <title>Custom Elements: adopt node</title> |
| 3 <link rel="help" href="https://dom.spec.whatwg.org/#concept-node-adopt"> | 3 <link rel="help" href="https://dom.spec.whatwg.org/#concept-node-adopt"> |
| 4 <script src="../../resources/testharness.js"></script> | 4 <script src="../../resources/testharness.js"></script> |
| 5 <script src="../../resources/testharnessreport.js"></script> | 5 <script src="../../resources/testharnessreport.js"></script> |
| 6 <script src="resources/custom-elements-helpers.js"></script> | 6 <script src="resources/custom-elements-helpers.js"></script> |
| 7 <body> | 7 <body> |
| 8 <script> | 8 <script> |
| 9 'use strict' | 9 'use strict' |
| 10 | 10 |
| 11 // 3.2 For each inclusiveDescendant in node’s shadow-including inclusive descend
ants that is a custom | 11 // 3.2 For each inclusiveDescendant in node’s shadow-including inclusive descend
ants that is a custom |
| 12 // element, enqueue a custom element callback reaction with inclusiveDescendant, | 12 // element, enqueue a custom element callback reaction with inclusiveDescendant, |
| 13 // callback name "adoptedCallback", and an empty argument list. | 13 // callback name "adoptedCallback", and an empty argument list. |
| 14 promise_test((t) => { | 14 promise_test((t) => { |
| 15 return Promise.all([ | 15 return Promise.all([ |
| 16 create_window_in_test(t), | 16 create_window_in_test(t), |
| 17 create_window_in_test(t)]) | 17 create_window_in_test(t)]) |
| 18 .then(([w1, w2]) => { | 18 .then(([w1, w2]) => { |
| 19 let invocations = []; | 19 let invocations = []; |
| 20 class X extends w1.HTMLElement { | 20 class X extends w1.HTMLElement { |
| 21 adoptedCallback() { invocations.push(['adopted', this, []]); } | 21 adoptedCallback() { invocations.push(['adopted', this, []]); } |
| 22 } | 22 } |
| 23 w1.customElements.define('a-a', X); | 23 w1.customElements.define('a-a', X); |
| 24 let a = w1.document.createElement('a-a'); | 24 let a = w1.document.createElement('a-a'); |
| 25 w2.document.adoptNode(a); | 25 w2.document.adoptNode(a); |
| 26 assert_array_equals_callback_invocations(invocations, [ ['adopted', a, []]
]); | 26 assert_array_equals_callback_invocations(invocations, [ ['adopted', a, []]
]); |
| 27 }); | 27 }); |
| 28 }, 'adopting a custom element to the different document should enqueue an adopte
dCallback reaction'); | 28 }, 'adopting a custom element to the different document should enqueue an adopte
dCallback reaction'); |
| 29 |
| 30 // 3.3 For each inclusiveDescendant in node’s shadow-including inclusive descend
ants, in |
| 31 // shadow-including tree order, run the adopting steps with inclusiveDescendant
and oldDocument. |
| 32 promise_test((t) => { |
| 33 return Promise.all([ |
| 34 create_window_in_test(t), |
| 35 create_window_in_test(t)]) |
| 36 .then(([w1, w2]) => { |
| 37 w1.document.body.innerHTML = ` |
| 38 <a-a id="a"> |
| 39 <p> |
| 40 <a-a id="b"></a-a> |
| 41 <a-a id="c"></a-a> |
| 42 </p> |
| 43 <a-a id="d"></a-a> |
| 44 </a-a>`; |
| 45 let invocations = []; |
| 46 class X extends w1.HTMLElement { |
| 47 adoptedCallback() { invocations.push(this); } |
| 48 } |
| 49 w1.customElements.define('a-a', X); |
| 50 let a = w1.document.getElementById("a"); |
| 51 w2.document.adoptNode(a); |
| 52 assert_array_equals(['a', 'b', 'c', 'd'], invocations.map((e) => e.id), |
| 53 'four elements should have been removed in doc order'); |
| 54 }); |
| 55 }, 'shadow-including inclusive descendants should be adopted in shadow-including
tree order'); |
| 29 </script> | 56 </script> |
| 30 </body> | 57 </body> |
| OLD | NEW |