Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(62)

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/custom-elements/reactions/Document.html

Issue 2468053002: Import wpt@9fcccf38b6be00f71ffa6bd6e29c5aa1ef25ee8c (Closed)
Patch Set: Skip cssom and svg/shapes, remove unwanted baseline Created 4 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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_with_window(function (contentWindow, contentDocument) {
19 var element = define_new_custom_element(); 19 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
20 var instance = document.createElement(element.name); 20 const instance = contentDocument.createElement('custom-element');
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 const newDoc = contentDocument.implementation.createHTMLDocument();
24 newDoc.importNode(instance); 24 newDoc.importNode(instance);
25 25
26 assert_array_equals(element.takeLog().types(), []); 26 assert_array_equals(element.takeLog().types(), []);
27 }, 'importNode on Document must not construct a new custom element when importin g a custom element into a window-less document'); 27 }, 'importNode on Document must not construct a new custom element when importin g a custom element into a window-less document');
28 28
29 test(function () { 29 test_with_window(function (contentWindow, contentDocument) {
30 var element = define_new_custom_element(); 30 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
31 var template = document.createElement('template'); 31 const template = contentDocument.createElement('template');
32 template.innerHTML = `<${element.name}></${element.name}>`; 32 template.innerHTML = '<custom-element></custom-element>';
33 assert_array_equals(element.takeLog().types(), []); 33 assert_array_equals(element.takeLog().types(), []);
34 document.importNode(template.content, true); 34 contentDocument.importNode(template.content, true);
35 assert_array_equals(element.takeLog().types(), ['constructed']); 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'); 36 }, 'importNode on Document must construct a new custom element when importing a custom element from a template');
37 37
38 test(function () { 38 test_with_window(function (contentWindow, contentDocument) {
39 var element = define_new_custom_element(); 39 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
40 var instance = document.createElement(element.name); 40 const instance = contentDocument.createElement('custom-element');
41 assert_array_equals(element.takeLog().types(), ['constructed']); 41 assert_array_equals(element.takeLog().types(), ['constructed']);
42 42
43 var newDoc = document.implementation.createHTMLDocument(); 43 const newDoc = contentDocument.implementation.createHTMLDocument();
44 newDoc.adoptNode(instance); 44 newDoc.adoptNode(instance);
45 45
46 var logEntries = element.takeLog(); 46 const logEntries = element.takeLog();
47 assert_array_equals(logEntries.types(), ['adopted']); 47 assert_array_equals(logEntries.types(), ['adopted']);
48 assert_equals(logEntries.last().oldDocument, document); 48 assert_equals(logEntries.last().oldDocument, contentDocument);
49 assert_equals(logEntries.last().newDocument, newDoc); 49 assert_equals(logEntries.last().newDocument, newDoc);
50 }, 'adoptNode on Document must enqueue an adopted reaction when importing a cust om element'); 50 }, 'adoptNode on Document must enqueue an adopted reaction when importing a cust om element');
51 51
52 test(function () { 52 test_with_window(function (contentWindow, contentDocument) {
53 var element = define_new_custom_element(); 53 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
54 var instance = document.createElement(element.name); 54 const instance = contentDocument.createElement('custom-element');
55 55
56 var container = document.createElement('div'); 56 const container = contentDocument.createElement('div');
57 container.contentEditable = true; 57 container.contentEditable = true;
58 container.appendChild(instance); 58 container.appendChild(instance);
59 document.body.appendChild(container); 59 contentDocument.body.appendChild(container);
60 60
61 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']) ; 61 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']) ;
62 62
63 container.focus(); 63 container.focus();
64 document.execCommand('delete', false, null); 64 contentDocument.execCommand('delete', false, null);
65 65
66 assert_array_equals(element.takeLog().types(), ['disconnected']); 66 assert_array_equals(element.takeLog().types(), ['disconnected']);
67 }, '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');
68 68
69 test_with_window(function (contentWindow, contentDocument) {
70 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
71
72 contentDocument.title = '';
73 const title = contentDocument.querySelector('title');
74 const instance = contentDocument.createElement('custom-element');
75 title.appendChild(instance);
76 instance.textContent = 'hello';
77
78 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']) ;
79 assert_equals(title.innerHTML, '<custom-element>hello</custom-element>');
80
81 title.text = 'world';
82 assert_equals(title.innerHTML, 'world');
83 assert_array_equals(element.takeLog().types(), ['disconnected']);
84 }, 'title on Document must enqueue disconnectedCallback when removing a custom e lement');
85
86 test_with_window(function (contentWindow, contentDocument) {
87 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
88
89 const body = contentDocument.body;
90 body.innerHTML = '<custom-element>hello</custom-element>';
91
92 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']) ;
93 assert_equals(body.innerHTML, '<custom-element>hello</custom-element>');
94
95 contentDocument.body = contentDocument.createElement('body');
96 assert_array_equals(element.takeLog().types(), ['disconnected']);
97 }, 'body on Document must enqueue disconnectedCallback when removing a custom el ement');
98
99 test_with_window(function (contentWindow, contentDocument) {
100 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
101
102 const instance = contentDocument.createElement('custom-element');
103 const body = contentDocument.createElement('body');
104 body.appendChild(instance);
105
106 assert_array_equals(element.takeLog().types(), ['constructed']);
107 assert_equals(body.innerHTML, '<custom-element></custom-element>');
108
109 contentDocument.body = body;
110 assert_array_equals(element.takeLog().types(), ['connected']);
111 }, 'body on Document must enqueue connectedCallback when inserting a custom elem ent');
112
69 </script> 113 </script>
70 </body> 114 </body>
71 </html> 115 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698