зеркало из https://github.com/mozilla/gecko-dev.git
The toolbox should expect the previously selected tool to be unavailable (bug 915448). r=bgrins
This commit is contained in:
Родитель
ec9fb46b15
Коммит
3a398a1ba5
|
@ -64,6 +64,7 @@ skip-if = os == "mac" && os_version == "10.8" || os == "win" && os_version == "5
|
|||
[browser_toolbox_theme_registration.js]
|
||||
[browser_toolbox_options_enable_serviceworkers_testing.js]
|
||||
skip-if = true # Bug 1153407 - this test breaks subsequent tests and is not e10s compatible
|
||||
[browser_toolbox_selected_tool_unavailable.js]
|
||||
|
||||
# We want this test to run for mochitest-dt as well, so we include it here:
|
||||
[../../../base/content/test/general/browser_parsable_css.js]
|
||||
|
|
|
@ -0,0 +1,43 @@
|
|||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
"use strict";
|
||||
|
||||
// Test that opening the toolbox doesn't throw when the previously selected
|
||||
// tool is not supported.
|
||||
|
||||
const testToolDefinition = {
|
||||
id: "test-tool",
|
||||
isTargetSupported: () => true,
|
||||
visibilityswitch: "devtools.test-tool.enabled",
|
||||
url: "about:blank",
|
||||
label: "someLabel",
|
||||
build: (iframeWindow, toolbox) => {
|
||||
return {
|
||||
target: toolbox.target,
|
||||
toolbox: toolbox,
|
||||
isReady: true,
|
||||
destroy: () => {},
|
||||
panelDoc: iframeWindow.document
|
||||
};
|
||||
}
|
||||
};
|
||||
|
||||
add_task(function*() {
|
||||
gDevTools.registerTool(testToolDefinition);
|
||||
let tab = yield addTab("about:blank");
|
||||
let target = TargetFactory.forTab(tab);
|
||||
|
||||
let toolbox = yield gDevTools.showToolbox(target, testToolDefinition.id);
|
||||
is(toolbox.currentToolId, "test-tool", "test-tool was selected");
|
||||
yield gDevTools.closeToolbox(target);
|
||||
|
||||
// Make the previously selected tool unavailable.
|
||||
testToolDefinition.isTargetSupported = () => false;
|
||||
|
||||
target = TargetFactory.forTab(tab);
|
||||
toolbox = yield gDevTools.showToolbox(target);
|
||||
is(toolbox.currentToolId, "webconsole", "web console was selected");
|
||||
|
||||
gDevTools.unregisterTool(testToolDefinition.id);
|
||||
gBrowser.removeCurrentTab();
|
||||
});
|
|
@ -137,9 +137,6 @@ function Toolbox(target, selectedTool, hostType, hostOptions) {
|
|||
if (!selectedTool) {
|
||||
selectedTool = Services.prefs.getCharPref(this._prefs.LAST_TOOL);
|
||||
}
|
||||
if (!gDevTools.getToolDefinition(selectedTool)) {
|
||||
selectedTool = "webconsole";
|
||||
}
|
||||
this._defaultToolId = selectedTool;
|
||||
|
||||
this._hostOptions = hostOptions;
|
||||
|
@ -370,6 +367,14 @@ Toolbox.prototype = {
|
|||
|
||||
this._pingTelemetry();
|
||||
|
||||
// The isTargetSupported check needs to happen after the target is
|
||||
// remoted, otherwise we could have done it in the toolbox constructor
|
||||
// (bug 1072764).
|
||||
let toolDef = gDevTools.getToolDefinition(this._defaultToolId);
|
||||
if (!toolDef || !toolDef.isTargetSupported(this._target)) {
|
||||
this._defaultToolId = "webconsole";
|
||||
}
|
||||
|
||||
yield this.selectTool(this._defaultToolId);
|
||||
|
||||
// Wait until the original tool is selected so that the split
|
||||
|
|
Загрузка…
Ссылка в новой задаче