mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-10 20:05:49 +00:00
Bug 1412050 - session restore should not initialize devtools when unnecessary;r=bgrins
MozReview-Commit-ID: BEQBZsXREoQ --HG-- extra : rebase_source : 137ffca2e8ebdee6056e6746f54afa3e0c4539aa
This commit is contained in:
parent
0ce2bfb273
commit
60ad2e8979
@ -153,6 +153,13 @@ this.DevToolsShim = {
|
||||
return;
|
||||
}
|
||||
|
||||
let {scratchpads, browserConsole} = session;
|
||||
let hasDevToolsData = browserConsole || (scratchpads && scratchpads.length);
|
||||
if (!hasDevToolsData) {
|
||||
// Do not initialize DevTools unless there is DevTools specific data in the session.
|
||||
return;
|
||||
}
|
||||
|
||||
this.initDevTools();
|
||||
this._gDevTools.restoreDevToolsSession(session);
|
||||
},
|
||||
|
@ -134,21 +134,30 @@ function test_restore_session_apis() {
|
||||
let initDevToolsBackup = DevToolsShim.initDevTools;
|
||||
let devtoolsEnabledValue = Services.prefs.getBoolPref("devtools.enabled");
|
||||
|
||||
// Create fake session objects to restore.
|
||||
let sessionWithoutDevTools = {};
|
||||
let sessionWithDevTools = {
|
||||
scratchpads: [{}],
|
||||
browserConsole: true,
|
||||
};
|
||||
|
||||
Services.prefs.setBoolPref("devtools.enabled", false);
|
||||
ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
|
||||
ok(!DevToolsShim.isEnabled(), "DevTools are not enabled");
|
||||
|
||||
// Ensure that save & restore DevToolsSession don't initialize the tools and don't crash
|
||||
// Check that save & restore DevToolsSession don't initialize the tools and don't crash.
|
||||
DevToolsShim.saveDevToolsSession({});
|
||||
DevToolsShim.restoreDevToolsSession({
|
||||
scratchpads: [{}],
|
||||
browserConsole: true,
|
||||
});
|
||||
DevToolsShim.restoreDevToolsSession(sessionWithDevTools);
|
||||
|
||||
Services.prefs.setBoolPref("devtools.enabled", true);
|
||||
ok(DevToolsShim.isEnabled(), "DevTools are enabled");
|
||||
ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
|
||||
|
||||
// Check that DevTools are not initialized when calling restoreDevToolsSession without
|
||||
// DevTools related data.
|
||||
DevToolsShim.restoreDevToolsSession(sessionWithoutDevTools);
|
||||
ok(!DevToolsShim.isInitialized(), "DevTools are still not initialized");
|
||||
|
||||
let mock = createMockDevTools();
|
||||
DevToolsShim.initDevTools = () => {
|
||||
// Next call to restoreDevToolsSession is expected to initialize DevTools, which we
|
||||
@ -156,9 +165,8 @@ function test_restore_session_apis() {
|
||||
DevToolsShim.register(mock);
|
||||
};
|
||||
|
||||
let scratchpadSessions = [{}];
|
||||
DevToolsShim.restoreDevToolsSession(scratchpadSessions);
|
||||
checkCalls(mock, "restoreDevToolsSession", 1, [scratchpadSessions]);
|
||||
DevToolsShim.restoreDevToolsSession(sessionWithDevTools);
|
||||
checkCalls(mock, "restoreDevToolsSession", 1, [sessionWithDevTools]);
|
||||
|
||||
ok(DevToolsShim.isInitialized(), "DevTools are initialized");
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user