mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 21:35:39 +00:00
Bug 1438487 - Restore the Browser Toolbox using session store;r=jryans
MozReview-Commit-ID: JUbafbthojm --HG-- extra : rebase_source : eb8f4c3d10ec60475594c43010afe7ef6088a3f2
This commit is contained in:
parent
c7bf9cb790
commit
89210dfc96
@ -44,6 +44,7 @@ registerCleanupFunction(function() {
|
||||
add_task(async function() {
|
||||
// Windows XP and 8.1 test slaves are terribly slow at this test.
|
||||
requestLongerTimeout(5);
|
||||
await pushPref("devtools.chrome.enabled", true);
|
||||
await pushPref("devtools.debugger.remote-enabled", true);
|
||||
|
||||
gProcess = await initChromeDebugger();
|
||||
|
@ -12,6 +12,7 @@ var gProcess;
|
||||
function test() {
|
||||
// Windows XP and 8.1 test slaves are terribly slow at this test.
|
||||
requestLongerTimeout(5);
|
||||
Services.prefs.setBoolPref("devtools.chrome.enabled", true);
|
||||
Services.prefs.setBoolPref("devtools.debugger.remote-enabled", true);
|
||||
|
||||
initChromeDebugger(aOnClose).then(aProcess => {
|
||||
@ -57,6 +58,7 @@ function aOnClose() {
|
||||
}
|
||||
|
||||
registerCleanupFunction(function () {
|
||||
Services.prefs.clearUserPref("devtools.chrome.enabled");
|
||||
Services.prefs.clearUserPref("devtools.debugger.remote-enabled");
|
||||
gProcess = null;
|
||||
});
|
||||
|
@ -91,9 +91,28 @@ EventEmitter.decorate(BrowserToolboxProcess);
|
||||
* @return object
|
||||
*/
|
||||
BrowserToolboxProcess.init = function (onClose, onRun, options) {
|
||||
if (!Services.prefs.getBoolPref("devtools.chrome.enabled") ||
|
||||
!Services.prefs.getBoolPref("devtools.debugger.remote-enabled")) {
|
||||
console.error("Could not start Browser Toolbox, you need to enable it.");
|
||||
return null;
|
||||
}
|
||||
return new BrowserToolboxProcess(onClose, onRun, options);
|
||||
};
|
||||
|
||||
/**
|
||||
* Figure out if there are any open Browser Toolboxes that'll need to be restored.
|
||||
* @return bool
|
||||
*/
|
||||
BrowserToolboxProcess.getBrowserToolboxSessionState = function () {
|
||||
for (let process of processes.values()) {
|
||||
// Don't worry about addon toolboxes, we only want to restore the Browser Toolbox.
|
||||
if (!process._options || !process._options.addonID) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Passes a set of options to the BrowserAddonActors for the given ID.
|
||||
*
|
||||
|
@ -17,6 +17,7 @@ loader.lazyRequireGetter(this, "ToolboxHostManager", "devtools/client/framework/
|
||||
loader.lazyRequireGetter(this, "gDevToolsBrowser", "devtools/client/framework/devtools-browser", true);
|
||||
loader.lazyRequireGetter(this, "HUDService", "devtools/client/webconsole/hudservice", true);
|
||||
loader.lazyImporter(this, "ScratchpadManager", "resource://devtools/client/scratchpad/scratchpad-manager.jsm");
|
||||
loader.lazyImporter(this, "BrowserToolboxProcess", "resource://devtools/client/framework/ToolboxProcess.jsm");
|
||||
|
||||
loader.lazyRequireGetter(this, "WebExtensionInspectedWindowFront",
|
||||
"devtools/shared/fronts/webextension-inspected-window", true);
|
||||
@ -397,6 +398,7 @@ DevTools.prototype = {
|
||||
*/
|
||||
saveDevToolsSession: function (state) {
|
||||
state.browserConsole = HUDService.getBrowserConsoleSessionState();
|
||||
state.browserToolbox = BrowserToolboxProcess.getBrowserToolboxSessionState();
|
||||
|
||||
// Check if the module is loaded to avoid loading ScratchpadManager for no reason.
|
||||
state.scratchpads = [];
|
||||
@ -408,11 +410,15 @@ DevTools.prototype = {
|
||||
/**
|
||||
* Restore the devtools session state as provided by SessionStore.
|
||||
*/
|
||||
restoreDevToolsSession: function ({scratchpads, browserConsole}) {
|
||||
restoreDevToolsSession: function ({scratchpads, browserConsole, browserToolbox}) {
|
||||
if (scratchpads) {
|
||||
ScratchpadManager.restoreSession(scratchpads);
|
||||
}
|
||||
|
||||
if (browserToolbox) {
|
||||
BrowserToolboxProcess.init();
|
||||
}
|
||||
|
||||
if (browserConsole && !HUDService.getBrowserConsole()) {
|
||||
HUDService.toggleBrowserConsole();
|
||||
}
|
||||
|
@ -5,8 +5,8 @@
|
||||
// On debug test slave, it takes about 50s to run the test.
|
||||
requestLongerTimeout(4);
|
||||
|
||||
add_task(function* runTest() {
|
||||
yield new Promise(done => {
|
||||
add_task(async function() {
|
||||
await new Promise(done => {
|
||||
let options = {"set": [
|
||||
["devtools.debugger.prompt-connection", false],
|
||||
["devtools.debugger.remote-enabled", true],
|
||||
@ -48,18 +48,22 @@ add_task(function* runTest() {
|
||||
});
|
||||
|
||||
let { BrowserToolboxProcess } = ChromeUtils.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
|
||||
is(BrowserToolboxProcess.getBrowserToolboxSessionState(), false, "No session state initially");
|
||||
|
||||
let closePromise;
|
||||
yield new Promise(onRun => {
|
||||
await new Promise(onRun => {
|
||||
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");
|
||||
|
||||
yield onCustomMessage;
|
||||
await onCustomMessage;
|
||||
ok(true, "Received the custom message");
|
||||
|
||||
yield closePromise;
|
||||
await closePromise;
|
||||
ok(true, "Browser toolbox process just closed");
|
||||
is(BrowserToolboxProcess.getBrowserToolboxSessionState(), false, "No session state after closing");
|
||||
});
|
||||
|
@ -152,8 +152,9 @@ this.DevToolsShim = {
|
||||
return;
|
||||
}
|
||||
|
||||
let {scratchpads, browserConsole} = session;
|
||||
let hasDevToolsData = browserConsole || (scratchpads && scratchpads.length);
|
||||
let {scratchpads, browserConsole, browserToolbox} = session;
|
||||
let hasDevToolsData = browserConsole || browserToolbox ||
|
||||
(scratchpads && scratchpads.length);
|
||||
if (!hasDevToolsData) {
|
||||
// Do not initialize DevTools unless there is DevTools specific data in the session.
|
||||
return;
|
||||
|
Loading…
Reference in New Issue
Block a user