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> | |
11 <script src="./resources/reactions.js"></script> | 10 <script src="./resources/reactions.js"></script> |
12 </head> | 11 </head> |
13 <body> | 12 <body> |
14 <div id="log"></div> | 13 <div id="log"></div> |
15 <script> | 14 <script> |
16 | 15 |
17 testAttributeMutator(function (element, name, value) { | 16 testAttributeMutator(function (element, name, value) { |
18 element.getAttributeNode(name).nodeValue = value; | 17 element.getAttributeNode(name).nodeValue = value; |
19 }, 'nodeValue on Node'); | 18 }, 'nodeValue on Node'); |
20 | 19 |
21 testAttributeMutator(function (element, name, value) { | 20 testAttributeMutator(function (element, name, value) { |
22 element.getAttributeNode(name).textContent = value; | 21 element.getAttributeNode(name).textContent = value; |
23 }, 'textContent on Node'); | 22 }, 'textContent on Node'); |
24 | 23 |
25 // FIXME: Add a test for normalize() | 24 // FIXME: Add a test for normalize() |
26 | 25 |
27 testCloner(function (customElement) { | 26 test(function () { |
28 return customElement.cloneNode(false); | 27 var element = defineNewCustomElement(); |
29 }, 'cloneNode on Node'); | 28 var instance = document.createElement(element.name); |
| 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 |
30 | 48 |
31 testNodeConnector(function (newContainer, customElement) { | 49 testNodeConnector(function (newContainer, customElement) { |
32 newContainer.insertBefore(customElement, newContainer.firstChild); | 50 newContainer.insertBefore(customElement, newContainer.firstChild); |
33 }, 'insertBefore on ChildNode'); | 51 }, 'insertBefore on ChildNode'); |
34 | 52 |
35 testNodeConnector(function (newContainer, customElement) { | 53 testNodeConnector(function (newContainer, customElement) { |
36 newContainer.appendChild(customElement); | 54 newContainer.appendChild(customElement); |
37 }, 'appendChild on ChildNode'); | 55 }, 'appendChild on ChildNode'); |
38 | 56 |
39 testNodeConnector(function (newContainer, customElement) { | 57 testNodeConnector(function (newContainer, customElement) { |
40 newContainer.replaceChild(customElement, newContainer.firstChild); | 58 newContainer.replaceChild(customElement, newContainer.firstChild); |
41 }, 'replaceChild on ChildNode'); | 59 }, 'replaceChild on ChildNode'); |
42 | 60 |
43 testNodeDisconnector(function (customElement) { | 61 testNodeDisconnector(function (customElement) { |
44 customElement.parentNode.removeChild(customElement); | 62 customElement.parentNode.removeChild(customElement); |
45 }, 'removeChild on ChildNode'); | 63 }, 'removeChild on ChildNode'); |
46 | 64 |
47 </script> | 65 </script> |
48 </body> | 66 </body> |
49 </html> | 67 </html> |
OLD | NEW |