Bug 1455204 - Hide close button on browser console and browser toolbox. r?jdescottes
This patch will hide toolbar's close button if debug target is not local tab
like browser toolbox.
MozReview-Commit-ID: Guf6QhzkGIV
--- a/devtools/client/framework/test/browser_browser_toolbox.js
+++ b/devtools/client/framework/test/browser_browser_toolbox.js
@@ -24,30 +24,33 @@ add_task(async function() {
["devtools.debugger.remote-timeout", 120000]
]};
SpecialPowers.pushPrefEnv(options, done);
});
// Wait for a notification sent by a script evaluated in the webconsole
// of the browser toolbox.
let onCustomMessage = new Promise(done => {
- Services.obs.addObserver(function listener() {
+ Services.obs.addObserver(function listener(target, aTop, data) {
Services.obs.removeObserver(listener, "browser-toolbox-console-works");
- done();
+ done(data === "true");
}, "browser-toolbox-console-works");
});
// Be careful, this JS function is going to be executed in the addon toolbox,
// which lives in another process. So do not try to use any scope variable!
let env = Cc["@mozilla.org/process/environment;1"].getService(Ci.nsIEnvironment);
let testScript = function() {
toolbox.selectTool("webconsole")
.then(console => {
+ // This is for checking Browser Toolbox doesn't have a close button.
+ let hasCloseButton = !!toolbox.doc.getElementById("toolbox-close");
let { jsterm } = console.hud;
- let js = "Services.obs.notifyObservers(null, 'browser-toolbox-console-works', null);";
+ let js = "Services.obs.notifyObservers(null, 'browser-toolbox-console-works', " +
+ hasCloseButton + ");";
return jsterm.execute(js);
})
.then(() => toolbox.destroy());
};
env.set("MOZ_TOOLBOX_TEST_SCRIPT", "new " + testScript);
registerCleanupFunction(() => {
env.set("MOZ_TOOLBOX_TEST_SCRIPT", "");
});
@@ -60,15 +63,16 @@ add_task(async function() {
closePromise = new Promise(onClose => {
info("Opening the browser toolbox\n");
BrowserToolboxProcess.init(onClose, onRun);
});
});
ok(true, "Browser toolbox started\n");
is(BrowserToolboxProcess.getBrowserToolboxSessionState(), true, "Has session state");
- await onCustomMessage;
+ let hasCloseButton = await onCustomMessage;
ok(true, "Received the custom message");
+ ok(!hasCloseButton, "Browser toolbox doesn't have a close button");
await closePromise;
ok(true, "Browser toolbox process just closed");
is(BrowserToolboxProcess.getBrowserToolboxSessionState(), false, "No session state after closing");
});
--- a/devtools/client/framework/toolbox.js
+++ b/devtools/client/framework/toolbox.js
@@ -1077,16 +1077,17 @@ Toolbox.prototype = {
/**
* Build the options for changing hosts. Called every time
* the host changes.
*/
_buildDockOptions: function() {
if (!this._target.isLocalTab) {
this.component.setDockOptionsEnabled(false);
+ this.component.setCanCloseToolbox(false);
return;
}
this.component.setDockOptionsEnabled(true);
this.component.setCanCloseToolbox(this.hostType !== Toolbox.HostType.WINDOW);
let sideEnabled = Services.prefs.getBoolPref(this._prefs.SIDE_ENABLED);