browser_toolbox_connecting_with_frozen_process.js (1529B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 "use strict"; 5 6 add_task(async function () { 7 const initialTab = BrowserTestUtils.addTab( 8 gBrowser, 9 "https://example.com/document-builder.sjs?html=test-devtools-hang" 10 ); 11 gBrowser.selectedTab = BrowserTestUtils.addTab( 12 gBrowser, 13 "https://example.net/document-builder.sjs?html=test-devtools-hang" 14 ); 15 isnot( 16 initialTab.linkedBrowser.browsingContext.currentWindowGlobal.osPid, 17 gBrowser.selectedBrowser.browsingContext.currentWindowGlobal.osPid, 18 "The two tabs are loaded in distinct processes" 19 ); 20 21 // Freeze the second tab 22 const slowScriptDone = SpecialPowers.spawn( 23 gBrowser.selectedBrowser, 24 [], 25 function () { 26 const start = Date.now(); 27 while (Date.now() < start + 4000) { 28 // block the tab for 4 seconds 29 } 30 } 31 ); 32 let resumed = false; 33 slowScriptDone.then(() => { 34 resumed = true; 35 }); 36 37 // Select the first tab while the second is freezing 38 gBrowser.selectedTab = initialTab; 39 40 // Try opening on the first tab, which isn't freezing 41 const toolbox = await gDevTools.showToolboxForTab(initialTab, { 42 toolId: "webconsole", 43 }); 44 ok(true, "Toolbox successfully opened despite frozen tab in background"); 45 is( 46 resumed, 47 false, 48 "The background tab is still frozen after opening devtools" 49 ); 50 await slowScriptDone; 51 is(resumed, true, "The background tab resumed its executions"); 52 await toolbox.closeToolbox(); 53 });