browser_fullscreen_window_open.js (2948B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 SimpleTest.requestLongerTimeout(2); 7 8 const IFRAME_ID = "testIframe"; 9 10 async function testWindowOpen(iframeID) { 11 let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL); 12 info("Entering full-screen"); 13 await DOMFullscreenTestUtils.changeFullscreen(tab.linkedBrowser, true); 14 15 let popup; 16 await testExpectFullScreenExit(tab.linkedBrowser, true, async () => { 17 info("Calling window.open()"); 18 popup = await jsWindowOpen(tab.linkedBrowser, true, iframeID); 19 }); 20 21 // Cleanup 22 await BrowserTestUtils.closeWindow(popup); 23 BrowserTestUtils.removeTab(tab); 24 } 25 26 async function testWindowOpenExistingWindow(funToOpenExitingWindow, iframeID) { 27 let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, TEST_URL); 28 let popup = await jsWindowOpen(tab.linkedBrowser, true); 29 30 info("re-focusing main window"); 31 await waitForFocus(tab.linkedBrowser); 32 33 info("Entering full-screen"); 34 await DOMFullscreenTestUtils.changeFullscreen(tab.linkedBrowser, true); 35 36 info("open existing popup window"); 37 await testExpectFullScreenExit(tab.linkedBrowser, true, async () => { 38 await funToOpenExitingWindow(tab.linkedBrowser, iframeID); 39 }); 40 41 // Cleanup 42 await BrowserTestUtils.closeWindow(popup); 43 BrowserTestUtils.removeTab(tab); 44 } 45 46 add_setup(async function () { 47 await SpecialPowers.pushPrefEnv({ 48 set: [ 49 ["test.wait300msAfterTabSwitch", true], 50 ["dom.disable_open_during_load", false], // Allow window.open calls without user interaction 51 ["browser.link.open_newwindow.disabled_in_fullscreen", false], 52 ], 53 }); 54 }); 55 56 add_task(function test_parentWindowOpen() { 57 return testWindowOpen(); 58 }); 59 60 add_task(function test_iframeWindowOpen() { 61 return testWindowOpen(IFRAME_ID); 62 }); 63 64 add_task(async function test_parentWindowOpenExistWindow() { 65 await testWindowOpenExistingWindow(browser => { 66 info( 67 "Calling window.open() with same name again should reuse the existing window" 68 ); 69 jsWindowOpen(browser, true); 70 }); 71 }); 72 73 add_task(async function test_iframeWindowOpenExistWindow() { 74 await testWindowOpenExistingWindow((browser, iframeID) => { 75 info( 76 "Calling window.open() with same name again should reuse the existing window" 77 ); 78 jsWindowOpen(browser, true, iframeID); 79 }, IFRAME_ID); 80 }); 81 82 add_task(async function test_parentWindowClickLinkOpenExistWindow() { 83 await testWindowOpenExistingWindow(browser => { 84 info( 85 "Clicking link with same target name should reuse the existing window" 86 ); 87 jsClickLink(browser, true); 88 }); 89 }); 90 91 add_task(async function test_iframeWindowClickLinkOpenExistWindow() { 92 await testWindowOpenExistingWindow((browser, iframeID) => { 93 info( 94 "Clicking link with same target name should reuse the existing window" 95 ); 96 jsClickLink(browser, true, iframeID); 97 }, IFRAME_ID); 98 });