Backed out changeset 2dd30b065030 (bug 1359855)
authorCarsten "Tomcat" Book <cbook@mozilla.com>
Mon, 24 Jul 2017 12:07:02 +0200
changeset 419250 263f0b999ae1239dc1850c528a9f80b4949fc52a
parent 419249 22d7b65df1345614ecaded08cb1113a387ee7c52
child 419251 5c5cd7954f5ce97a1d08dcb32b07c1b4d56b8411
push id7566
push usermtabara@mozilla.com
push dateWed, 02 Aug 2017 08:25:16 +0000
treeherdermozilla-beta@86913f512c3c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1359855
milestone56.0a1
backs out2dd30b065030bab3f0e2b231822302eda90b6039
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
Backed out changeset 2dd30b065030 (bug 1359855)
devtools/shim/DevToolsShim.jsm
devtools/shim/tests/unit/test_devtools_shim.js
--- a/devtools/shim/DevToolsShim.jsm
+++ b/devtools/shim/DevToolsShim.jsm
@@ -170,18 +170,22 @@ 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()) {
+      return [];
+    }
+
     if (!this.isInitialized()) {
-      return [];
+      this._initDevTools();
     }
 
     return this.gDevTools.getOpenedScratchpads();
   },
 
   /**
    * Called from SessionStore.jsm in mozilla-central when restoring a state that contained
    * opened scratchpad windows.
--- a/devtools/shim/tests/unit/test_devtools_shim.js
+++ b/devtools/shim/tests/unit/test_devtools_shim.js
@@ -42,16 +42,17 @@ 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.
  */
@@ -199,51 +200,39 @@ 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");
 
-  mockDevToolsInstalled();
+  let mock = createMockDevTools();
 
-  ok(DevToolsShim.isInstalled(), "DevTools are installed");
-  ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
-
-  let mock = createMockDevTools();
+  mockDevToolsInstalled();
   DevToolsShim._initDevTools = () => {
-    // Next call to restoreScratchpadSession is expected to initialize DevTools, which we
+    // Next call to getOpenedScratchpags 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();