Backed out changeset 71b891583296 (bug 1369801)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Thu, 27 Jul 2017 18:13:58 +0200
changeset 420069 ce6144ec89d2d2e0cd1c6e64bc05a0ddd0c54ab4
parent 420068 05dc322d7fed3c88b83040e9596ce8ae19422c98
child 420070 952d7e686b62e994ca019028b0eac1281fff4990
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)
bugs1369801
milestone56.0a1
backs out71b891583296678bceb312953e7fd5b1c3bec2d7
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 71b891583296 (bug 1369801) MozReview-Commit-ID: A6KDPVjAL8X
devtools/shim/DevToolsShim.jsm
devtools/shim/tests/unit/test_devtools_shim.js
--- a/devtools/shim/DevToolsShim.jsm
+++ b/devtools/shim/DevToolsShim.jsm
@@ -204,17 +204,21 @@ this.DevToolsShim = {
    * Called from SessionStore.jsm in mozilla-central when restoring a state that contained
    * opened scratchpad windows.
    */
   restoreScratchpadSession: function (scratchpads) {
     if (!this.isInstalled()) {
       return;
     }
 
-    this.gDevTools.restoreScratchpadSession(scratchpads);
+    if (!this.isInitialized()) {
+      this._initDevTools();
+    }
+
+    this._gDevTools.restoreScratchpadSession(scratchpads);
   },
 
   /**
    * Called from nsContextMenu.js in mozilla-central when using the Inspect Element
    * context menu item.
    *
    * @param {XULTab} tab
    *        The browser tab on which inspect node was used.
--- a/devtools/shim/tests/unit/test_devtools_shim.js
+++ b/devtools/shim/tests/unit/test_devtools_shim.js
@@ -1,17 +1,20 @@
 /* -*- js-indent-level: 2; indent-tabs-mode: nil -*- */
 /* Any copyright is dedicated to the Public Domain.
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
-const { DevToolsShim } =
+const { DevToolsShim: realDevToolsShim } =
     Components.utils.import("chrome://devtools-shim/content/DevToolsShim.jsm", {});
 
+// Create a copy of the DevToolsShim for the test.
+const DevToolsShim = Object.assign({}, realDevToolsShim);
+
 // Test the DevToolsShim
 
 /**
  * Create a mocked version of DevTools that records all calls made to methods expected
  * to be called by DevToolsShim.
  */
 function createMockDevTools() {
   let methods = [
@@ -36,23 +39,21 @@ function createMockDevTools() {
       mock.callLog[method].push(args);
     };
     mock.callLog[method] = [];
   }
 
   return mock;
 }
 
-let isInstalledMethodBackup = DevToolsShim.isInstalled;
 function mockDevToolsInstalled() {
   DevToolsShim.isInstalled = () => true;
 }
-
-function restoreDevToolsInstalled() {
-  DevToolsShim.isInstalled = isInstalledMethodBackup;
+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.
  */
 function checkCalls(mock, method, length, lastArgs) {
   ok(mock.callLog[method].length === length,
@@ -66,87 +67,71 @@ function checkCalls(mock, method, length
   for (let i = 0; i < lastArgs.length; i++) {
     let expectedArg = lastArgs[i];
     ok(mock.callLog[method][length - 1][i] === expectedArg,
         `Devtools.${method} was called with the expected argument (index ${i})`);
   }
 }
 
 function test_register_unregister() {
-  mockDevToolsInstalled();
-
   ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
 
   DevToolsShim.register(createMockDevTools());
   ok(DevToolsShim.isInitialized(), "DevTools are installed");
 
   DevToolsShim.unregister();
   ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
-
-  restoreDevToolsInstalled();
 }
 
 function test_on_is_forwarded_to_devtools() {
   ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
 
   function cb1() {}
   function cb2() {}
   let mock = createMockDevTools();
 
   DevToolsShim.on("test_event", cb1);
   DevToolsShim.register(mock);
   checkCalls(mock, "on", 1, ["test_event", cb1]);
 
   DevToolsShim.on("other_event", cb2);
   checkCalls(mock, "on", 2, ["other_event", cb2]);
-
-  restoreDevToolsInstalled();
 }
 
 function test_off_called_before_registering_devtools() {
-  mockDevToolsInstalled();
-
   ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
 
   function cb1() {}
   let mock = createMockDevTools();
 
   DevToolsShim.on("test_event", cb1);
   DevToolsShim.off("test_event", cb1);
 
   DevToolsShim.register(mock);
   checkCalls(mock, "on", 0);
-
-  restoreDevToolsInstalled();
 }
 
 function test_off_called_before_with_bad_callback() {
-  mockDevToolsInstalled();
-
   ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
 
   function cb1() {}
   function cb2() {}
   let mock = createMockDevTools();
 
   DevToolsShim.on("test_event", cb1);
   DevToolsShim.off("test_event", cb2);
 
   DevToolsShim.register(mock);
   // on should still be called
   checkCalls(mock, "on", 1, ["test_event", cb1]);
   // Calls to off should not be held and forwarded.
   checkCalls(mock, "off", 0);
-
-  restoreDevToolsInstalled();
 }
 
 function test_registering_tool() {
-  mockDevToolsInstalled();
-
   ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
 
   let tool1 = {};
   let tool2 = {};
   let tool3 = {};
   let mock = createMockDevTools();
 
   // Pre-register tool1
@@ -163,23 +148,19 @@ function test_registering_tool() {
   checkCalls(mock, "registerTool", 2, [tool2]);
 
   DevToolsShim.unregister();
 
   // Create a new mock and check the tools are not added once again.
   mock = createMockDevTools();
   DevToolsShim.register(mock);
   checkCalls(mock, "registerTool", 0);
-
-  restoreDevToolsInstalled();
 }
 
 function test_registering_theme() {
-  mockDevToolsInstalled();
-
   ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
 
   let theme1 = {};
   let theme2 = {};
   let theme3 = {};
   let mock = createMockDevTools();
 
   // Pre-register theme1
@@ -196,41 +177,37 @@ function test_registering_theme() {
   checkCalls(mock, "registerTheme", 2, [theme2]);
 
   DevToolsShim.unregister();
 
   // Create a new mock and check the themes are not added once again.
   mock = createMockDevTools();
   DevToolsShim.register(mock);
   checkCalls(mock, "registerTheme", 0);
-
-  restoreDevToolsInstalled();
 }
 
 function test_events() {
-  mockDevToolsInstalled();
-
   ok(!DevToolsShim.isInitialized(), "DevTools are not initialized");
 
   let mock = createMockDevTools();
   // Check emit was not called.
   checkCalls(mock, "emit", 0);
 
   // Check emit is called once with the devtools-registered event.
   DevToolsShim.register(mock);
   checkCalls(mock, "emit", 1, ["devtools-registered"]);
 
   // Check emit is called once with the devtools-unregistered event.
   DevToolsShim.unregister();
   checkCalls(mock, "emit", 2, ["devtools-unregistered"]);
-
-  restoreDevToolsInstalled();
 }
 
 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");
@@ -257,18 +234,16 @@ function test_scratchpad_apis() {
   let scratchpadSessions = [{}];
   DevToolsShim.restoreScratchpadSession(scratchpadSessions);
   checkCalls(mock, "restoreScratchpadSession", 1, [scratchpadSessions]);
 
   ok(DevToolsShim.isInitialized(), "DevTools are initialized");
 
   DevToolsShim.getOpenedScratchpads();
   checkCalls(mock, "getOpenedScratchpads", 1, []);
-
-  restoreDevToolsInstalled();
 }
 
 function run_test() {
   test_register_unregister();
   DevToolsShim.unregister();
 
   test_on_is_forwarded_to_devtools();
   DevToolsShim.unregister();