OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <title>Document#exitFullscreen() timing</title> | 2 <title>Document#exitFullscreen() timing</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 <script> | 7 <script> |
8 async_test(t => { | 8 async_test(t => { |
9 const div = document.querySelector('div'); | 9 const div = document.querySelector('div'); |
10 trusted_request(div); | 10 trusted_request(t, div); |
11 | 11 |
12 document.onfullscreenchange = t.step_func(() => { | 12 document.onfullscreenchange = t.step_func(() => { |
13 // We are now in fullscreen. Exit again. | 13 // We are now in fullscreen. Exit again. |
14 assert_equals(document.fullscreenElement, div); | 14 assert_equals(document.fullscreenElement, div); |
15 document.exitFullscreen(); | 15 document.exitFullscreen(); |
16 | 16 |
17 // If fullscreenchange is an animation frame event, then animation frame | 17 // If fullscreenchange is an animation frame event, then animation frame |
18 // callbacks should be run after it is fired, before the timer callback. | 18 // callbacks should be run after it is fired, before the timer callback. |
19 // The resize event should fire before the fullscreenchange event. | 19 // The resize event should fire before the fullscreenchange event. |
20 const events = []; | 20 const events = []; |
21 const callback = t.step_func(event => { | 21 const callback = t.step_func(event => { |
22 events.push(event.type); | 22 events.push(event.type); |
23 if (event.type == 'fullscreenchange') { | 23 if (event.type == 'fullscreenchange') { |
24 setTimeout(t.unreached_func('timer callback')); | 24 setTimeout(t.unreached_func('timer callback')); |
25 requestAnimationFrame(t.step_func_done(() => { | 25 requestAnimationFrame(t.step_func_done(() => { |
26 assert_array_equals(events, ['resize', 'fullscreenchange'], 'event ord
er'); | 26 assert_array_equals(events, ['resize', 'fullscreenchange'], 'event ord
er'); |
27 })); | 27 })); |
28 } | 28 } |
29 }); | 29 }); |
30 document.onfullscreenchange = window.onresize = callback; | 30 document.onfullscreenchange = window.onresize = callback; |
31 }); | 31 }); |
32 }, 'Timing of fullscreenchange and resize events'); | 32 }, 'Timing of fullscreenchange and resize events'); |
33 </script> | 33 </script> |
OLD | NEW |