browser_test-content-chromeflags.js (1659B)
1 const TEST_PAGE = `data:text/html,<html><body><a href="about:blank" target="_blank">Test</a></body></html>`; 2 const { CHROME_ALL, CHROME_REMOTE_WINDOW, CHROME_FISSION_WINDOW } = 3 Ci.nsIWebBrowserChrome; 4 5 /** 6 * Tests that when we open new browser windows from content they 7 * get the full browser chrome. 8 */ 9 add_task(async function () { 10 // Make sure that the window.open call will open a new 11 // window instead of a new tab. 12 await new Promise(resolve => { 13 SpecialPowers.pushPrefEnv( 14 { 15 set: [ 16 ["test.wait300msAfterTabSwitch", true], 17 ["browser.link.open_newwindow", 2], 18 ], 19 }, 20 resolve 21 ); 22 }); 23 24 await BrowserTestUtils.withNewTab( 25 { 26 gBrowser, 27 url: TEST_PAGE, 28 }, 29 async function (browser) { 30 let openedPromise = BrowserTestUtils.waitForNewWindow(); 31 BrowserTestUtils.synthesizeMouse("a", 0, 0, {}, browser); 32 let win = await openedPromise; 33 34 let chromeFlags = win.docShell.treeOwner 35 .QueryInterface(Ci.nsIInterfaceRequestor) 36 .getInterface(Ci.nsIAppWindow).chromeFlags; 37 38 let expected = CHROME_ALL; 39 40 // In the multi-process tab case, the new window will have the 41 // CHROME_REMOTE_WINDOW flag set. 42 if (gMultiProcessBrowser) { 43 expected |= CHROME_REMOTE_WINDOW; 44 } 45 46 // In the multi-process subframe case, the new window will have the 47 // CHROME_FISSION_WINDOW flag set. 48 if (gFissionBrowser) { 49 expected |= CHROME_FISSION_WINDOW; 50 } 51 52 is(chromeFlags, expected, "Window should have opened with all chrome"); 53 54 await BrowserTestUtils.closeWindow(win); 55 } 56 ); 57 });