Bug 1365554 - Fix storage inspector failures in browser_devtools_api.js r=jdescottes
authorMichael Ratcliffe <mratcliffe@mozilla.com>
Fri, 02 Jun 2017 14:15:41 +0100
changeset 410234 2c0e0f3062aeb2e1bca2b743ab0d82ca19619c9e
parent 410233 3c59f4cceb9a7f4acca9331409c91d148405382c
child 410235 4db381159f27a7d1a1b5d112be7441290dc12550
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjdescottes
bugs1365554
milestone55.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 1365554 - Fix storage inspector failures in browser_devtools_api.js r=jdescottes The changes to devtools/client/framework/test/browser_devtools_api.js are purely eslint fixes so you only need to glance over them. The changes to ui.js checks if the toolbox is being destroyed... if it is we don't log an error, otherwise we do. MozReview-Commit-ID: JJTqkYXVsYG
devtools/client/framework/test/browser_devtools_api.js
devtools/client/storage/ui.js
--- a/devtools/client/framework/test/browser_devtools_api.js
+++ b/devtools/client/framework/test/browser_devtools_api.js
@@ -1,24 +1,26 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* Any copyright is dedicated to the Public Domain.
  * http://creativecommons.org/publicdomain/zero/1.0/ */
 
 // Tests devtools API
 
+"use strict";
+
 const toolId1 = "test-tool-1";
 const toolId2 = "test-tool-2";
 
 function test() {
   addTab("about:blank").then(runTests1);
 }
 
 // Test scenario 1: the tool definition build method returns a promise.
