browser_tab_close.js (1392B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 // Verify RDM closes synchronously when tabs are closed. 7 8 const TEST_URL = "http://example.com/"; 9 10 addRDMTask( 11 null, 12 async function () { 13 const tab = await addTab(TEST_URL); 14 15 const { ui } = await openRDM(tab); 16 await waitForDeviceAndViewportState(ui); 17 const clientClosed = waitForClientClose(ui); 18 19 closeRDM(tab, { 20 reason: "TabClose", 21 }); 22 23 // This flag is set at the end of `ResponsiveUI.destroy`. If it is true 24 // without waiting for `closeRDM` above, then we must have closed 25 // synchronously. 26 is(ui.destroyed, true, "RDM closed synchronously"); 27 28 await clientClosed; 29 await removeTab(tab); 30 }, 31 { onlyPrefAndTask: true } 32 ); 33 34 addRDMTask( 35 null, 36 async function () { 37 const tab = await addTab(TEST_URL); 38 39 const { ui } = await openRDM(tab); 40 await waitForDeviceAndViewportState(ui); 41 const clientClosed = waitForClientClose(ui); 42 43 await removeTab(tab); 44 45 // This flag is set at the end of `ResponsiveUI.destroy`. If it is true without 46 // waiting for `closeRDM` itself and only removing the tab, then we must have closed 47 // synchronously in response to tab closing. 48 is(ui.destroyed, true, "RDM closed synchronously"); 49 50 await clientClosed; 51 }, 52 { onlyPrefAndTask: true } 53 );