Bug 1360237 - Fix eslint issues for devtools/client/framework/devtools.js. r=pbro

MozReview-Commit-ID: 8mWiLTsH4Sb

--HG--
extra : rebase_source : af636828a21a8bfa11287a5eeae4ade08de45056
This commit is contained in:
Alexandre Poirot 2017-04-27 17:19:17 +02:00
parent b249c9b732
commit 0456b4d6eb
2 changed files with 26 additions and 30 deletions

View file

@ -83,6 +83,7 @@ devtools/client/canvasdebugger/**
devtools/client/commandline/** devtools/client/commandline/**
devtools/client/debugger/** devtools/client/debugger/**
devtools/client/framework/** devtools/client/framework/**
!devtools/client/framework/devtools.js
!devtools/client/framework/selection.js !devtools/client/framework/selection.js
!devtools/client/framework/target* !devtools/client/framework/target*
!devtools/client/framework/toolbox* !devtools/client/framework/toolbox*

View file

@ -6,8 +6,6 @@
const {Cu} = require("chrome"); const {Cu} = require("chrome");
const Services = require("Services"); const Services = require("Services");
const promise = require("promise");
const defer = require("devtools/shared/defer");
// Load gDevToolsBrowser toolbox lazily as they need gDevTools to be fully initialized // Load gDevToolsBrowser toolbox lazily as they need gDevTools to be fully initialized
loader.lazyRequireGetter(this, "Toolbox", "devtools/client/framework/toolbox", true); loader.lazyRequireGetter(this, "Toolbox", "devtools/client/framework/toolbox", true);
@ -46,7 +44,7 @@ function DevTools() {
// start registering all default tools and themes: create menuitems, keys, emit // start registering all default tools and themes: create menuitems, keys, emit
// related events. // related events.
this.registerDefaults(); this.registerDefaults();
}; }
DevTools.prototype = { DevTools.prototype = {
// The windowtype of the main window, used in various tools. This may be set // The windowtype of the main window, used in various tools. This may be set
@ -100,7 +98,7 @@ DevTools.prototype = {
* markup from |url|, and also the toolbox containing the panel. * markup from |url|, and also the toolbox containing the panel.
* And returns an instance of ToolPanel (function|required) * And returns an instance of ToolPanel (function|required)
*/ */
registerTool: function DT_registerTool(toolDefinition) { registerTool(toolDefinition) {
let toolId = toolDefinition.id; let toolId = toolDefinition.id;
if (!toolId || FORBIDDEN_IDS.has(toolId)) { if (!toolId || FORBIDDEN_IDS.has(toolId)) {
@ -130,17 +128,16 @@ DevTools.prototype = {
* true to indicate that the call is due to app quit, so we should not * true to indicate that the call is due to app quit, so we should not
* cause a cascade of costly events * cause a cascade of costly events
*/ */
unregisterTool: function DT_unregisterTool(tool, isQuitApplication) { unregisterTool(tool, isQuitApplication) {
let toolId = null; let toolId = null;
if (typeof tool == "string") { if (typeof tool == "string") {
toolId = tool; toolId = tool;
tool = this._tools.get(tool); tool = this._tools.get(tool);
} } else {
else {
let {Deprecated} = Cu.import("resource://gre/modules/Deprecated.jsm", {}); let {Deprecated} = Cu.import("resource://gre/modules/Deprecated.jsm", {});
Deprecated.warning("Deprecation WARNING: gDevTools.unregisterTool(tool) is deprecated. " + Deprecated.warning("Deprecation WARNING: gDevTools.unregisterTool(tool) is " +
"You should unregister a tool using its toolId: " + "deprecated. You should unregister a tool using its toolId: " +
"gDevTools.unregisterTool(toolId)."); "gDevTools.unregisterTool(toolId).");
toolId = tool.id; toolId = tool.id;
} }
this._tools.delete(toolId); this._tools.delete(toolId);
@ -153,19 +150,19 @@ DevTools.prototype = {
/** /**
* Sorting function used for sorting tools based on their ordinals. * Sorting function used for sorting tools based on their ordinals.
*/ */
ordinalSort: function DT_ordinalSort(d1, d2) { ordinalSort(d1, d2) {
let o1 = (typeof d1.ordinal == "number") ? d1.ordinal : MAX_ORDINAL; let o1 = (typeof d1.ordinal == "number") ? d1.ordinal : MAX_ORDINAL;
let o2 = (typeof d2.ordinal == "number") ? d2.ordinal : MAX_ORDINAL; let o2 = (typeof d2.ordinal == "number") ? d2.ordinal : MAX_ORDINAL;
return o1 - o2; return o1 - o2;
}, },
getDefaultTools: function DT_getDefaultTools() { getDefaultTools() {
return DefaultTools.sort(this.ordinalSort); return DefaultTools.sort(this.ordinalSort);
}, },
getAdditionalTools: function DT_getAdditionalTools() { getAdditionalTools() {
let tools = []; let tools = [];
for (let [key, value] of this._tools) { for (let [, value] of this._tools) {
if (DefaultTools.indexOf(value) == -1) { if (DefaultTools.indexOf(value) == -1) {
tools.push(value); tools.push(value);
} }
@ -186,7 +183,7 @@ DevTools.prototype = {
* @return {ToolDefinition|null} tool * @return {ToolDefinition|null} tool
* The ToolDefinition for the id or null. * The ToolDefinition for the id or null.
*/ */
getToolDefinition: function DT_getToolDefinition(toolId) { getToolDefinition(toolId) {
let tool = this._tools.get(toolId); let tool = this._tools.get(toolId);
if (!tool) { if (!tool) {
return null; return null;
@ -206,7 +203,7 @@ DevTools.prototype = {
* @return {Map} tools * @return {Map} tools
* A map of the the tool definitions registered in this instance * A map of the the tool definitions registered in this instance
*/ */
getToolDefinitionMap: function DT_getToolDefinitionMap() { getToolDefinitionMap() {
let tools = new Map(); let tools = new Map();
for (let [id, definition] of this._tools) { for (let [id, definition] of this._tools) {
@ -226,7 +223,7 @@ DevTools.prototype = {
* @return {Array} tools * @return {Array} tools
* A sorted array of the tool definitions registered in this instance * A sorted array of the tool definitions registered in this instance
*/ */
getToolDefinitionArray: function DT_getToolDefinitionArray() { getToolDefinitionArray() {
let definitions = []; let definitions = [];
for (let [id, definition] of this._tools) { for (let [id, definition] of this._tools) {
@ -260,7 +257,7 @@ DevTools.prototype = {
* is unapplied. The function takes the current iframe window * is unapplied. The function takes the current iframe window
* and the new theme id as arguments (function) * and the new theme id as arguments (function)
*/ */
registerTheme: function DT_registerTheme(themeDefinition) { registerTheme(themeDefinition) {
let themeId = themeDefinition.id; let themeId = themeDefinition.id;
if (!themeId) { if (!themeId) {
@ -283,13 +280,12 @@ DevTools.prototype = {
* @param {string|object} theme * @param {string|object} theme
* Definition or the id of the theme to unregister. * Definition or the id of the theme to unregister.
*/ */
unregisterTheme: function DT_unregisterTheme(theme) { unregisterTheme(theme) {
let themeId = null; let themeId = null;
if (typeof theme == "string") { if (typeof theme == "string") {
themeId = theme; themeId = theme;
theme = this._themes.get(theme); theme = this._themes.get(theme);
} } else {
else {
themeId = theme.id; themeId = theme.id;
} }
@ -323,7 +319,7 @@ DevTools.prototype = {
* @return {ThemeDefinition|null} theme * @return {ThemeDefinition|null} theme
* The ThemeDefinition for the id or null. * The ThemeDefinition for the id or null.
*/ */
getThemeDefinition: function DT_getThemeDefinition(themeId) { getThemeDefinition(themeId) {
let theme = this._themes.get(themeId); let theme = this._themes.get(themeId);
if (!theme) { if (!theme) {
return null; return null;
@ -337,7 +333,7 @@ DevTools.prototype = {
* @return {Map} themes * @return {Map} themes
* A map of the the theme definitions registered in this instance * A map of the the theme definitions registered in this instance
*/ */
getThemeDefinitionMap: function DT_getThemeDefinitionMap() { getThemeDefinitionMap() {
let themes = new Map(); let themes = new Map();
for (let [id, definition] of this._themes) { for (let [id, definition] of this._themes) {
@ -355,7 +351,7 @@ DevTools.prototype = {
* @return {Array} themes * @return {Array} themes
* A sorted array of the theme definitions registered in this instance * A sorted array of the theme definitions registered in this instance
*/ */
getThemeDefinitionArray: function DT_getThemeDefinitionArray() { getThemeDefinitionArray() {
let definitions = []; let definitions = [];
for (let [id, definition] of this._themes) { for (let [id, definition] of this._themes) {
@ -390,7 +386,6 @@ DevTools.prototype = {
showToolbox: Task.async(function* (target, toolId, hostType, hostOptions) { showToolbox: Task.async(function* (target, toolId, hostType, hostOptions) {
let toolbox = this._toolboxes.get(target); let toolbox = this._toolboxes.get(target);
if (toolbox) { if (toolbox) {
if (hostType != null && toolbox.hostType != hostType) { if (hostType != null && toolbox.hostType != hostType) {
yield toolbox.switchHost(hostType); yield toolbox.switchHost(hostType);
} }
@ -449,7 +444,7 @@ DevTools.prototype = {
* @return {Toolbox} toolbox * @return {Toolbox} toolbox
* The toolbox that is debugging the given target * The toolbox that is debugging the given target
*/ */
getToolbox: function DT_getToolbox(target) { getToolbox(target) {
return this._toolboxes.get(target); return this._toolboxes.get(target);
}, },
@ -482,17 +477,17 @@ DevTools.prototype = {
* some cleanups to speed it up. Otherwise everything need to be * some cleanups to speed it up. Otherwise everything need to be
* cleaned up in order to be able to load devtools again. * cleaned up in order to be able to load devtools again.
*/ */
destroy: function ({ shuttingDown }) { destroy({ shuttingDown }) {
// Do not cleanup everything during firefox shutdown, but only when // Do not cleanup everything during firefox shutdown, but only when
// devtools are reloaded via the add-on contribution workflow. // devtools are reloaded via the add-on contribution workflow.
if (!shuttingDown) { if (!shuttingDown) {
for (let [target, toolbox] of this._toolboxes) { for (let [, toolbox] of this._toolboxes) {
toolbox.destroy(); toolbox.destroy();
} }
AboutDevTools.unregister(); AboutDevTools.unregister();
} }
for (let [key, tool] of this.getToolDefinitionMap()) { for (let [key, ] of this.getToolDefinitionMap()) {
this.unregisterTool(key, true); this.unregisterTool(key, true);
} }
@ -508,7 +503,7 @@ DevTools.prototype = {
/** /**
* Iterator that yields each of the toolboxes. * Iterator that yields each of the toolboxes.
*/ */
*[Symbol.iterator ]() { * [Symbol.iterator ]() {
for (let toolbox of this._toolboxes) { for (let toolbox of this._toolboxes) {
yield toolbox; yield toolbox;
} }