Commit cf5d7978 authored by yurak's avatar yurak Committed by Commit bot

Custom Elements: layout tests for custom built-in elements definition

For custom built-in elements:

https://html.spec.whatwg.org/multipage/scripting.html#element-definition

7. If an element interface is provided for the extends option, it is assumed to be a customized built-in element.

7.1. If element interface is valid custom element name, throws NotSupportedError DOMException
     https://html.spec.whatwg.org/multipage/scripting.html#valid-custom-element-name

7.2. If element interface is HTMLUnknownElement, throws NotSupportedError DOMException
     https://html.spec.whatwg.org/multipage/dom.html#elements-in-the-dom:element-interface

7.3. localName set to extends value and not the define-name

A -expected.txt file was included since this isn't implemented yet.

BUG=

Review-Url: https://codereview.chromium.org/2321363002
Cr-Commit-Position: refs/heads/master@{#418762}
parent 75613110
This is a testharness.js-based test.
FAIL Element interface for extends is not valid custom element name assert_throws: having valid custon element name element interface (a-a) for extends should throw a NotSupportedError function "() => {
try {
func.call(this);
} catch(e) {
exception = e;
throw e;
}
}" did not throw
FAIL Element interface for extends defined in specification assert_throws: having element interface for extends (bgsound) undefined in specs should throw a NotSupportedError function "() => {
try {
func.call(this);
} catch(e) {
exception = e;
throw e;
}
}" did not throw
FAIL localName set to element interface for extends promise_test: Unhandled rejection with value: object "TypeError: Illegal constructor"
Harness: the test ran to completion.
<!DOCTYPE html>
<title>Custom Built-in Elements: define algorithm paths that are reached by customized built-in elements</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>
'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}) ` +
'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>
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment