browser_new_activation_workflow.js (1832B)
1 /* Any copyright is dedicated to the Public Domain. 2 * http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 // Tests devtools API 5 6 var gToolbox; 7 8 function test() { 9 addTab("about:blank").then(async function () { 10 loadWebConsole().then(function () { 11 console.log("loaded"); 12 }); 13 }); 14 } 15 16 function loadWebConsole() { 17 ok(gDevTools, "gDevTools exists"); 18 const tab = gBrowser.selectedTab; 19 return gDevTools 20 .showToolboxForTab(tab, { toolId: "webconsole" }) 21 .then(function (toolbox) { 22 gToolbox = toolbox; 23 checkToolLoading(); 24 }); 25 } 26 27 function checkToolLoading() { 28 is(gToolbox.currentToolId, "webconsole", "The web console is selected"); 29 ok(gToolbox.isReady, "toolbox is ready"); 30 31 selectAndCheckById("jsdebugger").then(function () { 32 selectAndCheckById("styleeditor").then(function () { 33 testToggle(); 34 }); 35 }); 36 } 37 38 function selectAndCheckById(id) { 39 return gToolbox.selectTool(id).then(function () { 40 const tab = gToolbox.doc.getElementById("toolbox-tab-" + id); 41 is( 42 tab.classList.contains("selected"), 43 true, 44 "The " + id + " tab is selected" 45 ); 46 is( 47 tab.getAttribute("aria-pressed"), 48 "true", 49 "The " + id + " tab is pressed" 50 ); 51 }); 52 } 53 54 function testToggle() { 55 gToolbox.once("destroyed", async () => { 56 // Cannot reuse a target after it's destroyed. 57 gDevTools 58 .showToolboxForTab(gBrowser.selectedTab, { toolId: "styleeditor" }) 59 .then(function (toolbox) { 60 gToolbox = toolbox; 61 is( 62 gToolbox.currentToolId, 63 "styleeditor", 64 "The style editor is selected" 65 ); 66 finishUp(); 67 }); 68 }); 69 70 gToolbox.destroy(); 71 } 72 73 function finishUp() { 74 gToolbox.destroy().then(function () { 75 gToolbox = null; 76 gBrowser.removeCurrentTab(); 77 finish(); 78 }); 79 }