Bug 1297113 - Fix eslint errors in toolbox.js;r=ochameau

MozReview-Commit-ID: 3q53J5L1bOk

--HG--
extra : rebase_source : 9a453e8484092df3eb52ff350e3289b339e8c6c7
This commit is contained in:
Julian Descottes 2016-09-12 16:51:40 +02:00
parent 8913fa4956
commit 48ae3f1a79
2 changed files with 41 additions and 31 deletions

View file

@ -80,6 +80,7 @@ devtools/client/debugger/**
devtools/client/eyedropper/** devtools/client/eyedropper/**
devtools/client/framework/** devtools/client/framework/**
!devtools/client/framework/selection.js !devtools/client/framework/selection.js
!devtools/client/framework/toolbox.js
devtools/client/jsonview/lib/** devtools/client/jsonview/lib/**
devtools/client/memory/** devtools/client/memory/**
devtools/client/netmonitor/test/** devtools/client/netmonitor/test/**

View file

@ -14,7 +14,7 @@ const SCREENSIZE_HISTOGRAM = "DEVTOOLS_SCREEN_RESOLUTION_ENUMERATED_PER_USER";
const HTML_NS = "http://www.w3.org/1999/xhtml"; const HTML_NS = "http://www.w3.org/1999/xhtml";
const { SourceMapService } = require("./source-map-service"); const { SourceMapService } = require("./source-map-service");
var {Cc, Ci, Cu} = require("chrome"); var {Ci, Cu} = require("chrome");
var promise = require("promise"); var promise = require("promise");
var defer = require("devtools/shared/defer"); var defer = require("devtools/shared/defer");
var Services = require("Services"); var Services = require("Services");
@ -235,8 +235,8 @@ Toolbox.prototype = {
if (panel) { if (panel) {
deferred.resolve(panel); deferred.resolve(panel);
} else { } else {
this.on(id + "-ready", (e, panel) => { this.on(id + "-ready", (e, initializedPanel) => {
deferred.resolve(panel); deferred.resolve(initializedPanel);
}); });
} }
@ -406,7 +406,7 @@ Toolbox.prototype = {
this.textboxContextMenuPopup.addEventListener("popupshowing", this.textboxContextMenuPopup.addEventListener("popupshowing",
this._updateTextboxMenuItems, true); this._updateTextboxMenuItems, true);
var shortcuts = new KeyShortcuts({ let shortcuts = new KeyShortcuts({
window: this.doc.defaultView window: this.doc.defaultView
}); });
this._buildDockButtons(); this._buildDockButtons();
@ -502,7 +502,8 @@ Toolbox.prototype = {
this._telemetry.logOncePerBrowserVersion(OS_HISTOGRAM, system.getOSCPU()); this._telemetry.logOncePerBrowserVersion(OS_HISTOGRAM, system.getOSCPU());
this._telemetry.logOncePerBrowserVersion(OS_IS_64_BITS, this._telemetry.logOncePerBrowserVersion(OS_IS_64_BITS,
Services.appinfo.is64Bit ? 1 : 0); Services.appinfo.is64Bit ? 1 : 0);
this._telemetry.logOncePerBrowserVersion(SCREENSIZE_HISTOGRAM, system.getScreenDimensions()); this._telemetry.logOncePerBrowserVersion(SCREENSIZE_HISTOGRAM,
system.getScreenDimensions());
this._telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId()); this._telemetry.log(HOST_HISTOGRAM, this._getTelemetryHostId());
}, },
@ -976,16 +977,16 @@ Toolbox.prototype = {
this._requisition = requisition; this._requisition = requisition;
const spec = CommandUtils.getCommandbarSpec("devtools.toolbox.toolbarSpec"); const spec = CommandUtils.getCommandbarSpec("devtools.toolbox.toolbarSpec");
return CommandUtils.createButtons(spec, this.target, this.doc, return CommandUtils.createButtons(spec, this.target, this.doc, requisition)
requisition).then(buttons => { .then(buttons => {
let container = this.doc.getElementById("toolbox-buttons"); let container = this.doc.getElementById("toolbox-buttons");
buttons.forEach(button=> { buttons.forEach(button => {
if (button) { if (button) {
container.appendChild(button); container.appendChild(button);
} }
}); });
this.setToolboxButtonsVisibility(); this.setToolboxButtonsVisibility();
}); });
}); });
}, },
@ -996,7 +997,8 @@ Toolbox.prototype = {
_buildPickerButton: function () { _buildPickerButton: function () {
this._pickerButton = this.doc.createElementNS(HTML_NS, "button"); this._pickerButton = this.doc.createElementNS(HTML_NS, "button");
this._pickerButton.id = "command-button-pick"; this._pickerButton.id = "command-button-pick";
this._pickerButton.className = "command-button command-button-invertable devtools-button"; this._pickerButton.className =
"command-button command-button-invertable devtools-button";
this._pickerButton.setAttribute("title", L10N.getStr("pickButton.tooltip")); this._pickerButton.setAttribute("title", L10N.getStr("pickButton.tooltip"));
this._pickerButton.setAttribute("hidden", "true"); this._pickerButton.setAttribute("hidden", "true");
@ -1082,7 +1084,9 @@ Toolbox.prototype = {
let on = true; let on = true;
try { try {
on = Services.prefs.getBoolPref(visibilityswitch); on = Services.prefs.getBoolPref(visibilityswitch);
} catch (ex) { } } catch (ex) {
// Do nothing.
}
on = on && isTargetSupported(this.target); on = on && isTargetSupported(this.target);
@ -1226,8 +1230,8 @@ Toolbox.prototype = {
if (panel) { if (panel) {
deferred.resolve(panel); deferred.resolve(panel);
} else { } else {
this.once(id + "-ready", panel => { this.once(id + "-ready", initializedPanel => {
deferred.resolve(panel); deferred.resolve(initializedPanel);
}); });
} }
return deferred.promise; return deferred.promise;
@ -1598,7 +1602,7 @@ Toolbox.prototype = {
// Returns an instance of the preference actor // Returns an instance of the preference actor
get _preferenceFront() { get _preferenceFront() {
return this.target.root.then(rootForm => { return this.target.root.then(rootForm => {
return new getPreferenceFront(this.target.client, rootForm); return getPreferenceFront(this.target.client, rootForm);
}); });
}, },
@ -1950,9 +1954,9 @@ Toolbox.prototype = {
if (!this._initInspector) { if (!this._initInspector) {
this._initInspector = Task.spawn(function* () { this._initInspector = Task.spawn(function* () {
this._inspector = InspectorFront(this._target.client, this._target.form); this._inspector = InspectorFront(this._target.client, this._target.form);
this._walker = yield this._inspector.getWalker( let pref = "devtools.inspector.showAllAnonymousContent";
{showAllAnonymousContent: Services.prefs.getBoolPref("devtools.inspector.showAllAnonymousContent")} let showAllAnonymousContent = Services.prefs.getBoolPref(pref);
); this._walker = yield this._inspector.getWalker({ showAllAnonymousContent });
this._selection = new Selection(this._walker); this._selection = new Selection(this._walker);
if (this.highlighterUtils.isRemoteHighlightable()) { if (this.highlighterUtils.isRemoteHighlightable()) {
@ -1976,7 +1980,7 @@ Toolbox.prototype = {
return this._destroyingInspector; return this._destroyingInspector;
} }
return this._destroyingInspector = Task.spawn(function* () { this._destroyingInspector = Task.spawn(function* () {
if (!this._inspector) { if (!this._inspector) {
return; return;
} }
@ -1988,7 +1992,9 @@ Toolbox.prototype = {
if (this._walker && !this.walker.traits.autoReleased) { if (this._walker && !this.walker.traits.autoReleased) {
try { try {
yield this._walker.release(); yield this._walker.release();
} catch (e) {} } catch (e) {
// Do nothing;
}
} }
yield this.highlighterUtils.stopPicker(); yield this.highlighterUtils.stopPicker();
@ -2018,6 +2024,7 @@ Toolbox.prototype = {
this._selection = null; this._selection = null;
this._walker = null; this._walker = null;
}.bind(this)); }.bind(this));
return this._destroyingInspector;
}, },
/** /**
@ -2233,7 +2240,7 @@ Toolbox.prototype = {
// If target does not have profiler actor (addons), do not // If target does not have profiler actor (addons), do not
// even register the shared performance connection. // even register the shared performance connection.
if (!this.target.hasActor("profiler")) { if (!this.target.hasActor("profiler")) {
return; return promise.resolve();
} }
if (this._performanceFrontConnection) { if (this._performanceFrontConnection) {
@ -2272,10 +2279,11 @@ Toolbox.prototype = {
}), }),
/** /**
* Called when any event comes from the PerformanceFront. If the performance tool is already * Called when any event comes from the PerformanceFront. If the performance tool is
* loaded when the first event comes in, immediately unbind this handler, as this is * already loaded when the first event comes in, immediately unbind this handler, as
* only used to queue up observed recordings before the performance tool can handle them, * this is only used to queue up observed recordings before the performance tool can
* which will only occur when `console.profile()` recordings are started before the tool loads. * handle them, which will only occur when `console.profile()` recordings are started
* before the tool loads.
*/ */
_onPerformanceFrontEvent: Task.async(function* (eventName, recording) { _onPerformanceFrontEvent: Task.async(function* (eventName, recording) {
if (this.getPanel("performance")) { if (this.getPanel("performance")) {
@ -2283,7 +2291,8 @@ Toolbox.prototype = {
return; return;
} }
let recordings = this._performanceQueuedRecordings = this._performanceQueuedRecordings || []; this._performanceQueuedRecordings = this._performanceQueuedRecordings || [];
let recordings = this._performanceQueuedRecordings;
// Before any console recordings, we'll get a `console-profile-start` event // Before any console recordings, we'll get a `console-profile-start` event
// warning us that a recording will come later (via `recording-started`), so // warning us that a recording will come later (via `recording-started`), so