diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-04-19 01:47:29 +0000 |
commit | 0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d (patch) | |
tree | a31f07c9bcca9d56ce61e9a1ffd30ef350d513aa /testing/web-platform/tests/screen-orientation/onchange-event-subframe.html | |
parent | Initial commit. (diff) | |
download | firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.tar.xz firefox-esr-0ebf5bdf043a27fd3dfb7f92e0cb63d88954c44d.zip |
Adding upstream version 115.8.0esr.upstream/115.8.0esr
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'testing/web-platform/tests/screen-orientation/onchange-event-subframe.html')
-rw-r--r-- | testing/web-platform/tests/screen-orientation/onchange-event-subframe.html | 83 |
1 files changed, 83 insertions, 0 deletions
diff --git a/testing/web-platform/tests/screen-orientation/onchange-event-subframe.html b/testing/web-platform/tests/screen-orientation/onchange-event-subframe.html new file mode 100644 index 0000000000..1b4b8cd428 --- /dev/null +++ b/testing/web-platform/tests/screen-orientation/onchange-event-subframe.html @@ -0,0 +1,83 @@ +<!DOCTYPE html> +<meta charset="utf-8" /> +<meta viewport="width=device-width, initial-scale=1" /> +<script src="/resources/testharness.js"></script> +<script src="/resources/testharnessreport.js"></script> +<script src="/resources/testdriver.js"></script> +<script src="/resources/testdriver-vendor.js"></script> +<script type="module"> + import { + attachIframe, + makeCleanup, + getOppositeOrientation, + } from "./resources/orientation-utils.js"; + + promise_test(async (t) => { + t.add_cleanup(makeCleanup()); + await test_driver.bless("request fullscreen"); + await document.documentElement.requestFullscreen(); + let orientations = ["portrait", "landscape"]; + if (screen.orientation.type.includes("portrait")) { + orientations = orientations.reverse(); + } + const messageWatcher = new EventWatcher(t, window, "message"); + const changeWatcher = new EventWatcher(t, screen.orientation, "change"); + const iframe = await attachIframe({ + src: "resources/iframe-listen-orientation-change.html", + sandbox: "allow-scripts allow-same-origin", + }); + for (const orientation of orientations) { + const messagePromise = messageWatcher.wait_for("message"); + const eventPromise = changeWatcher.wait_for("change"); + await screen.orientation.lock(orientation); + const winner = await Promise.race([eventPromise, messagePromise]); + assert_true(winner instanceof Event, "change event must be fired first"); + const message = await messagePromise; + assert_true( + message.data.startsWith(orientation), + "subframe receives orientation change event" + ); + } + iframe.remove(); + }, "Test subframes receive orientation change events"); + + promise_test(async (t) => { + t.add_cleanup(makeCleanup()); + const iframe = await attachIframe(); + const opposite = getOppositeOrientation(); + + const topEventPromise = new EventWatcher( + t, + screen.orientation, + "change" + ).wait_for("change"); + const iframeEventPromise = new EventWatcher( + t, + iframe.contentWindow.screen.orientation, + "change" + ).wait_for("change"); + + // Lock from the iframe + await test_driver.bless("request fullscreen"); + await document.documentElement.requestFullscreen(); + const lockPromise = iframe.contentWindow.screen.orientation.lock(opposite); + + const winningEvent = await Promise.race([ + topEventPromise, + iframeEventPromise, + ]); + assert_true( + winningEvent instanceof window.Event, + "top-level change event must be fired first" + ); + + const iframeEvent = await iframeEventPromise; + assert_true( + iframeEvent instanceof iframe.contentWindow.Event, + "iframe event eventually fires" + ); + + await lockPromise; + iframe.remove(); + }, "Check directly that events are fired in right order (from top to bottom)"); +</script> |