OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Document#exitFullscreen() vs. Element#requestFullscreen()</title> | 2 <title>Document#exitFullscreen() vs. Element#requestFullscreen()</title> |
3 <script src="../../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <script src="../trusted-click.js"></script> | 5 <script src="../trusted-click.js"></script> |
6 <div id="log"></div> | 6 <div id="log"></div> |
7 <div id="parent"><div><div></div></div></div> | 7 <div id="parent"><div></div></div> |
8 <script> | 8 <script> |
9 // Adapted from https://github.com/w3c/web-platform-tests/pull/4250 | 9 // Adapted from https://github.com/w3c/web-platform-tests/pull/4250 |
10 // TODO(foolip): Remove this test when the above is imported and passing. | 10 // TODO(foolip): Remove this test when the above is imported and passing. |
11 async_test(t => { | 11 async_test(t => { |
12 const parent = document.getElementById("parent"); | 12 const parent = document.getElementById("parent"); |
13 const child = parent.firstChild; | |
14 const grandChild = child.firstChild; | |
15 | 13 |
16 document.onfullscreenchange = t.step_func(() => { | 14 document.onfullscreenchange = t.step_func(() => { |
17 // We are now in fullscreen, so exiting requires a resize but requesting | 15 // We are now in fullscreen, so exiting requires a resize but requesting |
18 // does not. | 16 // does not. |
19 assert_equals(document.fullscreenElement, parent, "fullscreenElement after f
ullscreenchange event"); | 17 assert_equals(document.fullscreenElement, parent, "fullscreenElement after f
ullscreenchange event"); |
20 | 18 |
21 trusted_click(t.step_func(() => { | 19 trusted_click(t.step_func(() => { |
22 // Request fullscreen on another element, to avoid any synchronous | 20 // Request fullscreen on another element, to avoid any synchronous |
23 // short-circuiting on document.fullscreenElement.requestFullscreen(), | 21 // short-circuiting on document.fullscreenElement.requestFullscreen(), |
24 // which used to be in the spec. Also request both before and after the | 22 // which used to be in the spec. Also request both before and after the |
25 // exit. Both requests synchronously enqueue animation frame tasks. They | 23 // exit. Both requests should be silently ignored due to the exit. |
26 // may run after exiting, but still before the animation frame task for | |
27 // the exit, and so both will succeed, and there will be 3 | |
28 // fullscreenchange events, but not matching the order of the calls. | |
29 | 24 |
30 let i = 0; | 25 let fullscreenchanges = 0; |
31 const expected = [child, grandChild, null]; | 26 document.onfullscreenchange = t.step_func((event) => { |
32 document.onfullscreenchange = t.step_func(() => { | 27 assert_equals(document.fullscreenElement, child); |
33 assert_equals(document.fullscreenElement, expected[i], "fullscreenElemen
t when i=" + i); | 28 fullscreenchanges++; |
34 i++; | 29 if (fullscreenchanges == 3) |
35 if (i == 3) | |
36 t.done(); | 30 t.done(); |
37 }); | 31 }); |
38 | 32 |
| 33 const child = parent.firstChild; |
39 child.requestFullscreen(); | 34 child.requestFullscreen(); |
40 assert_equals(document.fullscreenElement, parent, "fullscreenElement after
first requestFullscreen()"); | 35 assert_equals(document.fullscreenElement, child, "fullscreenElement after
first requestFullscreen()"); |
41 document.exitFullscreen(); | 36 document.exitFullscreen(); |
42 assert_equals(document.fullscreenElement, parent, "fullscreenElement after
exitFullscreen()"); | 37 assert_equals(document.fullscreenElement, parent, "fullscreenElement after
exitFullscreen()"); |
43 grandChild.requestFullscreen(); | 38 child.requestFullscreen(); |
44 assert_equals(document.fullscreenElement, parent, "fullscreenElement after
second requestFullscreen()"); | 39 assert_equals(document.fullscreenElement, child, "fullscreenElement after
second requestFullscreen()"); |
45 }), parent); | 40 }), parent); |
46 }); | 41 }); |
47 document.onfullscreenerror = t.unreached_func("fullscreenerror event"); | 42 document.onfullscreenerror = t.unreached_func("fullscreenerror event"); |
48 | 43 |
49 trusted_request(parent); | 44 trusted_request(parent); |
50 }); | 45 }); |
51 </script> | 46 </script> |
OLD | NEW |