--- a/.eslintignore
+++ b/.eslintignore
@@ -77,17 +77,18 @@ browser/locales/**
browser/extensions/mortar/**
# devtools/ exclusions
devtools/client/canvasdebugger/**
devtools/client/commandline/**
devtools/client/debugger/**
devtools/client/framework/**
!devtools/client/framework/selection.js
-!devtools/client/framework/toolbox.js
+!devtools/client/framework/target*
+!devtools/client/framework/toolbox*
devtools/client/netmonitor/test/**
devtools/client/netmonitor/har/test/**
devtools/client/projecteditor/**
devtools/client/responsivedesign/**
devtools/client/scratchpad/**
devtools/client/shadereditor/**
devtools/client/shared/*.jsm
devtools/client/shared/components/reps/reps.js
--- a/devtools/client/framework/ToolboxProcess.jsm
+++ b/devtools/client/framework/ToolboxProcess.jsm
@@ -25,52 +25,52 @@ const Services = require("Services");
this.EXPORTED_SYMBOLS = ["BrowserToolboxProcess"];
var processes = new Set();
/**
* Constructor for creating a process that will hold a chrome toolbox.
*
- * @param function aOnClose [optional]
+ * @param function onClose [optional]
* A function called when the process stops running.
- * @param function aOnRun [optional]
+ * @param function onRun [optional]
* A function called when the process starts running.
- * @param object aOptions [optional]
+ * @param object options [optional]
* An object with properties for configuring BrowserToolboxProcess.
*/
-this.BrowserToolboxProcess = function BrowserToolboxProcess(aOnClose, aOnRun, aOptions) {
+this.BrowserToolboxProcess = function BrowserToolboxProcess(onClose, onRun, options) {
let emitter = new EventEmitter();
this.on = emitter.on.bind(emitter);
this.off = emitter.off.bind(emitter);
this.once = emitter.once.bind(emitter);
// Forward any events to the shared emitter.
this.emit = function (...args) {
emitter.emit(...args);
BrowserToolboxProcess.emit(...args);
};
// If first argument is an object, use those properties instead of
// all three arguments
- if (typeof aOnClose === "object") {
- if (aOnClose.onClose) {
- this.once("close", aOnClose.onClose);
+ if (typeof onClose === "object") {
+ if (onClose.onClose) {
+ this.once("close", onClose.onClose);
}
- if (aOnClose.onRun) {
- this.once("run", aOnClose.onRun);
+ if (onClose.onRun) {
+ this.once("run", onClose.onRun);
}
- this._options = aOnClose;
+ this._options = onClose;
} else {
- if (aOnClose) {
- this.once("close", aOnClose);
+ if (onClose) {
+ this.once("close", onClose);
}
- if (aOnRun) {
- this.once("run", aOnRun);
+ if (onRun) {
+ this.once("run", onRun);
}
- this._options = aOptions || {};
+ this._options = options || {};
}
this._telemetry = new Telemetry();
this.close = this.close.bind(this);
Services.obs.addObserver(this.close, "quit-application", false);
this._initServer();
this._initProfile();
@@ -80,34 +80,34 @@ this.BrowserToolboxProcess = function Br
};
EventEmitter.decorate(BrowserToolboxProcess);
/**
* Initializes and starts a chrome toolbox process.
* @return object
*/
-BrowserToolboxProcess.init = function (aOnClose, aOnRun, aOptions) {
- return new BrowserToolboxProcess(aOnClose, aOnRun, aOptions);
+BrowserToolboxProcess.init = function (onClose, onRun, options) {
+ return new BrowserToolboxProcess(onClose, onRun, options);
};
/**
* Passes a set of options to the BrowserAddonActors for the given ID.
*
- * @param aId string
+ * @param id string
* The ID of the add-on to pass the options to
- * @param aOptions object
+ * @param options object
* The options.
* @return a promise that will be resolved when complete.
*/
-BrowserToolboxProcess.setAddonOptions = function DSC_setAddonOptions(aId, aOptions) {
+BrowserToolboxProcess.setAddonOptions = function (id, options) {
let promises = [];
for (let process of processes.values()) {
- promises.push(process.debuggerServer.setAddonOptions(aId, aOptions));
+ promises.push(process.debuggerServer.setAddonOptions(id, options));
}
return promise.all(promises);
};
BrowserToolboxProcess.prototype = {
/**
* Initializes the debugger server.
@@ -185,50 +185,58 @@ BrowserToolboxProcess.prototype = {
// clears out the prefs file before re-writing it, and in practice the
// file is empty when we get here. So just copying doesn't work in that
// case.
// We could force a sync pref flush and then copy it... but if we're doing
// that, we might as well just flush directly to the new profile, which
// always works:
Services.prefs.savePrefFile(prefsFile);
- dumpn("Finished creating the chrome toolbox user profile at: " + this._dbgProfilePath);
+ dumpn("Finished creating the chrome toolbox user profile at: " +
+ this._dbgProfilePath);
},
/**
* Creates and initializes the profile & process for the remote debugger.
*/
_create: function () {
dumpn("Initializing chrome debugging process.");
- let process = this._dbgProcess = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
+ let process = Cc["@mozilla.org/process/util;1"].createInstance(Ci.nsIProcess);
+ this._dbgProcess = process;
process.init(Services.dirsvc.get("XREExeF", Ci.nsIFile));
let xulURI = DBG_XUL;
if (this._options.addonID) {
xulURI += "?addonID=" + this._options.addonID;
}
dumpn("Running chrome debugging process.");
- let args = ["-no-remote", "-foreground", "-profile", this._dbgProfilePath, "-chrome", xulURI];
+ let args = [
+ "-no-remote",
+ "-foreground",
+ "-profile", this._dbgProfilePath,
+ "-chrome", xulURI
+ ];
// During local development, incremental builds can trigger the main process
// to clear its startup cache with the "flag file" .purgecaches, but this
// file is removed during app startup time, so we aren't able to know if it
// was present in order to also clear the child profile's startup cache as
// well.
//
// As an approximation of "isLocalBuild", check for an unofficial build.
if (!Services.appinfo.isOfficial) {
args.push("-purgecaches");
}
// Disable safe mode for the new process in case this was opened via the
// keyboard shortcut.
- let nsIEnvironment = Components.classes["@mozilla.org/process/environment;1"].getService(Components.interfaces.nsIEnvironment);
+ let nsIEnvironment = Cc["@mozilla.org/process/environment;1"]
+ .getService(Ci.nsIEnvironment);
let originalValue = nsIEnvironment.get("MOZ_DISABLE_SAFE_MODE_KEY");
nsIEnvironment.set("MOZ_DISABLE_SAFE_MODE_KEY", "1");
process.runwAsync(args, args.length, { observe: () => this.close() });
// Now that the process has started, it's safe to reset the env variable.
nsIEnvironment.set("MOZ_DISABLE_SAFE_MODE_KEY", originalValue);
@@ -283,12 +291,14 @@ function dumpn(str) {
if (wantLogging) {
dump("DBG-FRONTEND: " + str + "\n");
}
}
var wantLogging = Services.prefs.getBoolPref("devtools.debugger.log");
Services.prefs.addObserver("devtools.debugger.log", {
- observe: (...args) => wantLogging = Services.prefs.getBoolPref(args.pop())
+ observe: (...args) => {
+ wantLogging = Services.prefs.getBoolPref(args.pop());
+ }
}, false);
Services.obs.notifyObservers(null, "ToolboxProcessLoaded", null);
--- a/devtools/client/framework/target-from-url.js
+++ b/devtools/client/framework/target-from-url.js
@@ -57,47 +57,47 @@ exports.targetFromURL = Task.async(funct
let client = yield createClient(params);
yield client.connect();
let form, isTabActor;
if (type === "tab") {
// Fetch target for a remote tab
- id = parseInt(id);
+ id = parseInt(id, 10);
if (isNaN(id)) {
- throw new Error("targetFromURL, wrong tab id:'" + id + "', should be a number");
+ throw new Error(`targetFromURL, wrong tab id '${id}', should be a number`);
}
try {
let response = yield client.getTab({ outerWindowID: id });
form = response.tab;
} catch (ex) {
if (ex.error == "noTab") {
- throw new Error("targetFromURL, tab with outerWindowID:'" + id + "' doesn't exist");
+ throw new Error(`targetFromURL, tab with outerWindowID '${id}' doesn't exist`);
}
throw ex;
}
} else if (type == "process") {
// Fetch target for a remote chrome actor
DebuggerServer.allowChromeProcess = true;
try {
- id = parseInt(id);
+ id = parseInt(id, 10);
if (isNaN(id)) {
id = 0;
}
let response = yield client.getProcess(id);
form = response.form;
chrome = true;
if (id != 0) {
// Child process are not exposing tab actors and only support debugger+console
isTabActor = false;
}
} catch (ex) {
if (ex.error == "noProcess") {
- throw new Error("targetFromURL, process with id:'" + id + "' doesn't exist");
+ throw new Error(`targetFromURL, process with id '${id}' doesn't exist`);
}
throw ex;
}
} else if (type == "window") {
// Fetch target for a remote window actor
DebuggerServer.allowChromeProcess = true;
try {
id = parseInt(id, 10);
@@ -106,23 +106,22 @@ exports.targetFromURL = Task.async(funct
}
let response = yield client.mainRoot.getWindow({
outerWindowID: id,
});
form = response.window;
chrome = true;
} catch (ex) {
if (ex.error == "notFound") {
- throw new Error(`targetFromURL, window with id:'${id}' ` +
- "doesn't exist");
+ throw new Error(`targetFromURL, window with id '${id}' doesn't exist`);
}
throw ex;
}
} else {
- throw new Error("targetFromURL, unsupported type='" + type + "' parameter");
+ throw new Error(`targetFromURL, unsupported type '${type}' parameter`);
}
return TargetFactory.forRemoteTab({ client, form, chrome, isTabActor });
});
function* createClient(params) {
let host = params.get("host");
let port = params.get("port");
@@ -132,12 +131,12 @@ function* createClient(params) {
if (port) {
transport = yield DebuggerClient.socketConnect({ host, port, webSocket });
} else {
// Setup a server if we don't have one already running
if (!DebuggerServer.initialized) {
DebuggerServer.init();
DebuggerServer.addBrowserActors();
}
- transport = DebuggerServer.connectPipe()
+ transport = DebuggerServer.connectPipe();
}
return new DebuggerClient(transport);
}
--- a/devtools/client/framework/target.js
+++ b/devtools/client/framework/target.js
@@ -1,16 +1,15 @@
/* 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 { Ci } = require("chrome");
-const promise = require("promise");
const defer = require("devtools/shared/defer");
const EventEmitter = require("devtools/shared/event-emitter");
const Services = require("Services");
const { XPCOMUtils } = require("resource://gre/modules/XPCOMUtils.jsm");
loader.lazyRequireGetter(this, "DebuggerServer", "devtools/server/main", true);
loader.lazyRequireGetter(this, "DebuggerClient",
"devtools/shared/client/main", true);
@@ -481,53 +480,53 @@ TabTarget.prototype = {
},
/**
* Setup listeners for remote debugging, updating existing ones as necessary.
*/
_setupRemoteListeners: function () {
this.client.addListener("closed", this.destroy);
- this._onTabDetached = (aType, aPacket) => {
+ this._onTabDetached = (type, packet) => {
// We have to filter message to ensure that this detach is for this tab
- if (aPacket.from == this._form.actor) {
+ if (packet.from == this._form.actor) {
this.destroy();
}
};
this.client.addListener("tabDetached", this._onTabDetached);
- this._onTabNavigated = (aType, aPacket) => {
+ this._onTabNavigated = (type, packet) => {
let event = Object.create(null);
- event.url = aPacket.url;
- event.title = aPacket.title;
- event.nativeConsoleAPI = aPacket.nativeConsoleAPI;
- event.isFrameSwitching = aPacket.isFrameSwitching;
+ event.url = packet.url;
+ event.title = packet.title;
+ event.nativeConsoleAPI = packet.nativeConsoleAPI;
+ event.isFrameSwitching = packet.isFrameSwitching;
- if (!aPacket.isFrameSwitching) {
+ if (!packet.isFrameSwitching) {
// Update the title and url unless this is a frame switch.
- this._url = aPacket.url;
- this._title = aPacket.title;
+ this._url = packet.url;
+ this._title = packet.title;
}
// Send any stored event payload (DOMWindow or nsIRequest) for backwards
// compatibility with non-remotable tools.
- if (aPacket.state == "start") {
+ if (packet.state == "start") {
event._navPayload = this._navRequest;
this.emit("will-navigate", event);
this._navRequest = null;
} else {
event._navPayload = this._navWindow;
this.emit("navigate", event);
this._navWindow = null;
}
};
this.client.addListener("tabNavigated", this._onTabNavigated);
- this._onFrameUpdate = (aType, aPacket) => {
- this.emit("frame-update", aPacket);
+ this._onFrameUpdate = (type, packet) => {
+ this.emit("frame-update", packet);
};
this.client.addListener("frameUpdate", this._onFrameUpdate);
this._onSourceUpdated = (event, packet) => this.emit("source-updated", packet);
this.client.addListener("newSource", this._onSourceUpdated);
this.client.addListener("updatedSource", this._onSourceUpdated);
},
@@ -560,19 +559,21 @@ TabTarget.prototype = {
}
break;
case "TabRemotenessChange":
this.onRemotenessChange();
break;
}
},
- // Automatically respawn the toolbox when the tab changes between being
- // loaded within the parent process and loaded from a content process.
- // Process change can go in both ways.
+ /**
+ * Automatically respawn the toolbox when the tab changes between being
+ * loaded within the parent process and loaded from a content process.
+ * Process change can go in both ways.
+ */
onRemotenessChange: function () {
// Responsive design do a crazy dance around tabs and triggers
// remotenesschange events. But we should ignore them as at the end
// the content doesn't change its remoteness.
if (this._tab.isResponsiveDesignMode) {
return;
}
@@ -682,21 +683,21 @@ TabTarget.prototype = {
return deferred.promise;
},
};
/**
* WebProgressListener for TabTarget.
*
- * @param object aTarget
+ * @param object target
* The TabTarget instance to work with.
*/
-function TabWebProgressListener(aTarget) {
- this.target = aTarget;
+function TabWebProgressListener(target) {
+ this.target = target;
}
TabWebProgressListener.prototype = {
target: null,
QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
Ci.nsISupportsWeakReference]),
--- a/devtools/client/framework/test/browser_target_from_url.js
+++ b/devtools/client/framework/test/browser_target_from_url.js
@@ -28,17 +28,17 @@ add_task(function* () {
let browser = tab.linkedBrowser;
let target;
info("Test invalid type");
try {
yield targetFromURL(new URL("http://foo?type=x"));
ok(false, "Shouldn't pass");
} catch (e) {
- is(e.message, "targetFromURL, unsupported type='x' parameter");
+ is(e.message, "targetFromURL, unsupported type 'x' parameter");
}
info("Test browser window");
let windowId = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.outerWindowID;
target = yield targetFromURL(new URL("http://foo?type=window&id=" + windowId));
is(target.url, window.location.href);
@@ -56,17 +56,17 @@ add_task(function* () {
target = yield targetFromURL(new URL("http://foo?type=tab&id=" + windowId + "&chrome"));
assertIsTabTarget(target, TEST_URI, true);
info("Test invalid tab id");
try {
yield targetFromURL(new URL("http://foo?type=tab&id=10000"));
ok(false, "Shouldn't pass");
} catch (e) {
- is(e.message, "targetFromURL, tab with outerWindowID:'10000' doesn't exist");
+ is(e.message, "targetFromURL, tab with outerWindowID '10000' doesn't exist");
}
info("Test parent process");
target = yield targetFromURL(new URL("http://foo?type=process"));
let topWindow = Services.wm.getMostRecentWindow("navigator:browser");
assertIsTabTarget(target, topWindow.location.href, true);
yield testRemoteTCP();
--- a/devtools/client/framework/toolbox-highlighter-utils.js
+++ b/devtools/client/framework/toolbox-highlighter-utils.js
@@ -1,10 +1,8 @@
-/* -*- 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 promise = require("promise");
const {Task} = require("devtools/shared/task");
@@ -28,17 +26,16 @@ const flags = require("devtools/shared/f
* scope that would be different for another instance returned by this function.
*
* @param {Toolbox} toolbox
* @return {Object} the highlighterUtils public API
*/
exports.getHighlighterUtils = function (toolbox) {
if (!toolbox || !toolbox.target) {
throw new Error("Missing or invalid toolbox passed to getHighlighterUtils");
- return;
}
// Exported API properties will go here
let exported = {};
// The current toolbox target
let target = toolbox.target;
@@ -92,22 +89,21 @@ exports.getHighlighterUtils = function (
};
/**
* Start/stop the element picker on the debuggee target.
* @param {Boolean} doFocus - Optionally focus the content area once the picker is
* activated.
* @return A promise that resolves when done
*/
- let togglePicker = exported.togglePicker = function (doFocus) {
+ exported.togglePicker = function (doFocus) {
if (isPicking) {
return cancelPicker();
- } else {
- return startPicker(doFocus);
}
+ return startPicker(doFocus);
};
/**
* Start the element picker on the debuggee target.
* This will request the inspector actor to start listening for mouse events
* on the target page to highlight the hovered/picked element.
* Depending on the server-side capabilities, this may fire events when nodes
* are hovered.
@@ -245,18 +241,17 @@ exports.getHighlighterUtils = function (
/**
* This is a convenience method in case you don't have a nodeFront but a
* valueGrip. This is often the case with VariablesView properties.
* This method will simply translate the grip into a nodeFront and call
* highlightNodeFront, so it has the same signature.
* @see highlightNodeFront
*/
- let highlightDomValueGrip = exported.highlightDomValueGrip = requireInspector(
- function* (valueGrip, options = {}) {
+ exported.highlightDomValueGrip = requireInspector(function* (valueGrip, options = {}) {
let nodeFront = yield gripToNodeFront(valueGrip);
if (nodeFront) {
yield highlightNodeFront(nodeFront, options);
} else {
throw new Error("The ValueGrip passed could not be translated to a NodeFront");
}
});
@@ -274,23 +269,23 @@ exports.getHighlighterUtils = function (
* Hide the highlighter.
* @param {Boolean} forceHide Only really matters in test mode (when
* flags.testing is true). In test mode, hovering over several nodes
* in the markup view doesn't hide/show the highlighter to ease testing. The
* highlighter stays visible at all times, except when the mouse leaves the
* markup view, which is when this param is passed to true
* @return a promise that resolves when the highlighter is hidden
*/
- let unhighlight = exported.unhighlight = Task.async(
- function* (forceHide = false) {
+ exported.unhighlight = Task.async(function* (forceHide = false) {
forceHide = forceHide || !flags.testing;
// Note that if isRemoteHighlightable is true, there's no need to hide the
// highlighter as the walker uses setTimeout to hide it after some time
- if (isNodeFrontHighlighted && forceHide && toolbox.highlighter && isRemoteHighlightable()) {
+ if (isNodeFrontHighlighted && forceHide && toolbox.highlighter &&
+ isRemoteHighlightable()) {
isNodeFrontHighlighted = false;
yield toolbox.highlighter.hideBoxModel();
}
// unhighlight is called when destroying the toolbox, which means that by
// now, the toolbox reference might have been nullified already.
if (toolbox) {
toolbox.emit("node-unhighlight");
@@ -301,24 +296,22 @@ exports.getHighlighterUtils = function (
* If the main, box-model, highlighter isn't enough, or if multiple
* highlighters are needed in parallel, this method can be used to return a
* new instance of a highlighter actor, given a type.
* The type of the highlighter passed must be known by the server.
* The highlighter actor returned will have the show(nodeFront) and hide()
* methods and needs to be released by the consumer when not needed anymore.
* @return a promise that resolves to the highlighter
*/
- let getHighlighterByType = exported.getHighlighterByType = requireInspector(
- function* (typeName) {
+ exported.getHighlighterByType = requireInspector(function* (typeName) {
let highlighter = null;
if (supportsCustomHighlighters()) {
highlighter = yield toolbox.inspector.getHighlighterByType(typeName);
}
return highlighter || promise.reject("The target doesn't support " +
`creating highlighters by types or ${typeName} is unknown`);
-
});
// Return the public API
return exported;
};
--- a/devtools/client/framework/toolbox-host-manager.js
+++ b/devtools/client/framework/toolbox-host-manager.js
@@ -1,10 +1,15 @@
+/* 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 Services = require("Services");
-const {Ci} = require("chrome");
const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const {Task} = require("devtools/shared/task");
loader.lazyRequireGetter(this, "Toolbox", "devtools/client/framework/toolbox", true);
loader.lazyRequireGetter(this, "Hosts", "devtools/client/framework/toolbox-hosts", true);
@@ -62,28 +67,31 @@ ToolboxHostManager.prototype = {
create: Task.async(function* (toolId) {
yield this.host.create();
this.host.frame.setAttribute("aria-label", L10N.getStr("toolbox.label"));
this.host.frame.ownerDocument.defaultView.addEventListener("message", this);
// We have to listen on capture as no event fires on bubble
this.host.frame.addEventListener("unload", this, true);
- let toolbox = new Toolbox(this.target, toolId, this.host.type, this.host.frame.contentWindow, this.frameId);
+ let toolbox = new Toolbox(this.target, toolId, this.host.type,
+ this.host.frame.contentWindow, this.frameId);
- // Prevent reloading the toolbox when loading the tools in a tab (e.g. from about:debugging)
- if (!this.host.frame.contentWindow.location.href.startsWith("about:devtools-toolbox")) {
+ // Prevent reloading the toolbox when loading the tools in a tab
+ // (e.g. from about:debugging)
+ let location = this.host.frame.contentWindow.location;
+ if (!location.href.startsWith("about:devtools-toolbox")) {
this.host.frame.setAttribute("src", "about:devtools-toolbox");
}
return toolbox;
}),
handleEvent(event) {
- switch(event.type) {
+ switch (event.type) {
case "message":
this.onMessage(event);
break;
case "unload":
// On unload, host iframe already lost its contentWindow attribute, so
// we can only compare against locations. Here we filter two very
// different cases: preliminary about:blank document as well as iframes
// like tool iframes.
--- a/devtools/client/framework/toolbox-init.js
+++ b/devtools/client/framework/toolbox-init.js
@@ -1,13 +1,14 @@
/* 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/. */
/* eslint-env browser */
+/* global XPCNativeWrapper */
"use strict";
// URL constructor doesn't support about: scheme
let href = window.location.href.replace("about:", "http://");
let url = new window.URL(href);
// Only use this method to attach the toolbox if some query parameters are given
--- a/devtools/client/framework/toolbox-options.js
+++ b/devtools/client/framework/toolbox-options.js
@@ -1,10 +1,8 @@
-/* -*- 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 Services = require("Services");
const defer = require("devtools/shared/defer");
@@ -64,18 +62,17 @@ function OptionsPanel(iframeWindow, tool
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 = {
@@ -111,19 +108,18 @@ OptionsPanel.prototype = {
Services.prefs.removeObserver("devtools.cache.disabled", this._prefChanged);
Services.prefs.removeObserver("devtools.theme", this._prefChanged);
gDevTools.off("theme-registered", this._themeRegistered);
gDevTools.off("theme-unregistered", this._themeUnregistered);
},
_prefChanged: function (subject, topic, prefName) {
if (prefName === "devtools.cache.disabled") {
- let cacheDisabled = data.newValue;
+ let cacheDisabled = GetPref(prefName);
let cbx = this.panelDoc.getElementById("devtools-disable-cache");
-
cbx.checked = cacheDisabled;
} else if (prefName === "devtools.theme") {
this.updateCurrentTheme();
}
},
_themeRegistered: function (event, themeId) {
this.setupThemeList();
@@ -354,17 +350,17 @@ OptionsPanel.prototype = {
};
for (let prefDefinition of prefDefinitions) {
let parent = this.panelDoc.getElementById(prefDefinition.parentId);
parent.appendChild(createPreferenceOption(prefDefinition));
}
},
- populatePreferences: function () {
+ populatePreferences: Task.async(function* () {
let prefCheckboxes = this.panelDoc.querySelectorAll(
"input[type=checkbox][data-pref]");
for (let prefCheckbox of prefCheckboxes) {
if (GetPref(prefCheckbox.getAttribute("data-pref"))) {
prefCheckbox.setAttribute("checked", true);
}
prefCheckbox.addEventListener("change", function (e) {
let checkbox = e.target;
@@ -394,36 +390,36 @@ OptionsPanel.prototype = {
let options = [...prefSelect.options];
options.some(function (option) {
let value = option.value;
// non strict check to allow int values.
if (value == pref) {
prefSelect.selectedIndex = options.indexOf(option);
return true;
}
+ return false;
});
prefSelect.addEventListener("change", function (e) {
let select = e.target;
SetPref(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);
- });
+ let [ response ] = yield this.target.client.attachTab(this.target.activeTab._actor);
+ this._origJavascriptEnabled = !response.javascriptEnabled;
+ this.disableJSNode.checked = this._origJavascriptEnabled;
+ this.disableJSNode.addEventListener("click", this._disableJSClicked);
+ } else {
+ // Hide the checkbox and label
+ this.disableJSNode.parentNode.style.display = "none";
}
- 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}]`);
if (themeRadioInput) {
themeRadioInput.checked = true;