summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/portals/portal-activate-default.html
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 17:32:43 +0000
commit6bf0a5cb5034a7e684dcc3500e841785237ce2dd (patch)
treea68f146d7fa01f0134297619fbe7e33db084e0aa /testing/web-platform/tests/portals/portal-activate-default.html
parentInitial commit. (diff)
downloadthunderbird-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/portal-activate-default.html')
-rw-r--r--testing/web-platform/tests/portals/portal-activate-default.html58
1 files changed, 58 insertions, 0 deletions
diff --git a/testing/web-platform/tests/portals/portal-activate-default.html b/testing/web-platform/tests/portals/portal-activate-default.html
new file mode 100644
index 0000000000..b1a8feb1f4
--- /dev/null
+++ b/testing/web-platform/tests/portals/portal-activate-default.html
@@ -0,0 +1,58 @@
+<!DOCTYPE html>
+<meta name="timeout" content="long">
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<script src="resources/open-blank-host.js"></script>
+<script>
+promise_test(async t => {
+ assert_implements("HTMLPortalElement" in self);
+ const w = await openBlankPortalHost();
+ try {
+ const bc = new BroadcastChannel('click-activate');
+ const portal = w.document.createElement('portal');
+ portal.src = new URL(`resources/portal-activate-broadcastchannel.html?bc=${bc.name}`, location.href);
+ w.document.body.appendChild(portal);
+ await new Promise(resolve => portal.onload = resolve);
+ let activated = new Promise(resolve => bc.onmessage = e => resolve(e.data));
+ portal.click();
+ let {event, data} = await activated;
+ assert_equals(event, 'portalactivate');
+ assert_equals(data, undefined);
+ } finally {
+ w.close();
+ }
+}, "Clicking should activate with undefined data.");
+
+promise_test(async t => {
+ assert_implements("HTMLPortalElement" in self);
+ const w = await openBlankPortalHost();
+ try {
+ const bc = new BroadcastChannel('prevent-no-activate');
+ const portal = w.document.createElement('portal');
+ portal.src = new URL(`resources/portal-activate-broadcastchannel.html?bc=${bc.name}`, location.href);
+ portal.onclick = e => e.preventDefault();
+ w.document.body.appendChild(portal);
+ await new Promise(resolve => portal.onload = resolve);
+ bc.onmessage = t.unreached_func('activation should not occur');
+ portal.click();
+ await new Promise(resolve => t.step_timeout(resolve, 3000));
+ } finally {
+ w.close();
+ }
+}, "Clicking shouldn't activate if prevented.");
+
+// Script didn't create the promise so it shouldn't observe one.
+// This forecloses a naive implementation of this behavior that simply calls the WebIDL operation.
+promise_test(async t => {
+ assert_implements("HTMLPortalElement" in self);
+ const w = await openBlankPortalHost();
+ try {
+ const portal = w.document.createElement('portal');
+ w.onunhandledrejection = t.unreached_func('unhandledrejection event should not fire');
+ portal.click();
+ await new Promise(resolve => t.step_timeout(resolve, 3000));
+ } finally {
+ w.close();
+ }
+}, "Failed activation should not surface as an unhandled promise rejection.");
+</script>