-function runTests1(aTab) {
+function runTests1(tab) {
   let toolDefinition = {
     id: toolId1,
     isTargetSupported: () => true,
     visibilityswitch: "devtools.test-tool.enabled",
     url: "about:blank",
     label: "someLabel",
     build: function (iframeWindow, toolbox) {
       let panel = createTestPanel(iframeWindow, toolbox);
@@ -37,37 +39,37 @@ function runTests1(aTab) {
   let target = TargetFactory.forTab(gBrowser.selectedTab);
 
   let events = {};
 
   // Check events on the gDevTools and toolbox objects.
   gDevTools.once(toolId1 + "-init", (event, toolbox, iframe) => {
     ok(iframe, "iframe argument available");
 
-    toolbox.once(toolId1 + "-init", (event, iframe) => {
-      ok(iframe, "iframe argument available");
-      events["init"] = true;
+    toolbox.once(toolId1 + "-init", (innerEvent, innerIframe) => {
+      ok(innerIframe, "innerIframe argument available");
+      events.init = true;
     });
   });
 
   gDevTools.once(toolId1 + "-ready", (event, toolbox, panel) => {
     ok(panel, "panel argument available");
 
-    toolbox.once(toolId1 + "-ready", (event, panel) => {
-      ok(panel, "panel argument available");
-      events["ready"] = true;
+    toolbox.once(toolId1 + "-ready", (innerEvent, innerPanel) => {
+      ok(innerPanel, "innerPanel argument available");
+      events.ready = true;
     });
   });
 
   gDevTools.showToolbox(target, toolId1).then(function (toolbox) {
     is(toolbox.target, target, "toolbox target is correct");
     is(toolbox.target.tab, gBrowser.selectedTab, "targeted tab is correct");
 
-    ok(events["init"], "init event fired");
-    ok(events["ready"], "ready event fired");
+    ok(events.init, "init event fired");
+    ok(events.ready, "ready event fired");
 
     gDevTools.unregisterTool(toolId1);
 
     // Wait for unregisterTool to select the next tool before calling runTests2,
     // otherwise we will receive the wrong select event when waiting for
     // unregisterTool to select the next tool in continueTests below.
     toolbox.once("select", runTests2);
   });
@@ -96,47 +98,47 @@ function runTests2() {
   let target = TargetFactory.forTab(gBrowser.selectedTab);
 
   let events = {};
 
   // Check events on the gDevTools and toolbox objects.
   gDevTools.once(toolId2 + "-init", (event, toolbox, iframe) => {
     ok(iframe, "iframe argument available");
 
-    toolbox.once(toolId2 + "-init", (event, iframe) => {
-      ok(iframe, "iframe argument available");
-      events["init"] = true;
+    toolbox.once(toolId2 + "-init", (innerEvent, innerIframe) => {
+      ok(innerIframe, "innerIframe argument available");
+      events.init = true;
     });
   });
 
   gDevTools.once(toolId2 + "-build", (event, toolbox, panel, iframe) => {
     ok(panel, "panel argument available");
 
-    toolbox.once(toolId2 + "-build", (event, panel, iframe) => {
-      ok(panel, "panel argument available");
-      events["build"] = true;
+    toolbox.once(toolId2 + "-build", (innerEvent, innerPanel, innerIframe) => {
+      ok(innerPanel, "innerPanel argument available");
+      events.build = true;
     });
   });
 
   gDevTools.once(toolId2 + "-ready", (event, toolbox, panel) => {
     ok(panel, "panel argument available");
 
-    toolbox.once(toolId2 + "-ready", (event, panel) => {
-      ok(panel, "panel argument available");
-      events["ready"] = true;
+    toolbox.once(toolId2 + "-ready", (innerEvent, innerPanel) => {
+      ok(innerPanel, "innerPanel argument available");
+      events.ready = true;
     });
   });
 
   gDevTools.showToolbox(target, toolId2).then(function (toolbox) {
     is(toolbox.target, target, "toolbox target is correct");
     is(toolbox.target.tab, gBrowser.selectedTab, "targeted tab is correct");
 
-    ok(events["init"], "init event fired");
-    ok(events["build"], "build event fired");
-    ok(events["ready"], "ready event fired");
+    ok(events.init, "init event fired");
+    ok(events.build, "build event fired");
+    ok(events.ready, "ready event fired");
 
     continueTests(toolbox);
   });
 }
 
 var continueTests = Task.async(function* (toolbox, panel) {
   ok(toolbox.getCurrentPanel(), "panel value is correct");
   is(toolbox.currentToolId, toolId2, "toolbox _currentToolId is correct");
@@ -179,16 +181,17 @@ var continueTests = Task.async(function*
   ok(toolbox.isToolRegistered(toolId2),
     "Toolbox: The tool is registered");
   ok(gDevTools.getToolDefinitionMap().has(toolId2),
     "The tool is registered");
 
   info("Unregistering tool");
   gDevTools.unregisterTool(toolId2);
 
+  info("Destroying toolbox");
   destroyToolbox(toolbox);
 });
 
 function destroyToolbox(toolbox) {
   toolbox.destroy().then(function () {
     let target = TargetFactory.forTab(gBrowser.selectedTab);
     ok(gDevTools._toolboxes.get(target) == null, "gDevTools doesn't know about target");
     ok(toolbox.target == null, "toolbox doesn't know about target.");
--- a/devtools/client/storage/ui.js
+++ b/devtools/client/storage/ui.js
@@ -137,17 +137,26 @@ function StorageUI(front, target, panelW
   let key = L10N.getStr("storage.filter.key");
   shortcuts.on(key, (name, event) => {
     event.preventDefault();
     this.searchBox.focus();
   });
 
   this.front.listStores().then(storageTypes => {
     this.populateStorageTree(storageTypes);
-  }).then(null, console.error);
+  }).catch(e => {
+    if (!this._toolbox || this._toolbox._destroyer) {
+      // The toolbox is in the process of being destroyed... in this case throwing here
+      // is expected and normal so let's ignore the error.
+      return;
+    }
+
+    // The toolbox is open so the error is unexpected and real so let's log it.
+    console.error(e);
+  });
 
   this.onUpdate = this.onUpdate.bind(this);
   this.front.on("stores-update", this.onUpdate);
   this.onCleared = this.onCleared.bind(this);
   this.front.on("stores-cleared", this.onCleared);
 
   this.handleKeypress = this.handleKeypress.bind(this);
   this._panelDoc.addEventListener("keypress", this.handleKeypress);