Bug 1800610 [wpt PR 36969] - Test that element.requestFullscreen() consumes user...
[gecko.git] / testing / web-platform / tests / fullscreen / api / element-request-fullscreen-same-element.html
bloba2b04dd173989b61a7423bba94fe4e49ba87ec2a
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(() => {
11 if (document.fullscreenElement) return document.exitFullscreen();
12 });
14 // Use the body element as the fullscreen element, because the second
15 // test_driver.bless() call needs to insert a button inside of it, which
16 // can't be clicked if another element is already fullscreen.
17 const target = document.body;
19 // First enter fullscreen.
20 await test_driver.bless("fullscreen", () => target.requestFullscreen());
21 assert_equals(document.fullscreenElement, target, "fullscreen element after first request");
23 // Now request fullscreen again, which should be a no-op.
24 await test_driver.bless("fullscreen", () => target.requestFullscreen());
25 assert_equals(document.fullscreenElement, target, "fullscreen element after second request");
26 });
27 </script>