Chromium Code Reviews| OLD | NEW |
|---|---|
| (Empty) | |
| 1 <!DOCTYPE html> | |
| 2 <title>Custom Builtin Elements: defineElement</title> | |
|
dominicc (has gone to gerrit)
2016/09/13 08:22:45
Let's use a more specific title.
| |
| 3 <link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#cus tomelementsregistry"> | |
| 4 <script src="../../resources/testharness.js"></script> | |
| 5 <script src="../../resources/testharnessreport.js"></script> | |
| 6 <script src="resources/custom-elements-helpers.js"></script> | |
| 7 <body> | |
| 8 <script> | |
| 9 // An addition to define-element.html for paths taken for builtin elements | |
| 10 // These aren't implemented yet | |
|
dominicc (has gone to gerrit)
2016/09/13 08:22:45
Scratch this comment; the -expected.txt file will
| |
| 11 | |
| 12 'use strict'; | |
| 13 | |
| 14 test_with_window((w) => { | |
| 15 class A extends w.HTMLButtonElement {} | |
| 16 let valid_custom_element_names = [ | |
| 17 'a-a', | |
| 18 'z0-y0', | |
| 19 'emotion-\u1f60d', | |
| 20 'math-\u03b1', | |
| 21 'a.b-c' | |
| 22 ]; | |
| 23 valid_custom_element_names.forEach((val) => { | |
| 24 assert_throws_dom_exception(w, 'NotSupportedError', () => { | |
| 25 w.customElements.define('a-a', A, { extends: val }); | |
| 26 }, 'having valid custon element name element interface (' + val + ') ' + | |
|
dominicc (has gone to gerrit)
2016/09/13 08:22:45
You can use `... ${val} ...` for more succinct str
| |
| 27 'for extends should throw a NotSupportedError') | |
| 28 }); | |
| 29 }, 'Element interface for extends is not valid custom element name'); | |
| 30 | |
| 31 test_with_window((w) => { | |
| 32 class A extends w.HTMLButtonElement {} | |
| 33 let HTMLUnknownElement_names = [ | |
| 34 'bgsound', | |
| 35 'blink', | |
| 36 'isindex', | |
| 37 'multicol', | |
| 38 'nextid', | |
| 39 'spacer', | |
| 40 42 | |
| 41 ] | |
| 42 HTMLUnknownElement_names.forEach((val) => { | |
| 43 assert_throws_dom_exception(w, 'NotSupportedError', () => { | |
| 44 w.customElements.define('a-a', A, { extends: val }); | |
| 45 }, 'having element interface for extends (' + val + ') undefined in specs' + | |
| 46 ' should throw a NotSupportedError'); | |
| 47 }); | |
| 48 }, 'Element interface for extends defined in specification'); | |
| 49 | |
| 50 test_with_window((w) => { | |
| 51 class A extends w.HTMLButtonElement {} | |
| 52 w.customElements.define('defined-name', A, { extends: 'button' }); | |
| 53 assert_equals(new A().localName, 'button', | |
| 54 'localName should be element interface for extends'); | |
| 55 assert_not_equals(new A().localName, 'defined-name', | |
| 56 'localName should not be defined-name'); | |
| 57 }, 'localName set to element interface for extends'); | |
| 58 </script> | |
| 59 </body> | |
| OLD | NEW |