browser_alert_from_about_blank.js (2056B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_setup(async function () { 7 await SpecialPowers.pushPrefEnv({ 8 set: [["test.wait300msAfterTabSwitch", true]], 9 }); 10 }); 11 12 add_task(async function test_check_alert_from_blank() { 13 await BrowserTestUtils.withNewTab( 14 "https://example.com/blank", 15 async browser => { 16 await SpecialPowers.spawn(browser, [], () => { 17 let button = content.document.createElement("button"); 18 button.addEventListener("click", () => { 19 info("Button onclick: opening about:blank"); 20 let newWin = content.open( 21 "about:blank", 22 "", 23 "popup,width=600,height=600" 24 ); 25 // Start an async navigation that will close the alert 26 // Previously this wasn't needed as the initial about:blank 27 // was followed by an async about:blank load. See Bug 543435 28 newWin.location = "about:blank?0"; 29 newWin.alert("Alert from the popup."); 30 info("Button onclick: finished"); 31 }); 32 content.document.body.append(button); 33 info( 34 "Added alert-from-about-blank-popup trigger button to " + 35 content.document.location.href 36 ); 37 }); 38 39 let newWinPromise = BrowserTestUtils.waitForNewWindow(); 40 await BrowserTestUtils.synthesizeMouseAtCenter("button", {}, browser); 41 42 // otherWin is the same as newWin 43 let otherWin = await newWinPromise; 44 45 Assert.equal( 46 otherWin.gBrowser.currentURI?.spec, 47 "about:blank", 48 "Should have opened about:blank" 49 ); 50 Assert.equal( 51 otherWin.menubar.visible, 52 false, 53 "Should be a popup window." 54 ); 55 let contentDialogManager = gBrowser 56 .getTabDialogBox(gBrowser.selectedBrowser) 57 .getContentDialogManager(); 58 todo_is(contentDialogManager._dialogs.length, 1, "Should have 1 dialog."); 59 await BrowserTestUtils.closeWindow(otherWin); 60 } 61 ); 62 });