Bug 1359855 - Prevent loading DevTools when saving session restore data. r=jdescottes,mossop
☠☠ backed out by 263f0b999ae1 ☠ ☠
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 20 Jul 2017 12:38:09 +0200
changeset 370510 2dd30b065030bab3f0e2b231822302eda90b6039
parent 370509 dbd03e7e1bc5aad3148a1b1ef69361bf30e041ef
child 370511 d39db44301707b46ab4c63889dc777d7af98264b
push id47052
push userapoirot@mozilla.com
push dateMon, 24 Jul 2017 09:16:15 +0000
treeherderautoland@2dd30b065030 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes, mossop
bugs1359855
milestone56.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1359855 - Prevent loading DevTools when saving session restore data. r=jdescottes,mossop MozReview-Commit-ID: 1d7WmiGRSmp
devtools/shim/DevToolsShim.jsm
devtools/shim/tests/unit/test_devtools_shim.js
--- a/devtools/shim/DevToolsShim.jsm
+++ b/devtools/shim/DevToolsShim.jsm
@@ -170,24 +170,20 @@ this.DevToolsShim = {
 
   /**
    * Called from SessionStore.jsm in mozilla-central when saving the current state.
    *
    * @return {Array} array of currently opened scratchpad windows. Empty array if devtools
    *         are not installed
    */
   getOpenedScratchpads: function () {
-    if (!this.isInstalled()) {
+    if (!this.isInitialized()) {
       return [];
     }
 
-    if (!this.isInitialized()) {
-      this._initDevTools();
-    }
-
     return this.gDevTools.getOpenedScratchpads();
   },
 
   /**
    * Called from SessionStore.jsm in mozilla-central when restoring a state that contained
    * opened scratchpad windows.
    */
   restoreScratchpadSession: function (scratchpads) {
--- a/devtools/shim/tests/unit/test_devtools_shim.js
+++ b/devtools/shim/tests/unit/test_devtools_shim.js
@@ -42,17 +42,16 @@ function createMockDevTools() {
   }
 
   return mock;
 }
 
 function mockDevToolsInstalled() {
   DevToolsShim.isInstalled = () => true;
 }
-
 function mockDevToolsUninstalled() {
   DevToolsShim.isInstalled = () => false;
 }
 
 /**
  * Check if a given method was called an expected number of times, and finally check the
  * arguments provided to the last call, if appropriate.
  */
@@ -200,39 +199,51 @@ function test_events() {
   DevToolsShim.unregister();
   checkCalls(mock, "emit", 2, ["devtools-unregistered"]);
 }
 
 function test_scratchpad_apis() {
   mockDevToolsUninstalled();
 
   ok(!DevToolsShim.isInstalled(), "DevTools are not installed");
+  ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
+
+  // Ensure that getOpenedScratchpads doesn't initialize the tools
+  DevToolsShim.getOpenedScratchpads();
+
+  ok(!DevToolsShim.isInstalled(), "DevTools are not installed");
+  ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
 
   // Check that restoreScratchpadSession doesn't crash.
   DevToolsShim.restoreScratchpadSession([{}]);
 
   let scratchpads = DevToolsShim.getOpenedScratchpads();
   equal(scratchpads.length, 0,
       "getOpenedScratchpads returns [] when DevTools are not installed");
 
-  let mock = createMockDevTools();
+  mockDevToolsInstalled();
 
-  mockDevToolsInstalled();
+  ok(DevToolsShim.isInstalled(), "DevTools are installed");
+  ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
+
+  let mock = createMockDevTools();
   DevToolsShim._initDevTools = () => {
-    // Next call to getOpenedScratchpags is expected to initialize DevTools, which we
+    // Next call to restoreScratchpadSession is expected to initialize DevTools, which we
     // simulate here by registering our mock.
     DevToolsShim.register(mock);
   };
 
-  DevToolsShim.getOpenedScratchpads();
-  checkCalls(mock, "getOpenedScratchpads", 1, []);
-
   let scratchpadSessions = [{}];
   DevToolsShim.restoreScratchpadSession(scratchpadSessions);
   checkCalls(mock, "restoreScratchpadSession", 1, [scratchpadSessions]);
+
+  ok(DevToolsShim.isInitialized(), "DevTools are initialized");
+
+  DevToolsShim.getOpenedScratchpads();
+  checkCalls(mock, "getOpenedScratchpads", 1, []);
 }
 
 function run_test() {
   test_register_unregister();
   DevToolsShim.unregister();
 
   test_on_is_forwarded_to_devtools();
   DevToolsShim.unregister();