Skip to content

Commit 86d83d5

Browse files
committed
Test that element.requestFullscreen() consumes user activation
This makes a bunch of other tests redundant, as they're also calling requestFullscreen() twice, and should all fail in exactly the same way. element-request-fullscreen-same-manual.html is also converted to ensure that a second call in a new click does work, to ensure the failure isn't because the element is the same as the fullscreen element. Follows whatwg/fullscreen#153.
1 parent f119ebc commit 86d83d5

9 files changed

+53
-309
lines changed
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
<!DOCTYPE html>
2+
<title>Element#requestFullscreen() consumes user activation</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script src="/resources/testdriver.js"></script>
6+
<script src="/resources/testdriver-vendor.js"></script>
7+
<div id="log"></div>
8+
<script>
9+
promise_test(async (t) => {
10+
t.add_cleanup(() => { document.exitFullscreen() });
11+
12+
const div = document.querySelector("div");
13+
14+
const promises = [];
15+
16+
await test_driver.bless("fullscreen", () => {
17+
// Request fullscreen twice in a row. The first request should consume the
18+
// user activation and succeed, and the second request should fail because
19+
// of the user activation requirement.
20+
const p1 = div.requestFullscreen();
21+
const p2 = div.requestFullscreen();
22+
promises.push(p1);
23+
promises.push(promise_rejects_js(t, TypeError, p2));
24+
});
25+
26+
await Promise.all(promises);
27+
});
28+
</script>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
<!DOCTYPE html>
2+
<title>Element#requestFullscreen() on the current fullscreen element</title>
3+
<script src="/resources/testharness.js"></script>
4+
<script src="/resources/testharnessreport.js"></script>
5+
<script src="/resources/testdriver.js"></script>
6+
<script src="/resources/testdriver-vendor.js"></script>
7+
<div id="log"></div>
8+
<script>
9+
promise_test(async (t) => {
10+
t.add_cleanup(() => { document.exitFullscreen() });
11+
12+
// Use the body element as the fullscreen element, because the second
13+
// test_driver.bless() call needs to insert a button inside of it, which
14+
// can't be clicked if another element is already fullscreen.
15+
const target = document.body;
16+
17+
// First enter fullscreen.
18+
await test_driver.bless("fullscreen", () => target.requestFullscreen());
19+
assert_equals(document.fullscreenElement, target, "fullscreen element after first request");
20+
21+
// Now request fullscreen again, which should be a no-op.
22+
await test_driver.bless("fullscreen", () => target.requestFullscreen());
23+
assert_equals(document.fullscreenElement, target, "fullscreen element after second request");
24+
});
25+
</script>

fullscreen/api/element-request-fullscreen-same-manual.html

Lines changed: 0 additions & 30 deletions
This file was deleted.

fullscreen/api/element-request-fullscreen-twice-manual.html

Lines changed: 0 additions & 27 deletions
This file was deleted.

fullscreen/api/element-request-fullscreen-twice-manual.tentative.html

Lines changed: 0 additions & 46 deletions
This file was deleted.

fullscreen/api/element-request-fullscreen-two-elements-manual.html

Lines changed: 0 additions & 37 deletions
This file was deleted.

fullscreen/api/element-request-fullscreen-two-elements-manual.tentative.html

Lines changed: 0 additions & 56 deletions
This file was deleted.

fullscreen/api/element-request-fullscreen-two-iframes-manual.html

Lines changed: 0 additions & 48 deletions
This file was deleted.

fullscreen/api/element-request-fullscreen-two-iframes-manual.tentative.html

Lines changed: 0 additions & 65 deletions
This file was deleted.

0 commit comments

Comments
 (0)