browser_fullscreen_newwindow.js (2448B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // This test verifies that when in fullscreen mode, and a new window is opened, 7 // fullscreen mode should not exit and the url bar is focused. 8 add_task(async function test_fullscreen_new_window() { 9 await SpecialPowers.pushPrefEnv({ 10 set: [ 11 ["test.wait300msAfterTabSwitch", true], 12 ["full-screen-api.enabled", true], 13 ["full-screen-api.allow-trusted-requests-only", false], 14 ], 15 }); 16 17 let tab = await BrowserTestUtils.openNewForegroundTab( 18 gBrowser, 19 "https://example.org/browser/browser/base/content/test/fullscreen/fullscreen.html" 20 ); 21 22 let fullScreenEntered = BrowserTestUtils.waitForEvent( 23 document, 24 "fullscreenchange", 25 false, 26 () => document.fullscreenElement 27 ); 28 29 // Enter fullscreen. 30 await SpecialPowers.spawn(tab.linkedBrowser, [], async () => { 31 content.document.getElementById("request").click(); 32 }); 33 34 await fullScreenEntered; 35 36 // Open a new window via ctrl+n. 37 let newWindowPromise = BrowserTestUtils.waitForNewWindow({ 38 url: "about:blank", 39 }); 40 EventUtils.synthesizeKey("N", { accelKey: true }); 41 let newWindow = await newWindowPromise; 42 43 // Check new window state. 44 is( 45 newWindow.document.activeElement, 46 newWindow.gURLBar.inputField, 47 "url bar is focused after new window opened" 48 ); 49 ok( 50 !newWindow.fullScreen, 51 "The new chrome window should not be in fullscreen" 52 ); 53 ok( 54 !newWindow.document.documentElement.hasAttribute("inDOMFullscreen"), 55 "The new chrome document should not be in fullscreen" 56 ); 57 58 // Wait a bit then check the original window state. 59 await new Promise(resolve => TestUtils.executeSoon(resolve)); 60 ok( 61 window.fullScreen, 62 "The original chrome window should be still in fullscreen" 63 ); 64 ok( 65 document.documentElement.hasAttribute("inDOMFullscreen"), 66 "The original chrome document should be still in fullscreen" 67 ); 68 69 // Close new window and move focus back to original window. 70 await BrowserTestUtils.closeWindow(newWindow); 71 await SimpleTest.promiseFocus(window); 72 73 // Exit fullscreen on original window. 74 let fullScreenExited = BrowserTestUtils.waitForEvent( 75 document, 76 "fullscreenchange", 77 false, 78 () => !document.fullscreenElement 79 ); 80 EventUtils.synthesizeKey("KEY_Escape"); 81 await fullScreenExited; 82 83 BrowserTestUtils.removeTab(tab); 84 });