file_fullscreen-focus.html (1547B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 5 Test that a fullscreen request fails if the window is not focused. 6 7 Open window1, open window2, focus window2, and then attempt to fullscreen 8 window1 while it is not focused. The fullscreen attempt should be rejected 9 because the window is not focused. 10 11 --> 12 <head> 13 <title>Test fullscreen request is blocked when window is not focused</title> 14 <script src="/tests/SimpleTest/EventUtils.js"></script> 15 <script src="/tests/SimpleTest/SimpleTest.js"></script> 16 <script type="application/javascript" src="file_fullscreen-utils.js"></script> 17 </head> 18 <body> 19 20 <script type="application/javascript"> 21 22 function ok(condition, msg) { 23 opener.ok(condition, "[focus] " + msg); 24 } 25 26 var window1, window2; 27 28 function openWindow() { 29 var w = window.open("file_fullscreen-focus-inner.html", "", 30 "width=500,height=500"); 31 return w; 32 } 33 34 function begin() { 35 window1 = openWindow(); 36 window1.focus(); 37 38 SimpleTest.waitForFocus(function(){ 39 window2 = openWindow(); 40 window2.focus(); 41 42 SimpleTest.waitForFocus(function(){ 43 // Now that window2 is focused, attempt to fullscreen window1. 44 // This should fail. 45 window1.enterFullscreen("one"); 46 }, window2); 47 48 }, window1); 49 } 50 51 async function enteredFullscreen(enteredSuccessfully) { 52 ok(!enteredSuccessfully, "window1 did not enter fullscreen"); 53 54 if (enteredSuccessfully) { 55 await window1.document.exitFullscreen() 56 } 57 58 window1.close(); 59 window2.close(); 60 opener.nextTest(); 61 } 62 63 </script> 64 </pre> 65 <div id="full-screen-element"></div> 66 </body> 67 </html>