diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 00:47:55 +0000 |
commit | 26a029d407be480d791972afb5975cf62c9360a6 (patch) | |
tree | f435a8308119effd964b339f76abb83a57c29483 /testing/web-platform/tests/custom-elements/CustomElementRegistry-getName.tentative.html | |
parent | Initial commit. (diff) | |
download | firefox-26a029d407be480d791972afb5975cf62c9360a6.tar.xz firefox-26a029d407be480d791972afb5975cf62c9360a6.zip |
Adding upstream version 124.0.1.upstream/124.0.1
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/custom-elements/CustomElementRegistry-getName.tentative.html')
-rw-r--r-- | testing/web-platform/tests/custom-elements/CustomElementRegistry-getName.tentative.html | 46 |
1 files changed, 46 insertions, 0 deletions
diff --git a/testing/web-platform/tests/custom-elements/CustomElementRegistry-getName.tentative.html b/testing/web-platform/tests/custom-elements/CustomElementRegistry-getName.tentative.html new file mode 100644 index 0000000000..9bd43d5108 --- /dev/null +++ b/testing/web-platform/tests/custom-elements/CustomElementRegistry-getName.tentative.html @@ -0,0 +1,46 @@ +<!DOCTYPE html> +<title>Custom Elements: CustomElementRegistry.getName function</title> +<meta name="author" title="Keith Cirkel" href="mailto:keithamus@github.com"> +<meta name="assert" content="CustomElementRegistry.getName function exists"> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> +test(function () { + assert_equals(customElements.getName(class extends HTMLElement {}), null); +}, 'customElements.getName must return null when the registry does not contain an entry with the given constructor'); + +test(function () { + assert_throws_js(TypeError, function () { customElements.getName(undefined); }, + 'customElements.getName must throw a TypeError when the element interface is undefined'); + assert_throws_js(TypeError, function () { customElements.getName(null); }, + 'customElements.getName must throw a TypeError when the element interface is null'); + assert_throws_js(TypeError, function () { customElements.getName('foo-bar'); }, + 'customElements.getName must throw a TypeError when the element interface is a string'); + assert_throws_js(TypeError, function () { customElements.getName(1); }, + 'customElements.getName must throw a TypeError when the element interface is a number'); + assert_throws_js(TypeError, function () { customElements.getName({}); }, + 'customElements.getName must throw a TypeError when the element interface is an object'); + assert_throws_js(TypeError, function () { customElements.getName([]) }, + 'customElements.getName must throw a TypeError when the element interface is an array'); +}, 'customElements.getName must throw when the element interface is not a constructor'); + +test(function () { + class OtherExistingCustomElement extends HTMLElement {}; + class SecondExistingCustomElement extends HTMLElement {}; + assert_throws_js(TypeError, function () { customElements.getName(customElements.getName(OtherExistingCustomElement)); }, + 'customElements.getName must throw a TypeError when the element interface is undefined'); + customElements.define('other-existing-custom-element', OtherExistingCustomElement); + customElements.define('second-existing-custom-element', SecondExistingCustomElement); + assert_equals(customElements.getName(OtherExistingCustomElement), 'other-existing-custom-element'); + assert_equals(customElements.getName(SecondExistingCustomElement), 'second-existing-custom-element'); +}, 'customElements.getName returns the name of the entry with the given constructor when there is a matching entry.'); + +test(function () { + class ButtonCustomBuiltInElement extends HTMLButtonElement {}; + class InputCustomBuiltInElement extends HTMLInputElement {}; + customElements.define('button-custom-built-in-element', ButtonCustomBuiltInElement, { extends: 'button' }); + customElements.define('input-custom-built-in-element', InputCustomBuiltInElement, { extends: 'input' }); + assert_equals(customElements.getName(ButtonCustomBuiltInElement), 'button-custom-built-in-element'); + assert_equals(customElements.getName(InputCustomBuiltInElement), 'input-custom-built-in-element'); +}, 'customElements.getName returns the name of the entry with the given customized built in constructor when there is a matching entry.'); +</script> |