--- a/addon-sdk/source/test/test-dev-panel.js
+++ b/addon-sdk/source/test/test-dev-panel.js
@@ -22,21 +22,23 @@ const iconURI = "data:image/png;base64,i
const makeHTML = fn =>
"data:text/html;charset=utf-8,<script>(" + fn + ")();</script>";
const test = function(unit) {
return function*(assert) {
assert.isRendered = (panel, toolbox) => {
const doc = toolbox.doc;
- assert.ok(doc.querySelector("[value='" + panel.label + "']"),
- "panel.label is found in the developer toolbox DOM");
- assert.ok(doc.querySelector("[tooltiptext='" + panel.tooltip + "']"),
- "panel.tooltip is found in the developer toolbox DOM");
-
+ assert.ok(Array.from(doc.querySelectorAll(".devtools-tab"))
+ .find(el => el.textContent === panel.label),
+ "panel.label is found in the developer toolbox DOM " + panel.label);
+ if (panel.tooltip) {
+ assert.ok(doc.querySelector("[title='" + panel.tooltip + "']"),
+ `panel.tooltip is found in the developer toolbox DOM "${panel.tooltip}"`);
+ }
assert.ok(doc.querySelector("#toolbox-panel-" + panel.id),
"toolbar panel with a matching id is present");
};
yield* unit(assert);
};
};
--- a/devtools/client/debugger/test/mochitest/browser_dbg_addon-panels.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_addon-panels.js
@@ -12,38 +12,38 @@ const ADDON_PATH = "addon3.xpi";
var gAddon, gClient, gThreadClient, gDebugger, gSources;
var PREFS = [
["devtools.canvasdebugger.enabled", true],
["devtools.shadereditor.enabled", true],
["devtools.performance.enabled", true],
["devtools.netmonitor.enabled", true],
["devtools.scratchpad.enabled", true]
];
+
function test() {
Task.spawn(function* () {
// Store and enable all optional dev tools panels
yield pushPrefs(...PREFS);
let addon = yield addTemporaryAddon(ADDON_PATH);
let addonDebugger = yield initAddonDebugger(ADDON_ID);
// Check only valid tabs are shown
- let tabs = addonDebugger.frame.contentDocument.getElementById("toolbox-tabs").children;
+ let tabs = addonDebugger.frame.contentDocument.querySelectorAll(".toolbox-tabs button")
+
let expectedTabs = ["webconsole", "jsdebugger", "scratchpad"];
is(tabs.length, expectedTabs.length, "displaying only " + expectedTabs.length + " tabs in addon debugger");
Array.forEach(tabs, (tab, i) => {
let toolName = expectedTabs[i];
- is(tab.getAttribute("toolid"), toolName, "displaying " + toolName);
+ is(tab.getAttribute("data-id"), toolName, "displaying " + toolName);
});
// Check no toolbox buttons are shown
- let buttons = addonDebugger.frame.contentDocument.getElementById("toolbox-buttons").children;
- Array.forEach(buttons, (btn, i) => {
- is(btn.hidden, true, "no toolbox buttons for the addon debugger -- " + btn.className);
- });
+ let buttons = addonDebugger.frame.contentDocument.querySelectorAll("#toolbox-buttons-end button");
+ is(buttons.length, 0, "no toolbox buttons for the addon debugger");
yield addonDebugger.destroy();
yield removeAddon(addon);
finish();
});
}
--- a/devtools/client/debugger/test/mochitest/browser_dbg_on-pause-highlight.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_on-pause-highlight.js
@@ -30,28 +30,24 @@ function test() {
}
function testPause() {
is(gDebugger.gThreadClient.paused, false,
"Should be running after starting test.");
gDebugger.gThreadClient.addOneTimeListener("paused", () => {
gToolbox.selectTool("webconsole").then(() => {
- ok(gToolboxTab.hasAttribute("highlighted") &&
- gToolboxTab.getAttribute("highlighted") == "true",
+ ok(gToolboxTab.classList.contains("highlighted"),
"The highlighted class is present");
- ok(!gToolboxTab.hasAttribute("selected") ||
- gToolboxTab.getAttribute("selected") != "true",
+ ok(!gToolboxTab.classList.contains("selected"),
"The tab is not selected");
}).then(() => gToolbox.selectTool("jsdebugger")).then(() => {
- ok(gToolboxTab.hasAttribute("highlighted") &&
- gToolboxTab.getAttribute("highlighted") == "true",
+ ok(gToolboxTab.classList.contains("highlighted"),
"The highlighted class is present");
- ok(gToolboxTab.hasAttribute("selected") &&
- gToolboxTab.getAttribute("selected") == "true",
+ ok(gToolboxTab.classList.contains("selected"),
"...and the tab is selected, so the glow will not be present.");
}).then(testResume);
});
EventUtils.sendMouseEvent({ type: "mousedown" },
gDebugger.document.getElementById("resume"),
gDebugger);
@@ -61,18 +57,17 @@ function testPause() {
});
}
function testResume() {
gDebugger.gThreadClient.addOneTimeListener("resumed", () => {
gToolbox.selectTool("webconsole").then(() => {
ok(!gToolboxTab.classList.contains("highlighted"),
"The highlighted class is not present now after the resume");
- ok(!gToolboxTab.hasAttribute("selected") ||
- gToolboxTab.getAttribute("selected") != "true",
+ ok(!gToolboxTab.classList.contains("selected"),
"The tab is not selected");
}).then(() => closeDebuggerAndFinish(gPanel));
});
EventUtils.sendMouseEvent({ type: "mousedown" },
gDebugger.document.getElementById("resume"),
gDebugger);
}
--- a/devtools/client/debugger/test/mochitest/browser_dbg_on-pause-raise.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_on-pause-raise.js
@@ -74,46 +74,40 @@ add_task(function *() {
yield onTabSelect;
if (toolbox.hostType != Toolbox.HostType.WINDOW) {
is(gBrowser.selectedTab, tab,
"Debugger's tab got selected.");
}
yield toolbox.selectTool("webconsole");
- ok(toolboxTab.hasAttribute("highlighted") &&
- toolboxTab.getAttribute("highlighted") == "true",
+ ok(toolboxTab.classList.contains("highlighted"),
"The highlighted class is present");
- ok(!toolboxTab.hasAttribute("selected") ||
- toolboxTab.getAttribute("selected") != "true",
+ ok(!toolboxTab.classList.contains("selected"),
"The tab is not selected");
yield toolbox.selectTool("jsdebugger");
- ok(toolboxTab.hasAttribute("highlighted") &&
- toolboxTab.getAttribute("highlighted") == "true",
+ ok(toolboxTab.classList.contains("highlighted"),
"The highlighted class is present");
- ok(toolboxTab.hasAttribute("selected") &&
- toolboxTab.getAttribute("selected") == "true",
+ ok(toolboxTab.classList.contains("selected"),
"...and the tab is selected, so the glow will not be present.");
}
function* testResume() {
let onPaused = waitForEvent(panelWin.gThreadClient, "resumed");
EventUtils.sendMouseEvent({ type: "mousedown" },
panelWin.document.getElementById("resume"),
panelWin);
yield onPaused;
yield toolbox.selectTool("webconsole");
- ok(!toolboxTab.hasAttribute("highlighted") ||
- toolboxTab.getAttribute("highlighted") != "true",
+ ok(!toolboxTab.classList.contains("highlighted"),
"The highlighted class is not present now after the resume");
- ok(!toolboxTab.hasAttribute("selected") ||
- toolboxTab.getAttribute("selected") != "true",
+ ok(!toolboxTab.classList.contains("selected"),
"The tab is not selected");
}
});
registerCleanupFunction(function () {
// Revert to the default toolbox host, so that the following tests proceed
// normally and not inside a non-default host.
Services.prefs.setCharPref("devtools.toolbox.host", Toolbox.HostType.BOTTOM);
--- a/devtools/client/debugger/test/mochitest/browser_dbg_worker-window.js
+++ b/devtools/client/debugger/test/mochitest/browser_dbg_worker-window.js
@@ -43,17 +43,17 @@ add_task(function* () {
done();
}
});
});
ok(toolbox.win.parent.document.title.includes(WORKER_URL),
"worker URL in host title");
let toolTabs = toolbox.doc.querySelectorAll(".devtools-tab");
- let activeTools = [...toolTabs].map(tab=>tab.getAttribute("toolid"));
+ let activeTools = [...toolTabs].map(tab=>tab.getAttribute("data-id"));
is(activeTools.join(","), "webconsole,jsdebugger,scratchpad,options",
"Correct set of tools supported by worker");
terminateWorkerInTab(tab, WORKER_URL);
yield waitForWorkerClose(workerClient);
yield close(client);
--- a/devtools/client/framework/test/browser_devtools_api.js
+++ b/devtools/client/framework/test/browser_devtools_api.js
@@ -147,21 +147,23 @@ function runTests2() {
continueTests(toolbox);
});
}
var continueTests = Task.async(function* (toolbox, panel) {
ok(toolbox.getCurrentPanel(), "panel value is correct");
is(toolbox.currentToolId, toolId2, "toolbox _currentToolId is correct");
- ok(!toolbox.doc.getElementById("toolbox-tab-" + toolId2).hasAttribute("icon-invertable"),
- "The tool tab does not have the invertable attribute");
+ ok(!toolbox.doc.getElementById("toolbox-tab-" + toolId2)
+ .classList.contains("icon-invertable"),
+ "The tool tab does not have the invertable class");
- ok(toolbox.doc.getElementById("toolbox-tab-inspector").hasAttribute("icon-invertable"),
- "The builtin tool tabs do have the invertable attribute");
+ ok(toolbox.doc.getElementById("toolbox-tab-inspector")
+ .classList.contains("icon-invertable"),
+ "The builtin tool tabs do have the invertable class");
let toolDefinitions = gDevTools.getToolDefinitionMap();
ok(toolDefinitions.has(toolId2), "The tool is in gDevTools");
let toolDefinition = toolDefinitions.get(toolId2);
is(toolDefinition.id, toolId2, "toolDefinition id is correct");
info("Testing toolbox tool-unregistered event");
--- a/devtools/client/framework/test/browser_new_activation_workflow.js
+++ b/devtools/client/framework/test/browser_new_activation_workflow.js
@@ -36,17 +36,17 @@ function checkToolLoading() {
testToggle();
});
});
}
function selectAndCheckById(id) {
return toolbox.selectTool(id).then(function () {
let tab = toolbox.doc.getElementById("toolbox-tab-" + id);
- is(tab.hasAttribute("selected"), true, "The " + id + " tab is selected");
+ is(tab.classList.contains("selected"), true, "The " + id + " tab is selected");
});
}
function testToggle() {
toolbox.once("destroyed", () => {
// Cannot reuse a target after it's destroyed.
target = TargetFactory.forTab(gBrowser.selectedTab);
gDevTools.showToolbox(target, "styleeditor").then(function (aToolbox) {
--- a/devtools/client/framework/test/browser_toolbox_dynamic_registration.js
+++ b/devtools/client/framework/test/browser_toolbox_dynamic_registration.js
@@ -92,13 +92,14 @@ function toolUnregistered(event, toolId)
ok(!menuitem, "menu item removed from every browser window");
}
cleanup();
}
function cleanup()
{
- toolbox.destroy();
- toolbox = null;
- gBrowser.removeCurrentTab();
- finish();
+ toolbox.destroy().then(() => {;
+ toolbox = null;
+ gBrowser.removeCurrentTab();
+ finish();
+ })
}
--- a/devtools/client/framework/test/browser_toolbox_highlight.js
+++ b/devtools/client/framework/test/browser_toolbox_highlight.js
@@ -3,79 +3,83 @@
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
var {Toolbox} = require("devtools/client/framework/toolbox");
var toolbox = null;
function test() {
- const URL = "data:text/plain;charset=UTF-8,Nothing to see here, move along";
+ Task.spawn(function* () {
+ const URL = "data:text/plain;charset=UTF-8,Nothing to see here, move along";
- const TOOL_ID_1 = "jsdebugger";
- const TOOL_ID_2 = "webconsole";
+ const TOOL_ID_1 = "jsdebugger";
+ const TOOL_ID_2 = "webconsole";
+ yield addTab(URL);
+
+ const target = TargetFactory.forTab(gBrowser.selectedTab);
+ toolbox = yield gDevTools.showToolbox(target, TOOL_ID_1, Toolbox.HostType.BOTTOM)
- addTab(URL).then(() => {
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- gDevTools.showToolbox(target, TOOL_ID_1, Toolbox.HostType.BOTTOM)
- .then(aToolbox => {
- toolbox = aToolbox;
- // select tool 2
- toolbox.selectTool(TOOL_ID_2)
- // and highlight the first one
- .then(highlightTab.bind(null, TOOL_ID_1))
- // to see if it has the proper class.
- .then(checkHighlighted.bind(null, TOOL_ID_1))
- // Now switch back to first tool
- .then(() => toolbox.selectTool(TOOL_ID_1))
- // to check again. But there is no easy way to test if
- // it is showing orange or not.
- .then(checkNoHighlightWhenSelected.bind(null, TOOL_ID_1))
- // Switch to tool 2 again
- .then(() => toolbox.selectTool(TOOL_ID_2))
- // and check again.
- .then(checkHighlighted.bind(null, TOOL_ID_1))
- // Now unhighlight the tool
- .then(unhighlightTab.bind(null, TOOL_ID_1))
- // to see the classes gone.
- .then(checkNoHighlight.bind(null, TOOL_ID_1))
- // Now close the toolbox and exit.
- .then(() => executeSoon(() => {
- toolbox.destroy()
- .then(() => {
- toolbox = null;
- gBrowser.removeCurrentTab();
- finish();
- });
- }));
- });
+ // select tool 2
+ yield toolbox.selectTool(TOOL_ID_2)
+ // and highlight the first one
+ yield highlightTab(TOOL_ID_1);
+ // to see if it has the proper class.
+ yield checkHighlighted(TOOL_ID_1);
+ // Now switch back to first tool
+ yield toolbox.selectTool(TOOL_ID_1);
+ // to check again. But there is no easy way to test if
+ // it is showing orange or not.
+ yield checkNoHighlightWhenSelected(TOOL_ID_1);
+ // Switch to tool 2 again
+ yield toolbox.selectTool(TOOL_ID_2);
+ // and check again.
+ yield checkHighlighted(TOOL_ID_1);
+ // Now unhighlight the tool
+ yield unhighlightTab(TOOL_ID_1);
+ // to see the classes gone.
+ yield checkNoHighlight(TOOL_ID_1);
+
+ // Now close the toolbox and exit.
+ executeSoon(() => {
+ toolbox.destroy().then(() => {
+ toolbox = null;
+ gBrowser.removeCurrentTab();
+ finish();
+ });
+ });
+ })
+ .catch(error => {
+ ok(false, "There was an error running the test.");
});
}
function highlightTab(toolId) {
- info("Highlighting tool " + toolId + "'s tab.");
- toolbox.highlightTool(toolId);
+ info(`Highlighting tool ${toolId}'s tab.`);
+ return toolbox.highlightTool(toolId);
}
function unhighlightTab(toolId) {
- info("Unhighlighting tool " + toolId + "'s tab.");
- toolbox.unhighlightTool(toolId);
+ info(`Unhighlighting tool ${toolId}'s tab.`);
+ return toolbox.unhighlightTool(toolId);
}
function checkHighlighted(toolId) {
let tab = toolbox.doc.getElementById("toolbox-tab-" + toolId);
- ok(tab.hasAttribute("highlighted"), "The highlighted attribute is present");
- ok(!tab.hasAttribute("selected") || tab.getAttribute("selected") != "true",
- "The tab is not selected");
+ ok(tab.classList.contains("highlighted"),
+ `The highlighted class is present in ${toolId}.`);
+ ok(!tab.classList.contains("selected"),
+ `The tab is not selected in ${toolId}`);
}
function checkNoHighlightWhenSelected(toolId) {
let tab = toolbox.doc.getElementById("toolbox-tab-" + toolId);
- ok(tab.hasAttribute("highlighted"), "The highlighted attribute is present");
- ok(tab.hasAttribute("selected") && tab.getAttribute("selected") == "true",
- "and the tab is selected, so the orange glow will not be present.");
+ ok(tab.classList.contains("highlighted"),
+ `The highlighted class is present in ${toolId}`);
+ ok(tab.classList.contains("selected"),
+ `And the tab is selected, so the orange glow will not be present. in ${toolId}`);
}
function checkNoHighlight(toolId) {
let tab = toolbox.doc.getElementById("toolbox-tab-" + toolId);
- ok(!tab.hasAttribute("highlighted"),
- "The highlighted attribute is not present");
+ ok(!tab.classList.contains("highlighted"),
+ `The highlighted class is not present in ${toolId}`);
}
--- a/devtools/client/framework/test/browser_toolbox_hosts.js
+++ b/devtools/client/framework/test/browser_toolbox_hosts.js
@@ -129,11 +129,11 @@ function* testPreviousHost() {
info("Forcing the previous host to match the current (side)");
Services.prefs.setCharPref("devtools.toolbox.previousHost", SIDE);
info("Switching from side to bottom (since previous=current=side");
yield toolbox.switchToPreviousHost();
checkHostType(toolbox, BOTTOM, SIDE);
}
function checkToolboxLoaded(iframe) {
- let tabs = iframe.contentDocument.getElementById("toolbox-tabs");
+ let tabs = iframe.contentDocument.querySelector(".toolbox-tabs");
ok(tabs, "toolbox UI has been loaded into iframe");
}
--- a/devtools/client/framework/test/browser_toolbox_options.js
+++ b/devtools/client/framework/test/browser_toolbox_options.js
@@ -288,32 +288,18 @@ function checkUnregistered(toolId, defer
}
deferred.resolve();
}
function checkRegistered(toolId, deferred, event, data) {
if (data == toolId) {
ok(true, "Correct tool added back");
// checking tab on the toolbox
- let radio = doc.getElementById("toolbox-tab-" + toolId);
- ok(radio, "Tab added back for " + toolId);
- if (radio.previousSibling) {
- ok(+radio.getAttribute("ordinal") >=
- +radio.previousSibling.getAttribute("ordinal"),
- "Inserted tab's ordinal is greater than equal to its previous tab." +
- "Expected " + radio.getAttribute("ordinal") + " >= " +
- radio.previousSibling.getAttribute("ordinal"));
- }
- if (radio.nextSibling) {
- ok(+radio.getAttribute("ordinal") <
- +radio.nextSibling.getAttribute("ordinal"),
- "Inserted tab's ordinal is less than its next tab. Expected " +
- radio.getAttribute("ordinal") + " < " +
- radio.nextSibling.getAttribute("ordinal"));
- }
+ let button = doc.getElementById("toolbox-tab-" + toolId);
+ ok(button, "Tab added back for " + toolId);
} else {
ok(false, "Something went wrong, " + toolId + " was not registered");
}
deferred.resolve();
}
function GetPref(name) {
let type = Services.prefs.getPrefType(name);
--- a/devtools/client/framework/test/browser_toolbox_options_disable_buttons.js
+++ b/devtools/client/framework/test/browser_toolbox_options_disable_buttons.js
@@ -55,82 +55,83 @@ function testSelectTool(devtoolsToolbox)
return deferred.promise;
}
function testPreferenceAndUIStateIsConsistent() {
let checkNodes = [...panelWin.document.querySelectorAll(
"#enabled-toolbox-buttons-box input[type=checkbox]")];
let toolboxButtonNodes = [...doc.querySelectorAll(".command-button")];
- toolboxButtonNodes.push(doc.getElementById("command-button-frames"));
- let toggleableTools = toolbox.toolboxButtons;
// The noautohide button is only displayed in the browser toolbox
- toggleableTools = toggleableTools.filter(
+ let toolbarButtons = toolbox.toolbarButtons.filter(
tool => tool.id != "command-button-noautohide");
- for (let tool of toggleableTools) {
+ for (let tool of toolbarButtons) {
let isVisible = getBoolPref(tool.visibilityswitch);
- let button = toolboxButtonNodes.filter(
- toolboxButton => toolboxButton.id === tool.id)[0];
- is(!button.hasAttribute("hidden"), isVisible,
+ let button = toolboxButtonNodes.find(toolboxButton => toolboxButton.id === tool.id);
+ is(!!button, isVisible,
"Button visibility matches pref for " + tool.id);
let check = checkNodes.filter(node => node.id === tool.id)[0];
is(check.checked, isVisible,
"Checkbox should be selected based on current pref for " + tool.id);
}
}
function testToggleToolboxButtons() {
let checkNodes = [...panelWin.document.querySelectorAll(
"#enabled-toolbox-buttons-box input[type=checkbox]")];
- let toolboxButtonNodes = [...doc.querySelectorAll(".command-button")];
- let toggleableTools = toolbox.toolboxButtons;
// The noautohide button is only displayed in the browser toolbox, and the element
// picker button is not toggleable.
- toggleableTools = toggleableTools.filter(
- tool => tool.id != "command-button-noautohide" && tool.id != "command-button-pick");
- toolboxButtonNodes = toolboxButtonNodes.filter(
- btn => btn.id != "command-button-noautohide" && btn.id != "command-button-pick");
+ let toolbarButtons = toolbox.toolbarButtons.filter(
+ tool => tool.id != "command-button-noautohide");
+
+ let visibleToolbarButtons = toolbox.toolbarButtons.filter(tool => tool.isVisible);
- is(checkNodes.length, toggleableTools.length,
+ let toolbarButtonNodes = [...doc.querySelectorAll(".command-button")].filter(
+ btn => btn.id != "command-button-noautohide");
+
+ is(checkNodes.length, toolbarButtons.length,
"All of the buttons are toggleable.");
- is(checkNodes.length, toolboxButtonNodes.length,
+ is(visibleToolbarButtons.length, toolbarButtonNodes.length,
"All of the DOM buttons are toggleable.");
- for (let tool of toggleableTools) {
+ for (let tool of toolbarButtons) {
let id = tool.id;
let matchedCheckboxes = checkNodes.filter(node => node.id === id);
- let matchedButtons = toolboxButtonNodes.filter(button => button.id === id);
+ let matchedButtons = toolbarButtonNodes.filter(button => button.id === id);
is(matchedCheckboxes.length, 1,
"There should be a single toggle checkbox for: " + id);
- is(matchedButtons.length, 1,
- "There should be a DOM button for: " + id);
- is(matchedButtons[0], tool.button,
- "DOM buttons should match for: " + id);
+ if (tool.isVisible) {
+ is(matchedButtons.length, 1,
+ "There should be a DOM button for the visible: " + id);
+ is(matchedButtons[0].getAttribute("title"), tool.description,
+ "The tooltip for button matches the tool definition.");
+ } else {
+ is(matchedButtons.length, 0,
+ "There should not be a DOM button for the invisible: " + id);
+ }
- is(matchedCheckboxes[0].nextSibling.textContent, tool.label,
+ is(matchedCheckboxes[0].nextSibling.textContent, tool.description,
"The label for checkbox matches the tool definition.");
- is(matchedButtons[0].getAttribute("title"), tool.label,
- "The tooltip for button matches the tool definition.");
}
// Store modified pref names so that they can be cleared on error.
- for (let tool of toggleableTools) {
+ for (let tool of toolbarButtons) {
let pref = tool.visibilityswitch;
modifiedPrefs.push(pref);
}
// Try checking each checkbox, making sure that it changes the preference
for (let node of checkNodes) {
- let tool = toggleableTools.filter(
- toggleableTool => toggleableTool.id === node.id)[0];
+ let tool = toolbarButtons.filter(
+ commandButton => commandButton.id === node.id)[0];
let isVisible = getBoolPref(tool.visibilityswitch);
testPreferenceAndUIStateIsConsistent();
node.click();
testPreferenceAndUIStateIsConsistent();
let isVisibleAfterClick = getBoolPref(tool.visibilityswitch);
--- a/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js
+++ b/devtools/client/framework/test/browser_toolbox_tools_per_toolbox_registration.js
@@ -127,13 +127,14 @@ function toolboxToolUnregistered() {
let panel = doc.getElementById("toolbox-panel-" + TOOL_ID);
ok(!panel, "tool's panel was removed from toolbox UI");
cleanup();
}
function cleanup() {
- toolbox.destroy();
- toolbox = null;
- gBrowser.removeCurrentTab();
- finish();
+ toolbox.destroy().then(() => {;
+ toolbox = null;
+ gBrowser.removeCurrentTab();
+ finish();
+ });
}
--- a/devtools/client/framework/test/browser_toolbox_transport_events.js
+++ b/devtools/client/framework/test/browser_toolbox_transport_events.js
@@ -25,20 +25,22 @@ function testResults(toolbox) {
cleanUp(toolbox);
}
function cleanUp(toolbox) {
gDevTools.off("toolbox-created", onToolboxCreated);
off(DebuggerClient, "connect", onDebuggerClientConnect);
toolbox.destroy().then(function () {
- gBrowser.removeCurrentTab();
- executeSoon(function () {
- finish();
- });
+ setTimeout(() => {
+ gBrowser.removeCurrentTab();
+ executeSoon(function () {
+ finish();
+ });
+ }, 1000);
});
}
function testPackets(sent, received) {
ok(sent.length > 0, "There must be at least one sent packet");
ok(received.length > 0, "There must be at leaset one received packet");
if (!sent.length || received.length) {
--- a/devtools/client/framework/test/browser_toolbox_window_title_frame_select.js
+++ b/devtools/client/framework/test/browser_toolbox_window_title_frame_select.js
@@ -39,21 +39,21 @@ add_task(function* () {
// Wait for tick to avoid unexpected 'popuphidden' event, which
// blocks the frame popup menu opened below. See also bug 1276873
yield waitForTick();
// Open frame menu and wait till it's available on the screen.
// Also check 'open' attribute on the command button.
let btn = toolbox.doc.getElementById("command-button-frames");
- ok(!btn.getAttribute("open"), "The open attribute must not be present");
+ ok(!btn.classList.contains("checked"), "The checked class must not be present");
let menu = toolbox.showFramesMenu({target: btn});
yield once(menu, "open");
- is(btn.getAttribute("open"), "true", "The open attribute must be set");
+ ok(btn.classList.contains("checked"), "The checked class must be set");
// Verify that the frame list menu is populated
let frames = menu.items;
is(frames.length, 2, "We have both frames in the list");
let topFrameBtn = frames.filter(b => b.label == URL)[0];
let iframeBtn = frames.filter(b => b.label == IFRAME_URL)[0];
ok(topFrameBtn, "Got top level document in the list");
--- a/devtools/client/inspector/test/browser_inspector_highlighter-preview.js
+++ b/devtools/client/inspector/test/browser_inspector_highlighter-preview.js
@@ -47,10 +47,10 @@ function* clickElement(selector, testAct
function* checkElementSelected(selector, inspector) {
let el = yield getNodeFront(selector, inspector);
is(inspector.selection.nodeFront, el, `The element ${selector} is now selected`);
}
function checkPickerMode(toolbox, isOn) {
let pickerButton = toolbox.doc.querySelector("#command-button-pick");
- is(pickerButton.hasAttribute("checked"), isOn, "The picker mode is correct");
+ is(pickerButton.classList.contains("checked"), isOn, "The picker mode is correct");
}
--- a/devtools/client/inspector/test/browser_inspector_initialization.js
+++ b/devtools/client/inspector/test/browser_inspector_initialization.js
@@ -52,19 +52,17 @@ function* testToolboxInitialization(test
yield testActor.scrollIntoView("span");
yield selectNode("span", inspector);
yield testMarkupView("span", inspector);
yield testBreadcrumbs("span", inspector);
info("Destroying toolbox");
- let destroyed = toolbox.once("destroyed");
- toolbox.destroy();
- yield destroyed;
+ yield toolbox.destroy();
ok("true", "'destroyed' notification received.");
ok(!gDevTools.getToolbox(target), "Toolbox destroyed.");
}
function* testContextMenuInitialization(testActor) {
info("Opening inspector by clicking on 'Inspect Element' context menu item");
yield clickOnInspectMenuItem(testActor, "#salutation");
--- a/devtools/client/performance/test/browser_perf-highlighted.js
+++ b/devtools/client/performance/test/browser_perf-highlighted.js
@@ -16,33 +16,33 @@ add_task(function* () {
let { target, toolbox, console } = yield initConsoleInNewTab({
url: SIMPLE_URL,
win: window
});
let tab = toolbox.doc.getElementById("toolbox-tab-performance");
yield console.profile("rust");
- yield waitUntil(() => tab.hasAttribute("highlighted"));
+ yield waitUntil(() => tab.classList.contains("highlighted"));
- ok(tab.hasAttribute("highlighted"), "Performance tab is highlighted during recording " +
- "from console.profile when unloaded.");
+ ok(tab.classList.contains("highlighted"), "Performance tab is highlighted during " +
+ "recording from console.profile when unloaded.");
yield console.profileEnd("rust");
- yield waitUntil(() => !tab.hasAttribute("highlighted"));
+ yield waitUntil(() => !tab.classList.contains("highlighted"));
- ok(!tab.hasAttribute("highlighted"),
+ ok(!tab.classList.contains("highlighted"),
"Performance tab is no longer highlighted when console.profile recording finishes.");
let { panel } = yield initPerformanceInTab({ tab: target.tab });
yield startRecording(panel);
- ok(tab.hasAttribute("highlighted"),
+ ok(tab.classList.contains("highlighted"),
"Performance tab is highlighted during recording while in performance tool.");
yield stopRecording(panel);
- ok(!tab.hasAttribute("highlighted"),
+ ok(!tab.classList.contains("highlighted"),
"Performance tab is no longer highlighted when recording finishes.");
yield teardownToolboxAndRemoveTab(panel);
});
--- a/devtools/client/shared/test/browser_telemetry_button_paintflashing.js
+++ b/devtools/client/shared/test/browser_telemetry_button_paintflashing.js
@@ -8,16 +8,17 @@ const TEST_URI = "data:text/html;charset
// Because we need to gather stats for the period of time that a tool has been
// opened we make use of setTimeout() to create tool active times.
const TOOL_DELAY = 200;
add_task(function* () {
yield addTab(TEST_URI);
let Telemetry = loadTelemetryAndRecordLogs();
+ yield pushPref("devtools.command-button-paintflashing.enabled", true);
let target = TargetFactory.forTab(gBrowser.selectedTab);
let toolbox = yield gDevTools.showToolbox(target, "inspector");
info("inspector opened");
info("testing the paintflashing button");
yield testButton(toolbox, Telemetry);
--- a/devtools/client/shared/test/browser_telemetry_button_scratchpad.js
+++ b/devtools/client/shared/test/browser_telemetry_button_scratchpad.js
@@ -9,16 +9,18 @@ const TEST_URI = "data:text/html;charset
// Because we need to gather stats for the period of time that a tool has been
// opened we make use of setTimeout() to create tool active times.
const TOOL_DELAY = 200;
add_task(function* () {
yield addTab(TEST_URI);
let Telemetry = loadTelemetryAndRecordLogs();
+ yield pushPref("devtools.command-button-scratchpad.enabled", true);
+
let target = TargetFactory.forTab(gBrowser.selectedTab);
let toolbox = yield gDevTools.showToolbox(target, "inspector");
info("inspector opened");
let onAllWindowsOpened = trackScratchpadWindows();
info("testing the scratchpad button");
yield testButton(toolbox, Telemetry);
--- a/devtools/client/webconsole/test/browser_webconsole_split.js
+++ b/devtools/client/webconsole/test/browser_webconsole_split.js
@@ -80,152 +80,143 @@ function runTest() {
let cmdButton = toolbox.doc.querySelector("#command-button-splitconsole");
return {
deckHeight: deckHeight,
containerHeight: containerHeight,
webconsoleHeight: webconsoleHeight,
splitterVisibility: splitterVisibility,
openedConsolePanel: openedConsolePanel,
- buttonSelected: cmdButton.hasAttribute("checked")
+ buttonSelected: cmdButton.classList.contains("checked")
};
}
- function checkWebconsolePanelOpened() {
+ const checkWebconsolePanelOpened = Task.async(function* () {
info("About to check special cases when webconsole panel is open.");
- let deferred = promise.defer();
-
// Start with console split, so we can test for transition to main panel.
- toolbox.toggleSplitConsole();
+ yield toolbox.toggleSplitConsole();
let currentUIState = getCurrentUIState();
ok(currentUIState.splitterVisibility,
"Splitter is visible when console is split");
ok(currentUIState.deckHeight > 0,
"Deck has a height > 0 when console is split");
ok(currentUIState.webconsoleHeight > 0,
"Web console has a height > 0 when console is split");
ok(!currentUIState.openedConsolePanel,
"The console panel is not the current tool");
ok(currentUIState.buttonSelected, "The command button is selected");
- openPanel("webconsole").then(() => {
- currentUIState = getCurrentUIState();
-
- ok(!currentUIState.splitterVisibility,
- "Splitter is hidden when console is opened.");
- is(currentUIState.deckHeight, 0,
- "Deck has a height == 0 when console is opened.");
- is(currentUIState.webconsoleHeight, currentUIState.containerHeight,
- "Web console is full height.");
- ok(currentUIState.openedConsolePanel,
- "The console panel is the current tool");
- ok(currentUIState.buttonSelected,
- "The command button is still selected.");
+ yield openPanel("webconsole");
+ currentUIState = getCurrentUIState();
- // Make sure splitting console does nothing while webconsole is opened
- toolbox.toggleSplitConsole();
-
- currentUIState = getCurrentUIState();
+ ok(!currentUIState.splitterVisibility,
+ "Splitter is hidden when console is opened.");
+ is(currentUIState.deckHeight, 0,
+ "Deck has a height == 0 when console is opened.");
+ is(currentUIState.webconsoleHeight, currentUIState.containerHeight,
+ "Web console is full height.");
+ ok(currentUIState.openedConsolePanel,
+ "The console panel is the current tool");
+ ok(currentUIState.buttonSelected,
+ "The command button is still selected.");
- ok(!currentUIState.splitterVisibility,
- "Splitter is hidden when console is opened.");
- is(currentUIState.deckHeight, 0,
- "Deck has a height == 0 when console is opened.");
- is(currentUIState.webconsoleHeight, currentUIState.containerHeight,
- "Web console is full height.");
- ok(currentUIState.openedConsolePanel,
- "The console panel is the current tool");
- ok(currentUIState.buttonSelected,
- "The command button is still selected.");
+ // Make sure splitting console does nothing while webconsole is opened
+ yield toolbox.toggleSplitConsole();
+
+ currentUIState = getCurrentUIState();
- // Make sure that split state is saved after opening another panel
- openPanel("inspector").then(() => {
- currentUIState = getCurrentUIState();
- ok(currentUIState.splitterVisibility,
- "Splitter is visible when console is split");
- ok(currentUIState.deckHeight > 0,
- "Deck has a height > 0 when console is split");
- ok(currentUIState.webconsoleHeight > 0,
- "Web console has a height > 0 when console is split");
- ok(!currentUIState.openedConsolePanel,
- "The console panel is not the current tool");
- ok(currentUIState.buttonSelected,
- "The command button is still selected.");
-
- toolbox.toggleSplitConsole();
- deferred.resolve();
- });
- });
- return deferred.promise;
- }
+ ok(!currentUIState.splitterVisibility,
+ "Splitter is hidden when console is opened.");
+ is(currentUIState.deckHeight, 0,
+ "Deck has a height == 0 when console is opened.");
+ is(currentUIState.webconsoleHeight, currentUIState.containerHeight,
+ "Web console is full height.");
+ ok(currentUIState.openedConsolePanel,
+ "The console panel is the current tool");
+ ok(currentUIState.buttonSelected,
+ "The command button is still selected.");
- function openPanel(toolId) {
- let deferred = promise.defer();
- let target = TargetFactory.forTab(gBrowser.selectedTab);
- gDevTools.showToolbox(target, toolId).then(function (box) {
- toolbox = box;
- deferred.resolve();
- }).then(null, console.error);
- return deferred.promise;
- }
+ // Make sure that split state is saved after opening another panel
+ yield openPanel("inspector");
+ currentUIState = getCurrentUIState();
+ ok(currentUIState.splitterVisibility,
+ "Splitter is visible when console is split");
+ ok(currentUIState.deckHeight > 0,
+ "Deck has a height > 0 when console is split");
+ ok(currentUIState.webconsoleHeight > 0,
+ "Web console has a height > 0 when console is split");
+ ok(!currentUIState.openedConsolePanel,
+ "The console panel is not the current tool");
+ ok(currentUIState.buttonSelected,
+ "The command button is still selected.");
- function openAndCheckPanel(toolId) {
- let deferred = promise.defer();
- openPanel(toolId).then(() => {
- info("Checking toolbox for " + toolId);
- checkToolboxUI(toolbox.getCurrentPanel());
- deferred.resolve();
- });
- return deferred.promise;
- }
+ yield toolbox.toggleSplitConsole();
+ });
- function checkToolboxUI() {
+ const checkToolboxUI = Task.async(function* () {
let currentUIState = getCurrentUIState();
ok(!currentUIState.splitterVisibility, "Splitter is hidden by default");
is(currentUIState.deckHeight, currentUIState.containerHeight,
"Deck has a height > 0 by default");
is(currentUIState.webconsoleHeight, 0,
"Web console is collapsed by default");
ok(!currentUIState.openedConsolePanel,
"The console panel is not the current tool");
ok(!currentUIState.buttonSelected, "The command button is not selected.");
- toolbox.toggleSplitConsole();
+ yield toolbox.toggleSplitConsole();
currentUIState = getCurrentUIState();
ok(currentUIState.splitterVisibility,
"Splitter is visible when console is split");
ok(currentUIState.deckHeight > 0,
"Deck has a height > 0 when console is split");
ok(currentUIState.webconsoleHeight > 0,
"Web console has a height > 0 when console is split");
is(Math.round(currentUIState.deckHeight + currentUIState.webconsoleHeight),
currentUIState.containerHeight,
"Everything adds up to container height");
ok(!currentUIState.openedConsolePanel,
"The console panel is not the current tool");
ok(currentUIState.buttonSelected, "The command button is selected.");
- toolbox.toggleSplitConsole();
+ yield toolbox.toggleSplitConsole();
currentUIState = getCurrentUIState();
ok(!currentUIState.splitterVisibility, "Splitter is hidden after toggling");
is(currentUIState.deckHeight, currentUIState.containerHeight,
"Deck has a height > 0 after toggling");
is(currentUIState.webconsoleHeight, 0,
"Web console is collapsed after toggling");
ok(!currentUIState.openedConsolePanel,
"The console panel is not the current tool");
ok(!currentUIState.buttonSelected, "The command button is not selected.");
+ });
+
+ function openPanel(toolId) {
+ let deferred = promise.defer();
+ let target = TargetFactory.forTab(gBrowser.selectedTab);
+ gDevTools.showToolbox(target, toolId).then(function (box) {
+ toolbox = box;
+ deferred.resolve();
+ }).then(null, console.error);
+ return deferred.promise;
+ }
+
+ function openAndCheckPanel(toolId) {
+ return openPanel(toolId).then(() => {
+ info("Checking toolbox for " + toolId);
+ return checkToolboxUI(toolbox.getCurrentPanel());
+ });
}
function testBottomHost() {
checkHostType(Toolbox.HostType.BOTTOM);
checkToolboxUI();
toolbox.switchHost(Toolbox.HostType.SIDE).then(testSidebarHost);
--- a/devtools/client/webconsole/test/browser_webconsole_split_persist.js
+++ b/devtools/client/webconsole/test/browser_webconsole_split_persist.js
@@ -94,17 +94,17 @@
}
function getHeightPrefValue() {
return Services.prefs.getIntPref("devtools.toolbox.splitconsoleHeight");
}
function isCommandButtonChecked() {
return toolbox.doc.querySelector("#command-button-splitconsole")
- .hasAttribute("checked");
+ .classList.contains("checked");
}
function toggleSplitConsoleWithEscape() {
let onceSplitConsole = toolbox.once("split-console");
let contentWindow = toolbox.win;
contentWindow.focus();
EventUtils.sendKey("ESCAPE", contentWindow);
return onceSplitConsole;