Skip to content

Commit 2fc3bee

Browse files
saschanazmoz-wptsync-bot
authored andcommitted
Test repeated fullscreen request with different keyboard lock mode
Differential Revision: https://phabricator.services.mozilla.com/D294939 bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=2032682 gecko-commit: 0cce7093c6575b5d72c83f9ce9e2e39f62140848 gecko-commit-git: 2b5d73b65b85467c137cdcafd83dc9f85099481f gecko-reviewers: dom-core, edgar
1 parent eb10dce commit 2fc3bee

2 files changed

Lines changed: 34 additions & 2 deletions

File tree

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
// META: script=/resources/testdriver.js
2+
// META: script=/resources/testdriver-actions.js
3+
// META: script=/resources/testdriver-vendor.js
4+
// META: timeout=long
5+
6+
promise_test(async t => {
7+
t.add_cleanup(() => document.exitFullscreen().catch(() => {}));
8+
9+
let { promise: fullscreenEnterPromise, resolve } = Promise.withResolvers();
10+
document.addEventListener("fullscreenchange", resolve, { once: true });
11+
12+
await test_driver.bless("requestFullscreen", () => document.body.requestFullscreen({ keyboardLock: "browser" }));
13+
await fullscreenEnterPromise;
14+
assert_equals(document.fullscreenElement, document.body, "fullscreen should activate");
15+
16+
await test_driver.send_keys(document.body, '\uE00C');
17+
await new Promise(r => t.step_timeout(r, 2000));
18+
assert_equals(document.fullscreenElement, document.body, "fullscreen should stay");
19+
20+
document.onfullscreenchange = t.unreached_func("No extra fullscreen change is expected by option change");
21+
await test_driver.bless("requestFullscreen", () => document.body.requestFullscreen());
22+
await new Promise(requestAnimationFrame);
23+
document.onfullscreenchange = null;
24+
25+
await test_driver.send_keys(document.body, '\uE00C');
26+
await new Promise(r => t.step_timeout(r, 2000));
27+
assert_equals(document.fullscreenElement, null, "fullscreen should deactivate");
28+
}, `Requesting fullscreen again without keyboard lock should disable it`);
29+
30+
// TODO(krosylight): we should be able to test the reverse way, but there's no good way to do so.

fullscreen/api/document-fullscreen-keyboard-lock-escape.tentative.window.js

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
// META: script=/resources/testdriver-vendor.js
44
// META: timeout=long
55

6-
76
async function holdEscapeKey() {
87
// Press Escape for 5 seconds
98
// Holding the key makes it repeat, so do the same here
@@ -27,6 +26,8 @@ for (const preventDefault of [true, false]) {
2726
const withEv = preventDefault ? "with" : "without";
2827

2928
promise_test(async t => {
29+
t.add_cleanup(() => document.exitFullscreen().catch(() => {}));
30+
3031
const signal = t.get_signal();
3132
await test_driver.bless("requestFullscreen", () => document.body.requestFullscreen({ keyboardLock: "browser" }));
3233
assert_equals(document.fullscreenElement, document.body, "fullscreen should activate");
@@ -44,6 +45,8 @@ for (const preventDefault of [true, false]) {
4445
}, `Holding Escape ${withEv} event.preventDefault() should cause fullscreen exit`);
4546

4647
promise_test(async t => {
48+
t.add_cleanup(() => document.exitFullscreen().catch(() => {}));
49+
4750
const signal = t.get_signal();
4851
await test_driver.bless("requestFullscreen", () => document.body.requestFullscreen({ keyboardLock: "browser" }));
4952
assert_equals(document.fullscreenElement, document.body, "fullscreen should activate");
@@ -54,6 +57,5 @@ for (const preventDefault of [true, false]) {
5457
await test_driver.send_keys(document.body, '\uE00C');
5558
await new Promise(r => t.step_timeout(r, 2000));
5659
assert_equals(document.fullscreenElement, document.body, "fullscreen should stay");
57-
await document.exitFullscreen();
5860
}, `Tapping Escape ${withEv} event.preventDefault() should not cause fullscreen exit`);
5961
}

0 commit comments

Comments
 (0)