Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(43)

Side by Side Diff: third_party/WebKit/LayoutTests/fullscreen/api/document-exit-fullscreen-vs-request.html

Issue 2573773002: Sync requestFullscreen() and exitFullscreen() algorithms with the spec (Closed)
Patch Set: address feedback Created 4 years ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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> 7 <div id="parent"><div><div></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;
13 15
14 document.onfullscreenchange = t.step_func(() => { 16 document.onfullscreenchange = t.step_func(() => {
15 // We are now in fullscreen, so exiting requires a resize but requesting 17 // We are now in fullscreen, so exiting requires a resize but requesting
16 // does not. 18 // does not.
17 assert_equals(document.fullscreenElement, parent, "fullscreenElement after f ullscreenchange event"); 19 assert_equals(document.fullscreenElement, parent, "fullscreenElement after f ullscreenchange event");
18 20
19 trusted_click(t.step_func(() => { 21 trusted_click(t.step_func(() => {
20 // Request fullscreen on another element, to avoid any synchronous 22 // Request fullscreen on another element, to avoid any synchronous
21 // short-circuiting on document.fullscreenElement.requestFullscreen(), 23 // short-circuiting on document.fullscreenElement.requestFullscreen(),
22 // which used to be in the spec. Also request both before and after the 24 // which used to be in the spec. Also request both before and after the
23 // exit. Both requests should be silently ignored due to the exit. 25 // exit. Both requests synchronously enqueue animation frame tasks. They
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.
24 29
25 let fullscreenchanges = 0; 30 let i = 0;
26 document.onfullscreenchange = t.step_func((event) => { 31 const expected = [child, grandChild, null];
27 assert_equals(document.fullscreenElement, child); 32 document.onfullscreenchange = t.step_func(() => {
28 fullscreenchanges++; 33 assert_equals(document.fullscreenElement, expected[i], "fullscreenElemen t when i=" + i);
29 if (fullscreenchanges == 3) 34 i++;
35 if (i == 3)
30 t.done(); 36 t.done();
31 }); 37 });
32 38
33 const child = parent.firstChild;
34 child.requestFullscreen(); 39 child.requestFullscreen();
35 assert_equals(document.fullscreenElement, child, "fullscreenElement after first requestFullscreen()"); 40 assert_equals(document.fullscreenElement, parent, "fullscreenElement after first requestFullscreen()");
36 document.exitFullscreen(); 41 document.exitFullscreen();
37 assert_equals(document.fullscreenElement, parent, "fullscreenElement after exitFullscreen()"); 42 assert_equals(document.fullscreenElement, parent, "fullscreenElement after exitFullscreen()");
38 child.requestFullscreen(); 43 grandChild.requestFullscreen();
39 assert_equals(document.fullscreenElement, child, "fullscreenElement after second requestFullscreen()"); 44 assert_equals(document.fullscreenElement, parent, "fullscreenElement after second requestFullscreen()");
40 }), parent); 45 }), parent);
41 }); 46 });
42 document.onfullscreenerror = t.unreached_func("fullscreenerror event"); 47 document.onfullscreenerror = t.unreached_func("fullscreenerror event");
43 48
44 trusted_request(parent); 49 trusted_request(parent);
45 }); 50 });
46 </script> 51 </script>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698