browser_browser_toolbox_print_preview.js (2157B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // There are shutdown issues for which multiple rejections are left uncaught. 5 // See bug 1018184 for resolving these issues. 6 const { PromiseTestUtils } = ChromeUtils.importESModule( 7 "resource://testing-common/PromiseTestUtils.sys.mjs" 8 ); 9 PromiseTestUtils.allowMatchingRejectionsGlobally(/File closed/); 10 11 Services.scriptloader.loadSubScript( 12 "chrome://mochitests/content/browser/devtools/client/inspector/test/shared-head.js", 13 this 14 ); 15 16 // On debug test machine, it takes about 50s to run the test. 17 requestLongerTimeout(4); 18 19 // Test that the MultiProcessBrowserToolbox can be opened when print preview is 20 // started, and can select elements in the print preview document. 21 add_task(async function () { 22 // Forces the Browser Toolbox to open on the inspector by default 23 await pushPref("devtools.browsertoolbox.panel", "inspector"); 24 25 // Enable Multiprocess Browser Toolbox 26 await pushPref("devtools.browsertoolbox.scope", "everything"); 27 28 // Open the tab *after* opening the Browser Toolbox in order to force creating the remote frames 29 // late and exercise frame target watching code. 30 await addTab(`data:text/html,<div id="test-div">PRINT PREVIEW TEST</div>`); 31 32 info("Start the print preview for the current tab"); 33 document.getElementById("cmd_print").doCommand(); 34 35 const ToolboxTask = await initBrowserToolboxTask(); 36 await ToolboxTask.importFunctions({ 37 getNodeFront, 38 getNodeFrontInFrames, 39 selectNode, 40 // selectNodeInFrames depends on selectNode, getNodeFront, getNodeFrontInFrames. 41 selectNodeInFrames, 42 }); 43 44 const hasCloseButton = await ToolboxTask.spawn(null, async () => { 45 /* global gToolbox */ 46 const inspector = gToolbox.getPanel("inspector"); 47 48 info("Select the #test-div element in the printpreview document"); 49 await selectNodeInFrames( 50 ['browser[printpreview="true"]', "#test-div"], 51 inspector 52 ); 53 return !!gToolbox.doc.getElementById("toolbox-close"); 54 }); 55 ok(!hasCloseButton, "Browser toolbox doesn't have a close button"); 56 57 await ToolboxTask.destroy(); 58 });