diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /dom/tests/mochitest/webcomponents | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to '')
3 files changed, 50 insertions, 56 deletions
diff --git a/dom/tests/mochitest/webcomponents/chrome.toml b/dom/tests/mochitest/webcomponents/chrome.toml index b29df619c4..5db7f14a37 100644 --- a/dom/tests/mochitest/webcomponents/chrome.toml +++ b/dom/tests/mochitest/webcomponents/chrome.toml @@ -1,7 +1,7 @@ [DEFAULT] support-files = ["dummy_page.html"] -["test_custom_element_ensure_custom_element.html"] +["test_custom_element_auto_import.html"] ["test_custom_element_htmlconstructor_chrome.html"] support-files = [ diff --git a/dom/tests/mochitest/webcomponents/test_custom_element_auto_import.html b/dom/tests/mochitest/webcomponents/test_custom_element_auto_import.html new file mode 100644 index 0000000000..2371600677 --- /dev/null +++ b/dom/tests/mochitest/webcomponents/test_custom_element_auto_import.html @@ -0,0 +1,49 @@ +<!DOCTYPE HTML> +<html lang="en"> +<head> + <meta charset="utf-8"> + <title>Test for custom element auto import behavior</title> + <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> + <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> + <script> + /* + Note: once you import one of these custom elements, they stay on the window + outside of the task that imported them. This can create issues if writing + another test in this file. + */ + add_task(async function test_custom_elements_auto_import() { + let registry = SpecialPowers.wrap(customElements); + + // Ensure the custom elements from ESModules are not defined. + is(registry.get("moz-button-group"), undefined, "moz-button-group should be undefined since we have not yet imported it"); + is(registry.get("moz-support-link"), undefined, "moz-support-link should be undefined since we have not yet imported it"); + is(registry.get("moz-toggle"), undefined, "moz-toggle should be undefined since we have not yet imported it"); + + // Create a custom element and assert that it gets imported/defined. + document.createElement("moz-support-link"); + ok(registry.get("moz-support-link"), "moz-support-link should be defined after creation"); + + // Create multiple custom elements and assert they exist in the registry. + is(registry.get("moz-button-group"), undefined, "moz-button-group should be undefined since we have not yet imported it"); + is(registry.get("moz-toggle"), undefined, "moz-toggle should be undefined since we have not yet imported it") + + document.createElement("moz-button-group"); + document.createElement("moz-toggle"); + + ok(registry.get("moz-toggle"), "moz-toggle should be defined after importing it"); + ok(registry.get("moz-button-group"), "moz-button-group should be defined after importing it"); + + // Ensure there are no errors if the imported elements are created again. + document.createElement("moz-support-link"); + document.createElement("moz-button-group"); + document.createElement("moz-toggle"); + ok(true, "The custom elements should not throw an error if imported again"); + }) + </script> +</head> +<body> +<p id="display"></p> +<div id="content" style="display: none"></div> +<pre id="test"></pre> +</body> +</html> diff --git a/dom/tests/mochitest/webcomponents/test_custom_element_ensure_custom_element.html b/dom/tests/mochitest/webcomponents/test_custom_element_ensure_custom_element.html deleted file mode 100644 index 03ed2e3815..0000000000 --- a/dom/tests/mochitest/webcomponents/test_custom_element_ensure_custom_element.html +++ /dev/null @@ -1,55 +0,0 @@ -<!DOCTYPE HTML> -<html lang="en"> - <!-- - https://bugzilla.mozilla.org/show_bug.cgi?id=1813077 - --> -<head> - <meta charset="utf-8"> - <title>Test for customElements.ensureCustomElement</title> - <script src="chrome://mochikit/content/tests/SimpleTest/SimpleTest.js"></script> - <link rel="stylesheet" href="chrome://mochikit/content/tests/SimpleTest/test.css"/> - <script> - /* - Note: once you import one of these custom elements, they stay on the window - outside of the task that imported them. This can create issues if writing - another test in this file. - */ - add_task(async function test_ensure_custom_elements() { - let registry = SpecialPowers.wrap(customElements); - ok(window.ensureCustomElements, "should be defined"); - - // Ensure the custom elements from ESModules are not defined. - is(registry.get("moz-button-group"), undefined, "moz-button-group should be undefined since we have not yet imported it"); - is(registry.get("moz-support-link"), undefined, "moz-support-link should be undefined since we have not yet imported it"); - is(registry.get("moz-toggle"), undefined, "moz-toggle should be undefined since we have not yet imported it"); - - // Import a single custom element and assert it exists in the custom - // element registry - let modules = await window.ensureCustomElements("moz-support-link"); - ok(registry.get("moz-support-link"), "moz-support-link should be defined after importing it"); - is(modules, null, "There should not be a return value when using ensureCustomElements"); - - // Import multiple custom elements and assert they exist in the registry - modules = undefined; - is(registry.get("moz-button-group"), undefined, "moz-button-group should be undefined since we have not yet imported it"); - is(registry.get("moz-toggle"), undefined, "moz-toggle should be undefined since we have not yet imported it") - modules = await window.ensureCustomElements("moz-toggle", "moz-button-group"); - is(modules, null, "There should not be a return value when using ensureCustomElements"); - ok(registry.get("moz-toggle"), "moz-toggle should be defined after importing it"); - ok(registry.get("moz-button-group"), "moz-button-group should be defined after importing it"); - - // Ensure there are no errors if the imported elements are imported - // again - modules = undefined; - modules = await window.ensureCustomElements("moz-support-link", "moz-toggle", "moz-button-group"); - ok(true, "The custom elements should not throw an error if imported again"); - is(modules, null, "There should not be a return value when using ensureCustomElements"); - }) - </script> -</head> -<body> -<p id="display"></p> -<div id="content" style="display: none"></div> -<pre id="test"></pre> -</body> -</html> |