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

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

Issue 2477133002: Import wpt@306326cfe973b6c7019c50879ad03b02825c7539 (Closed)
Patch Set: Modify TestExpectations or download new baselines for tests. 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
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <title>Custom Elements: CEReactions on HTMLSelectElement interface</title>
5 <meta name="author" title="Ryosuke Niwa" href="mailto:rniwa@webkit.org">
6 <meta name="assert" content="length, add, remove, and the setter of HTMLSelectEl ement interface must have CEReactions">
7 <meta name="help" content="https://dom.spec.whatwg.org/#node">
8 <script src="/resources/testharness.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>
12 </head>
13 <body>
14 <div id="log"></div>
15 <script>
16
17 test_with_window(function (contentWindow, contentDocument) {
18 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
19 contentDocument.body.innerHTML = `<select><option></option></select>`;
20 const option = contentDocument.querySelector('option');
21
22 const instance = contentDocument.createElement(element.name);
23 option.appendChild(instance);
24 instance.textContent = 'hello';
25
26 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']) ;
27 assert_equals(option.innerHTML, '<custom-element>hello</custom-element>');
28
29 const select = contentDocument.querySelector('select');
30 assert_equals(select.length, 1);
31 select.length = 0;
32 assert_equals(select.firstChild, null);
33 assert_array_equals(element.takeLog().types(), ['disconnected']);
34 }, 'length on HTMLSelectElement must enqueue disconnectedCallback when removing a custom element');
35
36 test_with_window(function (contentWindow) {
37 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
38
39 const contentDocument = contentWindow.document;
40 contentDocument.body.innerHTML = `<select></select>`;
41 const select = contentDocument.querySelector('select');
42
43 const option = contentDocument.createElement('option');
44 const instance = contentDocument.createElement(element.name);
45 option.appendChild(instance);
46 instance.textContent = 'hello';
47
48 assert_array_equals(element.takeLog().types(), ['constructed']);
49 assert_equals(option.innerHTML, '<custom-element>hello</custom-element>');
50
51 assert_equals(select.options.length, 0);
52 select[0] = option;
53 assert_equals(select.options.length, 1);
54 assert_array_equals(element.takeLog().types(), ['connected']);
55 }, 'The indexed setter on HTMLSelectElement must enqueue connectedCallback when inserting a custom element');
56
57 test_with_window(function (contentWindow) {
58 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
59
60 const contentDocument = contentWindow.document;
61 contentDocument.body.innerHTML = `<select><option></option></select>`;
62 const option = contentDocument.querySelector('option');
63
64 const instance = contentDocument.createElement(element.name);
65 option.appendChild(instance);
66 instance.textContent = 'hello';
67
68 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']) ;
69 assert_equals(option.innerHTML, '<custom-element>hello</custom-element>');
70
71 const select = contentDocument.querySelector('select');
72 assert_equals(select.options[0], option);
73 select[0] = null;
74 assert_equals(select.options.length, 0);
75 assert_array_equals(element.takeLog().types(), ['disconnected']);
76 }, 'The indexed setter on HTMLSelectElement must enqueue disconnectedCallback wh en removing a custom element');
77
78 test_with_window(function (contentWindow) {
79 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
80
81 const contentDocument = contentWindow.document;
82 contentDocument.body.innerHTML = `<select></select>`;
83 const select = contentDocument.querySelector('select');
84
85 const option = contentDocument.createElement('option');
86 const instance = contentDocument.createElement(element.name);
87 option.appendChild(instance);
88 instance.textContent = 'hello';
89
90 assert_array_equals(element.takeLog().types(), ['constructed']);
91 assert_equals(option.innerHTML, '<custom-element>hello</custom-element>');
92
93 assert_equals(select.options.length, 0);
94 select.add(option);
95 assert_equals(select.options.length, 1);
96 assert_array_equals(element.takeLog().types(), ['connected']);
97 }, 'add on HTMLSelectElement must enqueue connectedCallback when inserting a cus tom element');
98
99 test_with_window(function (contentWindow) {
100 const element = define_custom_element_in_window(contentWindow, 'custom-eleme nt', []);
101
102 const contentDocument = contentWindow.document;
103 contentDocument.body.innerHTML = `<select><option></option></select>`;
104 const option = contentDocument.querySelector('option');
105
106 const instance = contentDocument.createElement(element.name);
107 option.appendChild(instance);
108 instance.textContent = 'hello';
109
110 assert_array_equals(element.takeLog().types(), ['constructed', 'connected']) ;
111 assert_equals(option.innerHTML, '<custom-element>hello</custom-element>');
112
113 const select = contentDocument.querySelector('select');
114 assert_equals(select.options[0], option);
115 select.remove(0);
116 assert_equals(select.options.length, 0);
117 assert_array_equals(element.takeLog().types(), ['disconnected']);
118 }, 'remove on HTMLSelectElement must enqueue disconnectedCallback when removing a custom element');
119
120 </script>
121 </body>
122 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698