diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-07 17:32:43 +0000 |
commit | 6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch) | |
tree | a68f146d7fa01f0134297619fbe7e33db084e0aa /dom/tests/mochitest/webcomponents/test_custom_element_define_parser.html | |
parent | Initial commit. (diff) | |
download | thunderbird-upstream.tar.xz thunderbird-upstream.zip |
Adding upstream version 1:115.7.0.upstream/1%115.7.0upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/tests/mochitest/webcomponents/test_custom_element_define_parser.html')
-rw-r--r-- | dom/tests/mochitest/webcomponents/test_custom_element_define_parser.html | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/dom/tests/mochitest/webcomponents/test_custom_element_define_parser.html b/dom/tests/mochitest/webcomponents/test_custom_element_define_parser.html new file mode 100644 index 0000000000..dc247220d4 --- /dev/null +++ b/dom/tests/mochitest/webcomponents/test_custom_element_define_parser.html @@ -0,0 +1,61 @@ +<!DOCTYPE HTML> +<html> +<!-- +https://bugzilla.mozilla.org/show_bug.cgi?id=783129 +--> +<head> + <title>Test for customElements.define for elements created by the parser</title> + <script src="/tests/SimpleTest/SimpleTest.js"></script> +<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css" /> +<script> + +var uncaughtError; +window.onerror = function(message, url, lineNumber, columnNumber, error) { + uncaughtError = error; +}; + +var isConnectedCallbackCalled = false; +class XButton extends HTMLButtonElement { + connectedCallback() { + ok(!isConnectedCallbackCalled, "ConnectedCallback should only be called once."); + is(this.tagName, "BUTTON", "Only the <button> element should be upgraded."); + isConnectedCallbackCalled = true; + } +}; + +customElements.define("x-button", XButton, { extends: "button" }); + +class XDiv extends HTMLDivElement { + constructor() { + // Queue a task to check error and callbacks. + setTimeout(() => { + ok(isConnectedCallbackCalled, "ConnectedCallback should be called."); + ok(uncaughtError instanceof TypeError, + "TypeError should be filed for upgrading <x-div> element."); + SimpleTest.finish(); + }, 0); + super(); + } + + connectedCallback() { + ok(false, "Connected callback for x-div should not be called."); + } +}; + +customElements.define("x-div", XDiv); + +SimpleTest.waitForExplicitFinish(); + +</script> +</head> +<body> +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=783129">Bug 783129</a> +<button is="x-button"></button><!-- should be upgraded --> +<x-button></x-button><!-- should not be upgraded --> +<span is="x-button"></span><!-- should not be upgraded --> +<div is="x-div"></div><!-- should not be upgraded --> +<x-div></x-div><!-- should be upgraded, but failed --> +<script> +</script> +</body> +</html> |