browser_window_close.js (1339B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 addRDMTask( 7 null, 8 async function () { 9 const NEW_WINDOW_URL = 10 "data:text/html;charset=utf-8,New window opened via window.open"; 11 const newWindowPromise = BrowserTestUtils.waitForNewWindow({ 12 // Passing the url param so the Promise will resolve once DOMContentLoaded is emitted 13 // on the new window tab 14 url: NEW_WINDOW_URL, 15 }); 16 window.open(NEW_WINDOW_URL, "_blank", "noopener,all"); 17 18 const newWindow = await newWindowPromise; 19 ok(true, "Got new window"); 20 21 info("Focus new window"); 22 newWindow.focus(); 23 24 info("Open RDM"); 25 const tab = newWindow.gBrowser.selectedTab; 26 const { ui } = await openRDM(tab); 27 await waitForDeviceAndViewportState(ui); 28 29 ok( 30 ResponsiveUIManager.isActiveForTab(tab), 31 "ResponsiveUI should be active for tab when the window is closed" 32 ); 33 34 // Close the window on a tab with an active responsive design UI and 35 // wait for the UI to gracefully shutdown. This has leaked the window 36 // in the past. 37 info("Close the new window"); 38 const offPromise = once(ResponsiveUIManager, "off"); 39 await BrowserTestUtils.closeWindow(newWindow); 40 await offPromise; 41 }, 42 { onlyPrefAndTask: true } 43 );