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 /testing/web-platform/tests/portals/portals-adopt-predecessor.html | |
parent | Initial commit. (diff) | |
download | thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.tar.xz thunderbird-6bf0a5cb5034a7e684dcc3500e841785237ce2dd.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 'testing/web-platform/tests/portals/portals-adopt-predecessor.html')
-rw-r--r-- | testing/web-platform/tests/portals/portals-adopt-predecessor.html | 82 |
1 files changed, 82 insertions, 0 deletions
diff --git a/testing/web-platform/tests/portals/portals-adopt-predecessor.html b/testing/web-platform/tests/portals/portals-adopt-predecessor.html new file mode 100644 index 0000000000..04c6196062 --- /dev/null +++ b/testing/web-platform/tests/portals/portals-adopt-predecessor.html @@ -0,0 +1,82 @@ +<!DOCTYPE html> +<title>Tests that a portal can adopt its predecessor</title> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script> + function waitForCompletion(targetTest) { + return new Promise((resolve, reject) => { + window.addEventListener("message", ({data: {test, message}}) => { + if (test === targetTest) + resolve(message); + }); + }); + } + + promise_test(async () => { + assert_implements("HTMLPortalElement" in self); + var test = "adopt-once"; + window.open(`resources/portals-adopt-predecessor.html?test=${test}`); + var message = await waitForCompletion(test); + assert_equals(message, "adopted"); + }, "Tests that a portal can adopt its predecessor."); + + promise_test(async () => { + assert_implements("HTMLPortalElement" in self); + var test = "adopt-twice"; + window.open(`resources/portals-adopt-predecessor.html?test=${test}`); + var message = await waitForCompletion(test); + assert_equals(message, "passed"); + }, "Tests that trying to adopt the predecessor twice will throw an exception."); + + async_test(function(t) { + assert_implements("HTMLPortalElement" in self); + var test = "adopt-after-event"; + var bc = new BroadcastChannel(`test-${test}`); + bc.onmessage = t.step_func_done(function(e) { + assert_equals(e.data, "passed"); + bc.close(); + }); + window.open(`resources/portals-adopt-predecessor.html?test=${test}`); + }, "Tests that trying to adopt the predecessor after the PortalActivateEvent will throw an exception."); + + promise_test(async t => { + assert_implements("HTMLPortalElement" in self); + var test = "adopt-and-activate"; + window.open(`resources/portals-adopt-predecessor.html?test=${test}`); + var message = await waitForCompletion(test); + assert_equals(message, "passed"); + }, "Tests that activating an adopted predecessor without inserting it works"); + + async_test(t => { + assert_implements("HTMLPortalElement" in self); + var test = "adopt-attach-remove"; + var bc = new BroadcastChannel(`test-${test}`); + bc.onmessage = t.step_func_done(function(e) { + assert_equals(e.data, "passed"); + bc.close(); + }); + window.open(`resources/portals-adopt-predecessor.html?test=${test}`); + }, "Tests that an adopting, inserting and then removing a predecessor works correctly"); + + async_test(t => { + assert_implements("HTMLPortalElement" in self); + var test = "adopt-and-discard"; + var bc = new BroadcastChannel(`test-${test}`); + bc.onmessage = t.step_func_done(function(e) { + assert_equals(e.data, "passed"); + bc.close(); + }); + window.open(`resources/portals-adopt-predecessor.html?test=${test}`); + }, "Tests that the adopted predecessor is destroyed if it isn't inserted"); + + async_test(t => { + assert_implements("HTMLPortalElement" in self); + var test = "adopt-to-disconnected-node"; + var bc = new BroadcastChannel(`test-${test}`); + bc.onmessage = t.step_func_done(function(e) { + assert_equals(e.data, "passed"); + bc.close(); + }); + window.open(`resources/portals-adopt-predecessor.html?test=${test}`); + }, "Tests that an adopted portal can be inserted into a disconnected node."); +</script> |