1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/framework/test/browser_new_activation_workflow.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,71 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + * http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Tests devtools API 1.8 + 1.9 +const Cu = Components.utils; 1.10 + 1.11 +let toolbox, target; 1.12 + 1.13 +let tempScope = {}; 1.14 + 1.15 +function test() { 1.16 + addTab("about:blank", function(aBrowser, aTab) { 1.17 + target = TargetFactory.forTab(gBrowser.selectedTab); 1.18 + loadWebConsole(aTab).then(function() { 1.19 + console.log('loaded'); 1.20 + }, console.error); 1.21 + }); 1.22 +} 1.23 + 1.24 +function loadWebConsole(aTab) { 1.25 + ok(gDevTools, "gDevTools exists"); 1.26 + 1.27 + return gDevTools.showToolbox(target, "webconsole").then(function(aToolbox) { 1.28 + toolbox = aToolbox; 1.29 + checkToolLoading(); 1.30 + }, console.error); 1.31 +} 1.32 + 1.33 +function checkToolLoading() { 1.34 + is(toolbox.currentToolId, "webconsole", "The web console is selected"); 1.35 + ok(toolbox.isReady, "toolbox is ready") 1.36 + 1.37 + selectAndCheckById("jsdebugger").then(function() { 1.38 + selectAndCheckById("styleeditor").then(function() { 1.39 + testToggle(); 1.40 + }); 1.41 + }, console.error); 1.42 +} 1.43 + 1.44 +function selectAndCheckById(id) { 1.45 + let doc = toolbox.frame.contentDocument; 1.46 + 1.47 + return toolbox.selectTool(id).then(function() { 1.48 + let tab = doc.getElementById("toolbox-tab-" + id); 1.49 + is(tab.hasAttribute("selected"), true, "The " + id + " tab is selected"); 1.50 + }); 1.51 +} 1.52 + 1.53 +function testToggle() { 1.54 + toolbox.once("destroyed", function() { 1.55 + // Cannot reuse a target after it's destroyed. 1.56 + target = TargetFactory.forTab(gBrowser.selectedTab); 1.57 + gDevTools.showToolbox(target, "styleeditor").then(function(aToolbox) { 1.58 + toolbox = aToolbox; 1.59 + is(toolbox.currentToolId, "styleeditor", "The style editor is selected"); 1.60 + finishUp(); 1.61 + }); 1.62 + }.bind(this)); 1.63 + 1.64 + toolbox.destroy(); 1.65 +} 1.66 + 1.67 +function finishUp() { 1.68 + toolbox.destroy().then(function() { 1.69 + toolbox = null; 1.70 + target = null; 1.71 + gBrowser.removeCurrentTab(); 1.72 + finish(); 1.73 + }); 1.74 +}