mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-12-01 17:23:59 +00:00
Bug 1058167 - Activate split console command button when initially opened. r=jwalker
This commit is contained in:
parent
84bdc31023
commit
c663ce5e4c
@ -5,29 +5,8 @@
|
||||
"use strict";
|
||||
|
||||
const gcli = require("gcli/index");
|
||||
const EventEmitter = require("devtools/toolkit/event-emitter");
|
||||
const { gDevTools } = require("resource:///modules/devtools/gDevTools.jsm");
|
||||
|
||||
const eventEmitter = new EventEmitter();
|
||||
|
||||
gDevTools.on("toolbox-ready", (e, toolbox) => {
|
||||
if (!toolbox.target) {
|
||||
return;
|
||||
}
|
||||
|
||||
let fireChangeForTab = () => {
|
||||
eventEmitter.emit("changed", { target: toolbox.target });
|
||||
};
|
||||
|
||||
toolbox.on("split-console", fireChangeForTab);
|
||||
toolbox.on("select", fireChangeForTab);
|
||||
|
||||
toolbox.once("destroyed", () => {
|
||||
toolbox.off("split-console", fireChangeForTab);
|
||||
toolbox.off("select", fireChangeForTab);
|
||||
});
|
||||
});
|
||||
|
||||
exports.items = [
|
||||
{
|
||||
name: 'splitconsole',
|
||||
@ -41,11 +20,20 @@ exports.items = [
|
||||
return !!(toolbox && toolbox.splitConsole);
|
||||
},
|
||||
onChange: function(target, changeHandler) {
|
||||
eventEmitter.on("changed", changeHandler);
|
||||
},
|
||||
offChange: function(target, changeHandler) {
|
||||
eventEmitter.off("changed", changeHandler);
|
||||
},
|
||||
// Register handlers for when a change event should be fired
|
||||
// (which resets the checked state of the button).
|
||||
let toolbox = gDevTools.getToolbox(target);
|
||||
let callback = changeHandler.bind(null, "changed", { target: target });
|
||||
|
||||
if (!toolbox) {
|
||||
return;
|
||||
}
|
||||
|
||||
toolbox.on("split-console", callback);
|
||||
toolbox.once("destroyed", () => {
|
||||
toolbox.off("split-console", callback);
|
||||
});
|
||||
}
|
||||
},
|
||||
exec: function(args, context) {
|
||||
let target = context.environment.target;
|
||||
|
@ -18,8 +18,10 @@ function test() {
|
||||
toolbox = yield gDevTools.showToolbox(target, "inspector");
|
||||
|
||||
ok(!toolbox.splitConsole, "Split console is hidden by default.");
|
||||
ok(!isCommandButtonChecked(), "Split console button is unchecked by default.");
|
||||
yield toggleSplitConsoleWithEscape();
|
||||
ok(toolbox.splitConsole, "Split console is now visible.");
|
||||
ok(isCommandButtonChecked(), "Split console button is now checked.");
|
||||
ok(getVisiblePrefValue(), "Visibility pref is true");
|
||||
|
||||
is(getHeightPrefValue(), toolbox.webconsolePanel.height, "Panel height matches the pref");
|
||||
@ -33,6 +35,7 @@ function test() {
|
||||
toolbox = yield gDevTools.showToolbox(target, "inspector");
|
||||
|
||||
ok(toolbox.splitConsole, "Split console is visible by default.");
|
||||
ok(isCommandButtonChecked(), "Split console button is checked by default.");
|
||||
is(getHeightPrefValue(), 200, "Height is set based on panel height after closing");
|
||||
|
||||
// Use the binding element since jsterm.inputNode is a XUL textarea element.
|
||||
@ -51,6 +54,7 @@ function test() {
|
||||
|
||||
yield toggleSplitConsoleWithEscape();
|
||||
ok(!toolbox.splitConsole, "Split console is now hidden.");
|
||||
ok(!isCommandButtonChecked(), "Split console button is now unchecked.");
|
||||
ok(!getVisiblePrefValue(), "Visibility pref is false");
|
||||
|
||||
yield toolbox.destroy();
|
||||
@ -85,6 +89,11 @@ function test() {
|
||||
return Services.prefs.getIntPref("devtools.toolbox.splitconsoleHeight");
|
||||
}
|
||||
|
||||
function isCommandButtonChecked() {
|
||||
return toolbox.doc.querySelector("#command-button-splitconsole").
|
||||
hasAttribute("checked");
|
||||
}
|
||||
|
||||
function toggleSplitConsoleWithEscape() {
|
||||
let onceSplitConsole = toolbox.once("split-console");
|
||||
let contentWindow = toolbox.frame.contentWindow;
|
||||
|
Loading…
Reference in New Issue
Block a user