Bug 961771 - Disable highlighter when switching tools. r=pbrosset

This commit is contained in:
Peiyong Lin 2014-01-24 17:28:41 +01:00
parent 45f5cb9027
commit 55305b0740
3 changed files with 52 additions and 0 deletions

View File

@ -73,6 +73,7 @@ function Toolbox(target, selectedTool, hostType, hostOptions) {
this._refreshHostTitle = this._refreshHostTitle.bind(this);
this._splitConsoleOnKeypress = this._splitConsoleOnKeypress.bind(this)
this.destroy = this.destroy.bind(this);
this.stopPicker = this.stopPicker.bind(this);
this._target.on("close", this.destroy);
@ -1112,6 +1113,7 @@ Toolbox.prototype = {
let done = () => {
this.emit("picker-started");
this.on("select", this.stopPicker);
deferred.resolve();
};
@ -1156,6 +1158,7 @@ Toolbox.prototype = {
let done = () => {
this.emit("picker-stopped");
this.off("select", this.stopPicker);
deferred.resolve();
};

View File

@ -48,3 +48,4 @@ support-files =
[browser_inspector_bug_952294_tooltips_dimensions.js]
[browser_inspector_bug_958456_highlight_comments.js]
[browser_inspector_bug_958169_switch_to_inspector_on_pick.js]
[browser_inspector_bug_961771_picker_stops_on_tool_select.js]

View File

@ -0,0 +1,48 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */
// Test that the highlighter's picker should be stopped when a different tool is selected
function test() {
let {devtools} = Cu.import("resource://gre/modules/devtools/Loader.jsm", {});
let {require} = devtools;
let promise = require("sdk/core/promise");
let {Task} = Cu.import("resource://gre/modules/Task.jsm", {});
waitForExplicitFinish();
let inspector, doc, toolbox;
gBrowser.selectedTab = gBrowser.addTab();
gBrowser.selectedBrowser.addEventListener("load", function onload() {
gBrowser.selectedBrowser.removeEventListener("load", onload, true);
doc = content.document;
waitForFocus(setupTest, content);
}, true);
content.location = "data:text/html,testing the highlighter goes away on tool selection";
function setupTest() {
openInspector((aInspector, aToolbox) => {
toolbox = aToolbox;
inspector = aInspector;
toolbox.once("picker-stopped", () => {
ok(true, "picker-stopped event fired after switch tools, so picker is closed");
finishUp();
});
Task.spawn(function() {
yield toolbox.startPicker();
yield toolbox.selectNextTool();
}).then(null, Cu.reportError);
});
}
function finishUp() {
inspector = doc = toolbox = null;
gBrowser.removeCurrentTab();
finish();
}
}