Bug 1246514 - Fix eslint errors in files touched in this bug. r=bgrins
authorNicolas Chevobbe <chevobbe.nicolas@gmail.com>
Fri, 11 Mar 2016 22:23:53 +0100
changeset 289153 5c5cf183a60890e651380e00533ce10d60375ffb
parent 289152 2ddb3191c7f0ad04961e6cada4d6cc90f13b5f50
child 289154 4a09c0fed0470d8d29542e96b0e665199659269b
push id30098
push usercbook@mozilla.com
push dateFri, 18 Mar 2016 14:32:34 +0000
treeherdermozilla-central@3d37c7e5b8dd [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbgrins
bugs1246514
milestone48.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 1246514 - Fix eslint errors in files touched in this bug. r=bgrins MozReview-Commit-ID: LSs3NUsMXLN
devtools/client/framework/test/browser_toolbox_options.js
devtools/client/framework/test/browser_toolbox_options_disable_buttons.js
devtools/client/framework/test/browser_toolbox_theme_registration.js
devtools/client/framework/toolbox-options.js
--- a/devtools/client/framework/test/browser_toolbox_options.js
+++ b/devtools/client/framework/test/browser_toolbox_options.js
@@ -1,20 +1,24 @@
 /* -*- 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/ */
 
+/* import-globals-from shared-head.js */
+"use strict";
+
 // Tests that changing preferences in the options panel updates the prefs
 // and toggles appropriate things in the toolbox.
 
 var doc = null, toolbox = null, panelWin = null, modifiedPrefs = [];
 
 add_task(function*() {
-  const URL = "data:text/html;charset=utf8,test for dynamically registering and unregistering tools";
+  const URL = "data:text/html;charset=utf8,test for dynamically registering " +
+              "and unregistering tools";
   registerNewTool();
   let tab = yield addTab(URL);
   let target = TargetFactory.forTab(tab);
   toolbox = yield gDevTools.showToolbox(target);
   doc = toolbox.doc;
   yield testSelectTool();
   yield testOptionsShortcut();
   yield testOptions();
@@ -36,26 +40,26 @@ function registerNewTool() {
     "The tool is not registered");
 
   gDevTools.registerTool(toolDefinition);
   ok(gDevTools.getToolDefinitionMap().has("test-tool"),
     "The tool is registered");
 }
 
 function* testSelectTool() {
-  info ("Checking to make sure that the options panel can be selected.");
+  info("Checking to make sure that the options panel can be selected.");
 
   let onceSelected = toolbox.once("options-selected");
   toolbox.selectTool("options");
   yield onceSelected;
   ok(true, "Toolbox selected via selectTool method");
 }
 
 function* testOptionsShortcut() {
-  info ("Selecting another tool, then reselecting options panel with keyboard.");
+  info("Selecting another tool, then reselecting options panel with keyboard.");
 
   yield toolbox.selectTool("webconsole");
   is(toolbox.currentToolId, "webconsole", "webconsole is selected");
   synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key"));
   is(toolbox.currentToolId, "options", "Toolbox selected via shortcut key (1)");
   synthesizeKeyFromKeyTag(doc.getElementById("toolbox-options-key"));
   is(toolbox.currentToolId, "webconsole", "webconsole is selected (1)");
 
@@ -109,17 +113,17 @@ function* testSelect(select) {
     if (options.indexOf(option) === select.selectedIndex) {
       continue;
     }
 
     let deferred = promise.defer();
     gDevTools.once("pref-changed", (event, data) => {
       if (data.pref == pref) {
         ok(true, "Correct pref was changed");
-        is (GetPref(pref), option.value, "Preference been switched for " + pref);
+        is(GetPref(pref), option.value, "Preference been switched for " + pref);
       } else {
         ok(false, "Pref " + pref + " was not changed correctly");
       }
       deferred.resolve();
     });
 
     select.selectedIndex = options.indexOf(option);
     let changeEvent = new Event("change");
@@ -163,17 +167,17 @@ function* testToggleTools() {
   let enabledTools = [...toolNodes].filter(node => node.checked);
 
   let toggleableTools = gDevTools.getDefaultTools().filter(tool => {
     return tool.visibilityswitch;
   }).concat(gDevTools.getAdditionalTools());
 
   for (let node of toolNodes) {
     let id = node.getAttribute("id");
-    ok (toggleableTools.some(tool => tool.id === id),
+    ok(toggleableTools.some(tool => tool.id === id),
       "There should be a toggle checkbox for: " + id);
   }
 
   // Store modified pref names so that they can be cleared on error.
   for (let tool of toggleableTools) {
     let pref = tool.visibilityswitch;
     modifiedPrefs.push(pref);
   }
@@ -194,49 +198,51 @@ function* testToggleTools() {
   }
   // Re-enable the tools which are enabled by default
   for (let node of enabledTools) {
     yield toggleTool(node);
   }
 
   // Toggle first, middle, and last tools to ensure that toolbox tabs are
   // inserted in order
-  let firstTool  = toolNodes[0],
-      middleTool = toolNodes[(toolNodes.length / 2) | 0],
-      lastTool   = toolNodes[toolNodes.length - 1];
+  let firstTool = toolNodes[0];
+  let middleTool = toolNodes[(toolNodes.length / 2) | 0];
+  let lastTool = toolNodes[toolNodes.length - 1];
 
   yield toggleTool(firstTool);
   yield toggleTool(firstTool);
   yield toggleTool(middleTool);
   yield toggleTool(middleTool);
   yield toggleTool(lastTool);
   yield toggleTool(lastTool);
 }
 
 function* toggleTool(node) {
   let deferred = promise.defer();
 
   let toolId = node.getAttribute("id");
-  let onRegistrationChange;
   if (node.checked) {
-    gDevTools.once("tool-unregistered", checkUnregistered.bind(null, toolId, deferred));
+    gDevTools.once("tool-unregistered",
+      checkUnregistered.bind(null, toolId, deferred));
   } else {
-    gDevTools.once("tool-registered", checkRegistered.bind(null, toolId, deferred));
+    gDevTools.once("tool-registered",
+      checkRegistered.bind(null, toolId, deferred));
   }
   node.scrollIntoView();
   EventUtils.synthesizeMouseAtCenter(node, {}, panelWin);
 
   yield deferred.promise;
 }
 
 function checkUnregistered(toolId, deferred, event, data) {
   if (data.id == toolId) {
     ok(true, "Correct tool removed");
     // checking tab on the toolbox
-    ok(!doc.getElementById("toolbox-tab-" + toolId), "Tab removed for " + toolId);
+    ok(!doc.getElementById("toolbox-tab-" + toolId),
+      "Tab removed for " + toolId);
   } else {
     ok(false, "Something went wrong, " + toolId + " was not unregistered");
   }
   deferred.resolve();
 }
 
 function checkRegistered(toolId, deferred, event, data) {
   if (data == toolId) {
--- a/devtools/client/framework/test/browser_toolbox_options_disable_buttons.js
+++ b/devtools/client/framework/test/browser_toolbox_options_disable_buttons.js
@@ -1,134 +1,150 @@
 /* -*- 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/ */
 
+/* import-globals-from shared-head.js */
+"use strict";
+
 var doc = null, toolbox = null, panelWin = null, modifiedPrefs = [];
 
 function test() {
   gBrowser.selectedTab = gBrowser.addTab();
   let target = TargetFactory.forTab(gBrowser.selectedTab);
 
   gBrowser.selectedBrowser.addEventListener("load", function onLoad(evt) {
     gBrowser.selectedBrowser.removeEventListener(evt.type, onLoad, true);
     gDevTools.showToolbox(target)
       .then(testSelectTool)
       .then(testToggleToolboxButtons)
       .then(testPrefsAreRespectedWhenReopeningToolbox)
       .then(cleanup, errorHandler);
   }, true);
 
-  content.location = "data:text/html;charset=utf8,test for dynamically registering and unregistering tools";
+  content.location = "data:text/html;charset=utf8,test for dynamically " +
+                     "registering and unregistering tools";
 }
 
 function testPrefsAreRespectedWhenReopeningToolbox() {
   let deferred = promise.defer();
   let target = TargetFactory.forTab(gBrowser.selectedTab);
 
-  info ("Closing toolbox to test after reopening");
+  info("Closing toolbox to test after reopening");
   gDevTools.closeToolbox(target).then(() => {
-    let target = TargetFactory.forTab(gBrowser.selectedTab);
-    gDevTools.showToolbox(target)
+    let tabTarget = TargetFactory.forTab(gBrowser.selectedTab);
+    gDevTools.showToolbox(tabTarget)
       .then(testSelectTool)
       .then(() => {
-        info ("Toolbox has been reopened.  Checking UI state.");
+        info("Toolbox has been reopened.  Checking UI state.");
         testPreferenceAndUIStateIsConsistent();
         deferred.resolve();
       });
   });
 
   return deferred.promise;
 }
 
-function testSelectTool(aToolbox) {
+function testSelectTool(devtoolsToolbox) {
   let deferred = promise.defer();
-  info ("Selecting the options panel");
+  info("Selecting the options panel");
 
-  toolbox = aToolbox;
+  toolbox = devtoolsToolbox;
   doc = toolbox.doc;
   toolbox.once("options-selected", (event, tool) => {
     ok(true, "Options panel selected via selectTool method");
     panelWin = tool.panelWin;
     deferred.resolve();
   });
   toolbox.selectTool("options");
 
   return deferred.promise;
 }
 
 function testPreferenceAndUIStateIsConsistent() {
-  let checkNodes = [...panelWin.document.querySelectorAll("#enabled-toolbox-buttons-box input[type=checkbox]")];
+  let checkNodes = [...panelWin.document.querySelectorAll(
+    "#enabled-toolbox-buttons-box input[type=checkbox]")];
   let toolboxButtonNodes = [...doc.querySelectorAll(".command-button")];
   toolboxButtonNodes.push(doc.getElementById("command-button-frames"));
   let toggleableTools = toolbox.toolboxButtons;
 
   // The noautohide button is only displayed in the browser toolbox
-  toggleableTools = toggleableTools.filter(tool => tool.id != "command-button-noautohide");
+  toggleableTools = toggleableTools.filter(
+    tool => tool.id != "command-button-noautohide");
 
   for (let tool of toggleableTools) {
     let isVisible = getBoolPref(tool.visibilityswitch);
 
-    let button = toolboxButtonNodes.filter(button => button.id === tool.id)[0];
-    is (!button.hasAttribute("hidden"), isVisible, "Button visibility matches pref for " + tool.id);
+    let button = toolboxButtonNodes.filter(
+      toolboxButton => toolboxButton.id === tool.id)[0];
+    is(!button.hasAttribute("hidden"), isVisible,
+      "Button visibility matches pref for " + tool.id);
 
-    let check = checkNodes.filter(node=>node.id === tool.id)[0];
-    is (check.checked, isVisible, "Checkbox should be selected based on current pref for " + tool.id);
+    let check = checkNodes.filter(node => node.id === tool.id)[0];
+    is(check.checked, isVisible,
+      "Checkbox should be selected based on current pref for " + tool.id);
   }
 }
 
 function testToggleToolboxButtons() {
-  let checkNodes = [...panelWin.document.querySelectorAll("#enabled-toolbox-buttons-box input[type=checkbox]")];
+  let checkNodes = [...panelWin.document.querySelectorAll(
+    "#enabled-toolbox-buttons-box input[type=checkbox]")];
   let toolboxButtonNodes = [...doc.querySelectorAll(".command-button")];
   let toggleableTools = toolbox.toolboxButtons;
 
   // The noautohide button is only displayed in the browser toolbox
-  toggleableTools = toggleableTools.filter(tool => tool.id != "command-button-noautohide");
-  toolboxButtonNodes = toolboxButtonNodes.filter(btn => btn.id != "command-button-noautohide");
+  toggleableTools = toggleableTools.filter(
+    tool => tool.id != "command-button-noautohide");
+  toolboxButtonNodes = toolboxButtonNodes.filter(
+    btn => btn.id != "command-button-noautohide");
 
-  is (checkNodes.length, toggleableTools.length, "All of the buttons are toggleable." );
-  is (checkNodes.length, toolboxButtonNodes.length, "All of the DOM buttons are toggleable." );
+  is(checkNodes.length, toggleableTools.length,
+    "All of the buttons are toggleable.");
+  is(checkNodes.length, toolboxButtonNodes.length,
+    "All of the DOM buttons are toggleable.");
 
   for (let tool of toggleableTools) {
     let id = tool.id;
-    let matchedCheckboxes = checkNodes.filter(node=>node.id === id);
-    let matchedButtons = toolboxButtonNodes.filter(button=>button.id === id);
-    is (matchedCheckboxes.length, 1,
+    let matchedCheckboxes = checkNodes.filter(node => node.id === id);
+    let matchedButtons = toolboxButtonNodes.filter(button => button.id === id);
+    is(matchedCheckboxes.length, 1,
       "There should be a single toggle checkbox for: " + id);
-    is (matchedButtons.length, 1,
+    is(matchedButtons.length, 1,
       "There should be a DOM button for: " + id);
-    is (matchedButtons[0], tool.button,
+    is(matchedButtons[0], tool.button,
       "DOM buttons should match for: " + id);
 
-    is (matchedCheckboxes[0].nextSibling.textContent, tool.label,
+    is(matchedCheckboxes[0].nextSibling.textContent, tool.label,
       "The label for checkbox matches the tool definition.");
-    is (matchedButtons[0].getAttribute("tooltiptext"), tool.label,
+    is(matchedButtons[0].getAttribute("tooltiptext"), tool.label,
       "The tooltip for button matches the tool definition.");
   }
 
   // Store modified pref names so that they can be cleared on error.
   for (let tool of toggleableTools) {
     let pref = tool.visibilityswitch;
     modifiedPrefs.push(pref);
   }
 
   // Try checking each checkbox, making sure that it changes the preference
   for (let node of checkNodes) {
-    let tool = toggleableTools.filter(tool=>tool.id === node.id)[0];
+    let tool = toggleableTools.filter(
+      toggleableTool => toggleableTool.id === node.id)[0];
     let isVisible = getBoolPref(tool.visibilityswitch);
 
     testPreferenceAndUIStateIsConsistent();
     node.click();
     testPreferenceAndUIStateIsConsistent();
 
     let isVisibleAfterClick = getBoolPref(tool.visibilityswitch);
 
-    is (isVisible, !isVisibleAfterClick,
-      "Clicking on the node should have toggled visibility preference for " + tool.visibilityswitch);
+    is(isVisible, !isVisibleAfterClick,
+      "Clicking on the node should have toggled visibility preference for " +
+      tool.visibilityswitch);
   }
 
   return promise.resolve();
 }
 
 function getBoolPref(key) {
   return Services.prefs.getBoolPref(key);
 }
--- a/devtools/client/framework/test/browser_toolbox_theme_registration.js
+++ b/devtools/client/framework/test/browser_toolbox_theme_registration.js
@@ -1,26 +1,29 @@
 /* -*- 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/ */
 
+/* import-globals-from shared-head.js */
+"use strict";
+
 // Test for dynamically registering and unregistering themes
 const CHROME_URL = "chrome://mochitests/content/browser/devtools/client/framework/test/";
 
 var toolbox;
 
 add_task(function* themeRegistration() {
   let tab = yield addTab("data:text/html,test");
   let target = TargetFactory.forTab(tab);
   toolbox = yield gDevTools.showToolbox(target, "options");
 
   let themeId = yield new Promise(resolve => {
-    gDevTools.once("theme-registered", (e, themeId) => {
-      resolve(themeId);
+    gDevTools.once("theme-registered", (e, registeredThemeId) => {
+      resolve(registeredThemeId);
     });
 
     gDevTools.registerTheme({
       id: "test-theme",
       label: "Test theme",
       stylesheets: [CHROME_URL + "doc_theme.css"],
       classList: ["theme-test"],
     });
@@ -74,17 +77,18 @@ add_task(function* themeInOptionsPanel()
   yield onThemeSwithComplete;
 });
 
 add_task(function* themeUnregistration() {
   let onUnRegisteredTheme = once(gDevTools, "theme-unregistered");
   gDevTools.unregisterTheme("test-theme");
   yield onUnRegisteredTheme;
 
-  ok(!gDevTools.getThemeDefinitionMap().has("test-theme"), "theme removed from map");
+  ok(!gDevTools.getThemeDefinitionMap().has("test-theme"),
+    "theme removed from map");
 
   let panelWin = toolbox.getCurrentPanel().panelWin;
   let doc = panelWin.frameElement.contentDocument;
   let themeBox = doc.getElementById("devtools-theme-box");
 
   // The default light theme must be selected now.
   is(themeBox.querySelector("#devtools-theme-box [value=light]").checked, true,
     "light theme must be selected");
--- a/devtools/client/framework/toolbox-options.js
+++ b/devtools/client/framework/toolbox-options.js
@@ -1,36 +1,35 @@
 /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */
 /* vim: set ft=javascript ts=2 et sw=2 tw=80: */
 /* This Source Code Form is subject to the terms of the Mozilla Public
  * License, v. 2.0. If a copy of the MPL was not distributed with this
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
-const {Cu, Cc, Ci} = require("chrome");
+const {Cu} = require("chrome");
 const Services = require("Services");
 const promise = require("promise");
 Cu.import("resource://gre/modules/XPCOMUtils.jsm");
 Cu.import("resource://gre/modules/Task.jsm");
 const {gDevTools} = require("devtools/client/framework/devtools");
 
 exports.OptionsPanel = OptionsPanel;
 
 XPCOMUtils.defineLazyGetter(this, "l10n", function() {
   let bundle = Services.strings.createBundle("chrome://devtools/locale/toolbox.properties");
-  let l10n = function(aName, ...aArgs) {
+  let l10n = function(name, ...aArgs) {
     try {
       if (aArgs.length == 0) {
-        return bundle.GetStringFromName(aName);
-      } else {
-        return bundle.formatStringFromName(aName, aArgs, aArgs.length);
+        return bundle.GetStringFromName(name);
       }
+      return bundle.formatStringFromName(name, aArgs, aArgs.length);
     } catch (ex) {
-      Services.console.logStringMessage("Error reading '" + aName + "'");
+      Services.console.logStringMessage("Error reading '" + name + "'");
     }
   };
   return l10n;
 });
 
 function GetPref(name) {
   let type = Services.prefs.getPrefType(name);
   switch (type) {
@@ -62,33 +61,33 @@ function SetPref(name, value) {
 function InfallibleGetBoolPref(key) {
   try {
     return Services.prefs.getBoolPref(key);
   } catch (ex) {
     return true;
   }
 }
 
-
 /**
  * Represents the Options Panel in the Toolbox.
  */
 function OptionsPanel(iframeWindow, toolbox) {
   this.panelDoc = iframeWindow.document;
   this.panelWin = iframeWindow;
 
   this.toolbox = toolbox;
   this.isReady = false;
 
   this._prefChanged = this._prefChanged.bind(this);
   this._themeRegistered = this._themeRegistered.bind(this);
   this._themeUnregistered = this._themeUnregistered.bind(this);
   this._disableJSClicked = this._disableJSClicked.bind(this);
 
-  this.disableJSNode = this.panelDoc.getElementById("devtools-disable-javascript");
+  this.disableJSNode = this.panelDoc.getElementById(
+    "devtools-disable-javascript");
 
   this._addListeners();
 
   const EventEmitter = require("devtools/shared/event-emitter");
   EventEmitter.decorate(this);
 }
 
 OptionsPanel.prototype = {
@@ -125,18 +124,17 @@ OptionsPanel.prototype = {
   },
 
   _prefChanged: function(event, data) {
     if (data.pref === "devtools.cache.disabled") {
       let cacheDisabled = data.newValue;
       let cbx = this.panelDoc.getElementById("devtools-disable-cache");
 
       cbx.checked = cacheDisabled;
-    }
-    else if (data.pref === "devtools.theme") {
+    } else if (data.pref === "devtools.theme") {
       this.updateCurrentTheme();
     }
   },
 
   _themeRegistered: function(event, themeId) {
     this.setupThemeList();
   },
 
@@ -153,18 +151,20 @@ OptionsPanel.prototype = {
     let enabledToolbarButtonsBox = this.panelDoc.getElementById(
       "enabled-toolbox-buttons-box");
 
     let toggleableButtons = this.toolbox.toolboxButtons;
     let setToolboxButtonsVisibility =
       this.toolbox.setToolboxButtonsVisibility.bind(this.toolbox);
 
     let onCheckboxClick = (checkbox) => {
-      let toolDefinition = toggleableButtons.filter(tool => tool.id === checkbox.id)[0];
-      Services.prefs.setBoolPref(toolDefinition.visibilityswitch, checkbox.checked);
+      let toolDefinition = toggleableButtons.filter(
+        toggleableButton => toggleableButton.id === checkbox.id)[0];
+      Services.prefs.setBoolPref(
+        toolDefinition.visibilityswitch, checkbox.checked);
       setToolboxButtonsVisibility();
     };
 
     let createCommandCheckbox = tool => {
       let checkboxLabel = this.panelDoc.createElement("label");
       let checkboxSpanLabel = this.panelDoc.createElement("span");
       checkboxSpanLabel.textContent = tool.label;
       let checkboxInput = this.panelDoc.createElement("input");
@@ -187,44 +187,44 @@ OptionsPanel.prototype = {
       }
 
       enabledToolbarButtonsBox.appendChild(createCommandCheckbox(tool));
     }
   },
 
   setupToolsList: function() {
     let defaultToolsBox = this.panelDoc.getElementById("default-tools-box");
-    let additionalToolsBox = this.panelDoc.getElementById("additional-tools-box");
-    let toolsNotSupportedLabel = this.panelDoc.getElementById("tools-not-supported-label");
+    let additionalToolsBox = this.panelDoc.getElementById(
+      "additional-tools-box");
+    let toolsNotSupportedLabel = this.panelDoc.getElementById(
+      "tools-not-supported-label");
     let atleastOneToolNotSupported = false;
 
     let onCheckboxClick = function(id) {
       let toolDefinition = gDevTools._tools.get(id);
       // Set the kill switch pref boolean to true
       Services.prefs.setBoolPref(toolDefinition.visibilityswitch, this.checked);
       if (this.checked) {
         gDevTools.emit("tool-registered", id);
-      }
-      else {
+      } else {
         gDevTools.emit("tool-unregistered", toolDefinition);
       }
     };
 
     let createToolCheckbox = tool => {
       let checkboxLabel = this.panelDoc.createElement("label");
       let checkboxInput = this.panelDoc.createElement("input");
       checkboxInput.setAttribute("type", "checkbox");
       checkboxInput.setAttribute("id", tool.id);
       checkboxInput.setAttribute("title", tool.tooltip || "");
 
       let checkboxSpanLabel = this.panelDoc.createElement("span");
       if (tool.isTargetSupported(this.target)) {
         checkboxSpanLabel.textContent = tool.label;
-      }
-      else {
+      } else {
         atleastOneToolNotSupported = true;
         checkboxSpanLabel.textContent = l10n(
           "options.toolNotSupportedMarker", tool.label);
         checkboxInput.setAttribute("data-unsupported", "true");
         checkboxInput.setAttribute("disabled", "true");
       }
 
       if (InfallibleGetBoolPref(tool.visibilityswitch)) {
@@ -342,22 +342,23 @@ OptionsPanel.prototype = {
       prefSelect.addEventListener("change", function(e) {
         let select = e.target;
         setPrefAndEmit(select.getAttribute("data-pref"),
           select.options[select.selectedIndex].value);
       });
     }
 
     if (this.target.activeTab) {
-      return this.target.client.attachTab(this.target.activeTab._actor).then(([response, client]) => {
-        this._origJavascriptEnabled = !response.javascriptEnabled;
-        this.disableJSNode.checked = this._origJavascriptEnabled;
-        this.disableJSNode.addEventListener("click",
-          this._disableJSClicked, false);
-      });
+      return this.target.client.attachTab(this.target.activeTab._actor)
+        .then(([response, client]) => {
+          this._origJavascriptEnabled = !response.javascriptEnabled;
+          this.disableJSNode.checked = this._origJavascriptEnabled;
+          this.disableJSNode.addEventListener("click",
+            this._disableJSClicked, false);
+        });
     }
     this.disableJSNode.hidden = true;
   },
 
   updateCurrentTheme: function() {
     let currentTheme = GetPref("devtools.theme");
     let themeBox = this.panelDoc.getElementById("devtools-theme-box");
     let themeRadioInput = themeBox.querySelector(`[value=${currentTheme}]`);