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

Side by Side Diff: third_party/WebKit/LayoutTests/imported/wpt/custom-elements/custom-elements-registry/define.html

Issue 2022203002: Import wpt@d510ec1abc30eee4c855c13842bc2f0dfa791f8b (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Message changed by testharness.js update Created 4 years, 6 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <title>Custom Elements: Element definition</title> 2 <title>Custom Elements: Element definition</title>
3 <script src="/resources/testharness.js"></script> 3 <script src="/resources/testharness.js"></script>
4 <script src="/resources/testharnessreport.js"></script> 4 <script src="/resources/testharnessreport.js"></script>
5 <body> 5 <body>
6 <div id="log"></div> 6 <div id="log"></div>
7 <iframe id="iframe"></iframe> 7 <iframe id="iframe"></iframe>
8 <script> 8 <script>
9 'use strict'; 9 'use strict';
10 (() => { 10 (() => {
(...skipping 143 matching lines...) Expand 10 before | Expand all | Expand 10 after
154 ].forEach(name => { 154 ].forEach(name => {
155 test(() => { 155 test(() => {
156 assert_throws(expectNotSupportedError, () => { 156 assert_throws(expectNotSupportedError, () => {
157 customElements.define('test-define-extend-' + name, class {}, { extends: name }); 157 customElements.define('test-define-extend-' + name, class {}, { extends: name });
158 }); 158 });
159 }, `If extends is ${name}, should throw a NotSupportedError`); 159 }, `If extends is ${name}, should throw a NotSupportedError`);
160 }); 160 });
161 161
162 // 8. Let observedAttributesIterable be Get(constructor, "observedAttributes") . 162 // 8. Let observedAttributesIterable be Get(constructor, "observedAttributes") .
163 // Rethrow any exceptions. 163 // Rethrow any exceptions.
164 // See step 12 for rethrow tests. 164 test(() => {
165 class C {
166 static get observedAttributes() { throw_rethrown_error(); }
167 }
168 assert_rethrown(() => {
169 customElements.define('test-define-observedattributes-rethrow', C);
170 });
171 }, 'If constructor.observedAttributes throws, should rethrow');
165 172
166 // 10. Let prototype be Get(constructor, "prototype"). Rethrow any exceptions. 173 // 10. Let prototype be Get(constructor, "prototype"). Rethrow any exceptions.
167 function assert_rethrown(func, description) { 174 function assert_rethrown(func, description) {
168 assert_throws({ name: 'rethrown' }, func, description); 175 assert_throws({ name: 'rethrown' }, func, description);
169 } 176 }
170 function throw_rethrown_error() { 177 function throw_rethrown_error() {
171 const e = new Error('check this is rethrown'); 178 const e = new Error('check this is rethrown');
172 e.name = 'rethrown'; 179 e.name = 'rethrown';
173 throw e; 180 throw e;
174 } 181 }
(...skipping 26 matching lines...) Expand all
201 // 12. Let connectedCallback be Get(prototype, "connectedCallback"). Rethrow a ny exceptions. 208 // 12. Let connectedCallback be Get(prototype, "connectedCallback"). Rethrow a ny exceptions.
202 // 13. If connectedCallback is not undefined, and IsCallable(connectedCallback ) is false, 209 // 13. If connectedCallback is not undefined, and IsCallable(connectedCallback ) is false,
203 // then throw a TypeError exception. 210 // then throw a TypeError exception.
204 // 14. Let disconnectedCallback be Get(prototype, "disconnectedCallback"). Ret hrow any exceptions. 211 // 14. Let disconnectedCallback be Get(prototype, "disconnectedCallback"). Ret hrow any exceptions.
205 // 15. If disconnectedCallback is not undefined, and IsCallable(disconnectedCa llback) is false, 212 // 15. If disconnectedCallback is not undefined, and IsCallable(disconnectedCa llback) is false,
206 // then throw a TypeError exception. 213 // then throw a TypeError exception.
207 // 16. Let attributeChangedCallback be Get(prototype, "attributeChangedCallbac k"). Rethrow any exceptions. 214 // 16. Let attributeChangedCallback be Get(prototype, "attributeChangedCallbac k"). Rethrow any exceptions.
208 // 17. If attributeChangedCallback is not undefined, and IsCallable(attributeC hangedCallback) is false, 215 // 17. If attributeChangedCallback is not undefined, and IsCallable(attributeC hangedCallback) is false,
209 // then throw a TypeError exception. 216 // then throw a TypeError exception.
210 [ 217 [
211 'observedAttributes', // See step 8 above.
212 'connectedCallback',
213 'disconnectedCallback',
214 'attributeChangedCallback',
215 ].forEach(name => {
216 test(() => {
217 class C {
218 get [name]() { throw_rethrown_error(); }
219 }
220 assert_rethrown(() => {
221 customElements.define('test-define-constructor-rethrow-prototype-' + nam e, C);
222 });
223 }, `If constructor.prototype.${name} throws, should rethrow`);
224 });
225 [
226 'connectedCallback', 218 'connectedCallback',
227 'disconnectedCallback', 219 'disconnectedCallback',
228 'attributeChangedCallback', 220 'attributeChangedCallback',
229 ].forEach(name => { 221 ].forEach(name => {
230 test(() => { 222 test(() => {
231 class c {}; 223 class C {
232 c.prototype[name] = undefined; 224 get [name]() { throw_rethrown_error(); }
233 customElements.define('test-define-constructor-prototype-' + name, c); 225 }
234 }, `If constructor.prototype.${name} is undefined, should success`); 226 assert_rethrown(() => {
227 customElements.define(`test-define-${name.toLowerCase()}-rethrow`, C);
228 });
229 }, `If constructor.prototype.${name} throws, should rethrow`);
230
235 [ 231 [
236 [ 'null', null ], 232 { name: 'undefined', value: undefined, success: true },
237 [ 'object', {} ], 233 { name: 'function', value: function () { }, success: true },
238 ].forEach(value => { 234 { name: 'null', value: null, success: false },
239 test(() => { 235 { name: 'object', value: {}, success: false },
240 class c {}; 236 { name: 'integer', value: 1, success: false },
241 c.prototype[name] = value[1]; 237 ].forEach(data => {
242 assert_throws(expectTypeError, () => { 238 test(() => {
243 customElements.define('test-define-constructor-prototype-' + name, c); 239 class C { };
244 }); 240 C.prototype[name] = data.value;
245 }, `If constructor.prototype.${name} is ${value[0]}, should throw a TypeEr ror`); 241 if (data.success) {
246 }) 242 customElements.define(`test-define-${name.toLowerCase()}-${data.name}` , C);
243 } else {
244 assert_throws(expectTypeError, () => {
245 customElements.define(`test-define-${name.toLowerCase()}-${data.name }`, C);
246 });
247 }
248 }, `If constructor.prototype.${name} is ${data.name}, should ${data.succes s ? 'succeed' : 'throw a TypeError'}`);
249 });
247 }); 250 });
248 })(); 251 })();
249 </script> 252 </script>
250 </body> 253 </body>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698