Skip to content

Commit ebc90b1

Browse files
mfreed7chromium-wpt-export-bot
authored andcommitted
Add a test for fullscreen for the A/B/A case
See the discussion at [1] for more context. This test requests fullscreen on A, then B, then A, where A and B are sibling divs. All three requests should succeed, but at the end, B should be left topmost (and the fullscreen element) but both A and B should be in the top layer. [1] whatwg/fullscreen#223 Change-Id: I3f35dda5b9eb1bc24201616bb5bb4949d20fd170
1 parent e643f91 commit ebc90b1

File tree

1 file changed

+63
-0
lines changed

1 file changed

+63
-0
lines changed
Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
<!DOCTYPE html>
2+
<title>Re-requesting fullscreen doesn't fail but doesn't change order</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+
<script src="../trusted-click.js"></script>
8+
9+
<div class="elements">
10+
<div id="A">Element A</div>
11+
<div id="B">Element B</div>
12+
</div>
13+
14+
<style>
15+
.elements>div {
16+
width:200px;
17+
height:200px;
18+
}
19+
#A { background: blue; }
20+
#B { background: green; }
21+
}
22+
</style>
23+
24+
<script>
25+
function isTopLayer(el) {
26+
return getComputedStyle(el, '::backdrop').right !== 'auto';
27+
}
28+
29+
promise_test(async (t) => {
30+
t.add_cleanup(async () => {
31+
if (document.fullscreenElement)
32+
await document.exitFullscreen();
33+
});
34+
document.onfullscreenerror = t.unreached_func('fullscreenerror should not happen');
35+
const A = document.getElementById('A');
36+
const B = document.getElementById('B');
37+
assert_true(!isTopLayer(A) && !isTopLayer(B));
38+
await trusted_click(document.body);
39+
await A.requestFullscreen();
40+
assert_equals(document.fullscreenElement,A,'first A request');
41+
assert_true(isTopLayer(A),'A top layer');
42+
await trusted_click(A);
43+
await B.requestFullscreen();
44+
assert_equals(document.fullscreenElement,B,'B request');
45+
assert_true(isTopLayer(B),'B top layer');
46+
assert_true(isTopLayer(A),'A still top layer');
47+
await trusted_click(B);
48+
await A.requestFullscreen();
49+
assert_true(isTopLayer(A),'A is still top layer');
50+
assert_true(isTopLayer(B),'B is still top layer');
51+
assert_equals(document.fullscreenElement,B,'B is still the fullscreen element');
52+
assert_equals(document.elementFromPoint(10,10),B,'B should be topmost');
53+
54+
await document.exitFullscreen();
55+
assert_equals(document.fullscreenElement,A,'A goes back to being the fullscreen element');
56+
assert_true(isTopLayer(A),'A is still top layer');
57+
assert_false(isTopLayer(B),'B is no longer top layer');
58+
await document.exitFullscreen();
59+
assert_equals(document.fullscreenElement,null,'Both closed');
60+
assert_false(isTopLayer(A),'A is no longer top layer');
61+
assert_false(isTopLayer(B),'B is no longer top layer');
62+
}, 'Requesting fullscreen on A, then B, then A doesn\'t throw, but leaves B topmost');
63+
</script>

0 commit comments

Comments
 (0)