Chromium Code Reviews| Index: third_party/WebKit/LayoutTests/custom-elements/spec/define-builtin-element.html |
| diff --git a/third_party/WebKit/LayoutTests/custom-elements/spec/define-builtin-element.html b/third_party/WebKit/LayoutTests/custom-elements/spec/define-builtin-element.html |
| new file mode 100644 |
| index 0000000000000000000000000000000000000000..a149676db2006980b3bba19106305c1f13429267 |
| --- /dev/null |
| +++ b/third_party/WebKit/LayoutTests/custom-elements/spec/define-builtin-element.html |
| @@ -0,0 +1,59 @@ |
| +<!DOCTYPE html> |
| +<title>Custom Builtin Elements: defineElement</title> |
|
dominicc (has gone to gerrit)
2016/09/13 08:22:45
Let's use a more specific title.
|
| +<link rel="help" href="https://html.spec.whatwg.org/multipage/scripting.html#customelementsregistry"> |
| +<script src="../../resources/testharness.js"></script> |
| +<script src="../../resources/testharnessreport.js"></script> |
| +<script src="resources/custom-elements-helpers.js"></script> |
| +<body> |
| +<script> |
| +// An addition to define-element.html for paths taken for builtin elements |
| +// These aren't implemented yet |
|
dominicc (has gone to gerrit)
2016/09/13 08:22:45
Scratch this comment; the -expected.txt file will
|
| + |
| +'use strict'; |
| + |
| +test_with_window((w) => { |
| + class A extends w.HTMLButtonElement {} |
| + let valid_custom_element_names = [ |
| + 'a-a', |
| + 'z0-y0', |
| + 'emotion-\u1f60d', |
| + 'math-\u03b1', |
| + 'a.b-c' |
| + ]; |
| + valid_custom_element_names.forEach((val) => { |
| + assert_throws_dom_exception(w, 'NotSupportedError', () => { |
| + w.customElements.define('a-a', A, { extends: val }); |
| + }, '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
|
| + 'for extends should throw a NotSupportedError') |
| + }); |
| +}, 'Element interface for extends is not valid custom element name'); |
| + |
| +test_with_window((w) => { |
| + class A extends w.HTMLButtonElement {} |
| + let HTMLUnknownElement_names = [ |
| + 'bgsound', |
| + 'blink', |
| + 'isindex', |
| + 'multicol', |
| + 'nextid', |
| + 'spacer', |
| + 42 |
| + ] |
| + HTMLUnknownElement_names.forEach((val) => { |
| + assert_throws_dom_exception(w, 'NotSupportedError', () => { |
| + w.customElements.define('a-a', A, { extends: val }); |
| + }, 'having element interface for extends (' + val + ') undefined in specs' + |
| + ' should throw a NotSupportedError'); |
| + }); |
| +}, 'Element interface for extends defined in specification'); |
| + |
| +test_with_window((w) => { |
| + class A extends w.HTMLButtonElement {} |
| + w.customElements.define('defined-name', A, { extends: 'button' }); |
| + assert_equals(new A().localName, 'button', |
| + 'localName should be element interface for extends'); |
| + assert_not_equals(new A().localName, 'defined-name', |
| + 'localName should not be defined-name'); |
| +}, 'localName set to element interface for extends'); |
| +</script> |
| +</body> |