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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/web-platform-tests/custom-elements/instantiating-custom-elements/changing-is-attribute.html

Issue 1954153002: Revert of Import web-platform-tests@88b9a65ce806b5f67e0a535bf2f1602c2df6af58 (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months 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>Changing IS attribute of the custom element must not affect this element' s custom element type, after element is instantiated</title>
5 <meta name="author" title="Sergey G. Grekhov" href="mailto:sgrekhov@unipro.ru">
6 <meta name="author" title="Aleksei Yu. Semenov" href="mailto:a.semenov@unipro.ru ">
7 <meta name="assert" content="After a custom element is instantiated, changing th e value of the IS attribute must not affect this element's custom element type">
8 <link rel="help" href="http://www.w3.org/TR/custom-elements/#instantiating-custo m-elements">
9 <script src="../../../../resources/testharness.js"></script>
10 <script src="../../../../resources/testharnessreport.js"></script>
11 <script src="../testcommon.js"></script>
12 </head>
13 <body>
14 <div id="log"></div>
15 <script>
16 test(function() {
17 var doc = newHTMLDocument();
18 var GeneratedConstructor = doc.registerElement('x-a');
19 var customElement = new GeneratedConstructor();
20 doc.registerElement('x-b');
21 customElement.setAttribute('is', 'x-b');
22 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.pro totype,
23 'Custom element type should be x-a');
24 }, 'Test custom element type, after assigning IS attribute value. ' +
25 'Element is created by constructor');
26
27
28 test(function() {
29 var doc = newHTMLDocument();
30 var GeneratedConstructor = doc.registerElement('x-c');
31 doc.registerElement('x-d');
32 doc.body.innerHTML = '<x-c id="x-c"></x-c>';
33 var customElement = doc.querySelector('#x-c');
34 customElement.setAttribute('is', 'x-d');
35 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.pro totype,
36 'Custom element type should be x-c');
37 }, 'Test custom element type, after assigning IS attribute value. ' +
38 'Element is created via innerHTML property');
39
40
41 test(function() {
42 var doc = newHTMLDocument();
43 doc.body.innerHTML = '<x-e id="x-e"></x-e>';
44 var customElement = doc.querySelector('#x-e');
45 customElement.setAttribute('is', 'x-f');
46 var GeneratedConstructor = doc.registerElement('x-e');
47 doc.registerElement('x-f');
48 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.pro totype,
49 'Custom element type should be x-e');
50 }, 'Test custom element type, after assigning IS attribute value to unresolved e lement. ' +
51 'Element is created via innerHTML property');
52
53
54 testInIFrame('../resources/x-element.html', function(doc) {
55 var GeneratedConstructor = doc.registerElement('x-element');
56 doc.registerElement('y-element');
57 var customElement = doc.querySelector('#x-element');
58 customElement.setAttribute('is', 'y-element');
59 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.pro totype,
60 'Custom element type should be x-element');
61 }, 'Test custom element type, after assigning IS attribute value. ' +
62 'Element is defined in loaded HTML document');
63
64
65 testInIFrame('../resources/x-element.html', function(doc) {
66 var customElement = doc.querySelector('#x-element');
67 customElement.setAttribute('is', 'y-element');
68 var GeneratedConstructor = doc.registerElement('x-element');
69 doc.registerElement('y-element');
70 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.pro totype,
71 'Custom element type should be x-element');
72 }, 'Test custom element type, after assigning IS attribute value to unresolved e lement. ' +
73 'Element is defined in loaded HTML document');
74
75
76 test(function() {
77 var doc = newHTMLDocument();
78 HTML5_ELEMENTS.forEach(function(tagName) {
79 if (HTML5_DOCUMENT_ELEMENTS.indexOf(tagName) !== -1) {
80 return;
81 }
82 var name = 'y-' + tagName;
83 var obj = doc.createElement(tagName);
84 var proto = Object.create(obj.constructor.prototype);
85 var GeneratedConstructor = doc.registerElement(name, {prototype: proto, extends: tagName});
86 if (HTML5_TABLE_ELEMENTS.indexOf(tagName) !== -1) {
87 doc.body.innerHTML =
88 '<table>' +
89 '<' + tagName + ' id="custom-element" is="' + name + '"></' + ta gName + '>' +
90 '</table>';
91 } else {
92 doc.body.innerHTML =
93 '<' + tagName + ' id="custom-element" is="' + name + '"></' + ta gName + '>';
94 }
95 var customElement = doc.querySelector('#custom-element');
96 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor .prototype,
97 'Custom element type should be '+ name);
98
99 var name2 = 'y-a-' + tagName;
100 doc.registerElement(name2);
101 customElement.setAttribute('is', name2);
102 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor .prototype,
103 'Custom element type should be ' + name);
104 });
105 }, 'Test custom element type after changing IS attribute value. ' +
106 'Element is HTML5 element with IS attribute referring to custom element type ');
107
108
109 test(function() {
110 var doc = newHTMLDocument();
111 var localName = 'z-a';
112 var obj = doc.createElement('a');
113 var proto = Object.create(obj.constructor.prototype);
114 var GeneratedConstructor = doc.registerElement(localName, {prototype: proto, extends: 'a'});
115 doc.body.innerHTML = '<a id="custom-element" is="' + localName + '"></a>';
116 var customElement = doc.querySelector('#custom-element');
117
118 HTML5_ELEMENTS.forEach(function(tagName) {
119 var name = 'z-a-' + tagName;
120 var htmlElement = doc.createElement(tagName);
121 var htmlElementProto = Object.create(htmlElement.constructor.prototype);
122 doc.registerElement(name, {prototype: htmlElementProto, extends: tagName });
123 customElement.setAttribute('is', name);
124 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor .prototype,
125 'Custom element type should be ' + localName);
126 });
127 }, 'Test custom element type after changing IS attribute value several times. ' +
128 'Element is HTML5 element with IS attribute referring to custom element type ');
129
130
131 test(function() {
132 var doc = newHTMLDocument();
133 var GeneratedConstructor = doc.registerElement('x-g');
134 doc.registerElement('x-h');
135 doc.body.innerHTML = '<x-g id="x-g" is="x-h"></x-g>';
136 var customElement = doc.querySelector('#x-g');
137 customElement.removeAttribute('is');
138 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.pro totype,
139 'Custom element type should be x-g');
140 }, 'Test custom element type, after removing IS attribute value. ' +
141 'Element is created via innerHTML property');
142
143
144 test(function() {
145 var doc = newHTMLDocument();
146 var obj = doc.createElement('a');
147 var proto = Object.create(obj.constructor.prototype);
148 var GeneratedConstructor = doc.registerElement('x-i', {prototype: proto, ext ends: 'a'});
149 doc.body.innerHTML = '<a id="x-i" is="x-i"></a>';
150 var customElement = doc.querySelector('#x-i');
151 customElement.removeAttribute('is');
152 assert_equals(Object.getPrototypeOf(customElement), GeneratedConstructor.pro totype,
153 'Custom element type should be x-i');
154 }, 'Test custom element type, after removing IS attribute value. ' +
155 'Element is HTML5 element with IS attribute referring to custom element type ');
156 </script>
157 </body>
158 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698