| OLD | NEW |
| 1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Custom Elements: CEReactions on Document interface</title> | 4 <title>Custom Elements: CEReactions on Document 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="importNode and adoptNode of Document interface must
have CEReactions"> | 6 <meta name="assert" content="importNode and adoptNode of Document interface must
have CEReactions"> |
| 7 <meta name="help" content="https://dom.spec.whatwg.org/#document"> | 7 <meta name="help" content="https://dom.spec.whatwg.org/#document"> |
| 8 <meta name="help" content="https://html.spec.whatwg.org/#document"> | 8 <meta name="help" content="https://html.spec.whatwg.org/#document"> |
| 9 <script src="/resources/testharness.js"></script> | 9 <script src="/resources/testharness.js"></script> |
| 10 <script src="/resources/testharnessreport.js"></script> | 10 <script src="/resources/testharnessreport.js"></script> |
| 11 <script src="../resources/custom-elements-helpers.js"></script> | 11 <script src="../resources/custom-elements-helpers.js"></script> |
| 12 <script src="./resources/reactions.js"></script> | 12 <script src="./resources/reactions.js"></script> |
| 13 </head> | 13 </head> |
| 14 <body> | 14 <body> |
| 15 <div id="log"></div> | 15 <div id="log"></div> |
| 16 <script> | 16 <script> |
| 17 | 17 |
| 18 test(function () { | 18 test(function () { |
| 19 var element = define_new_custom_element(); | 19 var element = define_new_custom_element(); |
| 20 var instance = document.createElement(element.name); | 20 var instance = document.createElement(element.name); |
| 21 assert_array_equals(element.takeLog().types(), ['constructed']); | 21 assert_array_equals(element.takeLog().types(), ['constructed']); |
| 22 | 22 |
| 23 var newDoc = document.implementation.createHTMLDocument(); | 23 var newDoc = document.implementation.createHTMLDocument(); |
| 24 newDoc.importNode(instance); | 24 newDoc.importNode(instance); |
| 25 | 25 |
| 26 var logEntries = element.takeLog(); | 26 assert_array_equals(element.takeLog().types(), []); |
| 27 assert_array_equals(logEntries.types(), ['constructed']); | 27 }, 'importNode on Document must not construct a new custom element when importin
g a custom element into a window-less document'); |
| 28 assert_equals(logEntries.last().oldDocument, document); | |
| 29 assert_equals(logEntries.last().newDocument, newDoc); | |
| 30 }, 'importNode on Document must construct a new custom element when importing a
custom element'); | |
| 31 | 28 |
| 32 test(function () { | 29 test(function () { |
| 33 var element = define_new_custom_element(); | 30 var element = define_new_custom_element(); |
| 31 var template = document.createElement('template'); |
| 32 template.innerHTML = `<${element.name}></${element.name}>`; |
| 33 assert_array_equals(element.takeLog().types(), []); |
| 34 document.importNode(template.content, true); |
| 35 assert_array_equals(element.takeLog().types(), ['constructed']); |
| 36 }, 'importNode on Document must construct a new custom element when importing a
custom element from a template'); |
| 37 |
| 38 test(function () { |
| 39 var element = define_new_custom_element(); |
| 34 var instance = document.createElement(element.name); | 40 var instance = document.createElement(element.name); |
| 35 assert_array_equals(element.takeLog().types(), ['constructed']); | 41 assert_array_equals(element.takeLog().types(), ['constructed']); |
| 36 | 42 |
| 37 var newDoc = document.implementation.createHTMLDocument(); | 43 var newDoc = document.implementation.createHTMLDocument(); |
| 38 newDoc.adoptNode(instance); | 44 newDoc.adoptNode(instance); |
| 39 | 45 |
| 40 var logEntries = element.takeLog(); | 46 var logEntries = element.takeLog(); |
| 41 assert_array_equals(logEntries.types(), ['adopted']); | 47 assert_array_equals(logEntries.types(), ['adopted']); |
| 42 assert_equals(logEntries.last().oldDocument, document); | 48 assert_equals(logEntries.last().oldDocument, document); |
| 43 assert_equals(logEntries.last().newDocument, newDoc); | 49 assert_equals(logEntries.last().newDocument, newDoc); |
| (...skipping 12 matching lines...) Expand all Loading... |
| 56 | 62 |
| 57 container.focus(); | 63 container.focus(); |
| 58 document.execCommand('delete', false, null); | 64 document.execCommand('delete', false, null); |
| 59 | 65 |
| 60 assert_array_equals(element.takeLog().types(), ['disconnected']); | 66 assert_array_equals(element.takeLog().types(), ['disconnected']); |
| 61 }, 'execCommand on Document must enqueue a disconnected reaction when deleting a
custom element from a contenteditable element'); | 67 }, 'execCommand on Document must enqueue a disconnected reaction when deleting a
custom element from a contenteditable element'); |
| 62 | 68 |
| 63 </script> | 69 </script> |
| 64 </body> | 70 </body> |
| 65 </html> | 71 </html> |
| OLD | NEW |