OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <title>Custom Elements: CEReactions on Node interface</title> | 4 <title>Custom Elements: CEReactions on Node interface</title> |
5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> | 5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org"> |
6 <meta name="assert" content="nodeValue, textContent, normalize, cloneNode, inser
tBefore, appendChild, replaceChild, and removeChild of Node interface must have
CEReactions"> | 6 <meta name="assert" content="nodeValue, textContent, normalize, cloneNode, inser
tBefore, appendChild, replaceChild, and removeChild of Node interface must have
CEReactions"> |
7 <meta name="help" content="https://dom.spec.whatwg.org/#node"> | 7 <meta name="help" content="https://dom.spec.whatwg.org/#node"> |
8 <script src="/resources/testharness.js"></script> | 8 <script src="/resources/testharness.js"></script> |
9 <script src="/resources/testharnessreport.js"></script> | 9 <script src="/resources/testharnessreport.js"></script> |
| 10 <script src="../resources/custom-elements-helpers.js"></script> |
10 <script src="./resources/reactions.js"></script> | 11 <script src="./resources/reactions.js"></script> |
11 </head> | 12 </head> |
12 <body> | 13 <body> |
13 <div id="log"></div> | 14 <div id="log"></div> |
14 <script> | 15 <script> |
15 | 16 |
16 testAttributeMutator(function (element, name, value) { | 17 testAttributeMutator(function (element, name, value) { |
17 element.getAttributeNode(name).nodeValue = value; | 18 element.getAttributeNode(name).nodeValue = value; |
18 }, 'nodeValue on Node'); | 19 }, 'nodeValue on Node'); |
19 | 20 |
20 testAttributeMutator(function (element, name, value) { | 21 testAttributeMutator(function (element, name, value) { |
21 element.getAttributeNode(name).textContent = value; | 22 element.getAttributeNode(name).textContent = value; |
22 }, 'textContent on Node'); | 23 }, 'textContent on Node'); |
23 | 24 |
24 // FIXME: Add a test for normalize() | 25 // FIXME: Add a test for normalize() |
25 | 26 |
26 test(function () { | 27 testCloner(function (customElement) { |
27 var element = defineNewCustomElement(); | 28 return customElement.cloneNode(false); |
28 var instance = document.createElement(element.name); | 29 }, 'cloneNode on Node'); |
29 instance.setAttribute('id', 'foo'); | |
30 assert_array_equals(element.log().types(), ['constructed', 'attributeChanged
']); | |
31 var newInstance = instance.cloneNode(false); | |
32 var logEntries = element.log(); | |
33 assert_array_equals(logEntries.types(), ['constructed', 'attributeChanged'])
; | |
34 assert_equals(logEntries.log().name, 'id'); | |
35 assert_equals(logEntries.log().oldValue, null); | |
36 assert_equals(logEntries.log().newValue, 'foo'); | |
37 }, 'cloneNode on Node must enqueue a attributeChanged reaction when cloning an e
lement with an attribute'); | |
38 | |
39 test(function () { | |
40 var element = defineNewCustomElement(); | |
41 var instance = document.createElement(element.name); | |
42 instance.setAttribute('lang', 'en'); | |
43 assert_array_equals(element.log().types(), ['constructed']); | |
44 var newInstance = instance.cloneNode(false); | |
45 assert_array_equals(element.log().types(), ['constructed']); | |
46 }, 'cloneNode on Node must not enqueue a attributeChanged reaction when cloning
an element with an attribute'); | |
47 | |
48 | 30 |
49 testNodeConnector(function (newContainer, customElement) { | 31 testNodeConnector(function (newContainer, customElement) { |
50 newContainer.insertBefore(customElement, newContainer.firstChild); | 32 newContainer.insertBefore(customElement, newContainer.firstChild); |
51 }, 'insertBefore on ChildNode'); | 33 }, 'insertBefore on ChildNode'); |
52 | 34 |
53 testNodeConnector(function (newContainer, customElement) { | 35 testNodeConnector(function (newContainer, customElement) { |
54 newContainer.appendChild(customElement); | 36 newContainer.appendChild(customElement); |
55 }, 'appendChild on ChildNode'); | 37 }, 'appendChild on ChildNode'); |
56 | 38 |
57 testNodeConnector(function (newContainer, customElement) { | 39 testNodeConnector(function (newContainer, customElement) { |
58 newContainer.replaceChild(customElement, newContainer.firstChild); | 40 newContainer.replaceChild(customElement, newContainer.firstChild); |
59 }, 'replaceChild on ChildNode'); | 41 }, 'replaceChild on ChildNode'); |
60 | 42 |
61 testNodeDisconnector(function (customElement) { | 43 testNodeDisconnector(function (customElement) { |
62 customElement.parentNode.removeChild(customElement); | 44 customElement.parentNode.removeChild(customElement); |
63 }, 'removeChild on ChildNode'); | 45 }, 'removeChild on ChildNode'); |
64 | 46 |
65 </script> | 47 </script> |
66 </body> | 48 </body> |
67 </html> | 49 </html> |
OLD | NEW |