Bug 1387123 - Replace all usages of require(promise).defer by require(devtools/shared/defer).defer. r=tromey
authorAlexandre Poirot <poirot.alex@gmail.com>
Tue, 08 Aug 2017 15:19:56 +0200
changeset 373410 84755985ba136a4afa2ea7d3e84626a3948417df
parent 373409 a820e391d9002cc951fee85edcf40b3dbd3eaf60
child 373411 a0f8b7a90139c3a459e26aa02dd9ee8c2cc3f570
push id48257
push userapoirot@mozilla.com
push dateTue, 08 Aug 2017 15:58:07 +0000
treeherderautoland@84755985ba13 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstromey
bugs1387123, 1387128
milestone57.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 1387123 - Replace all usages of require(promise).defer by require(devtools/shared/defer).defer. r=tromey In prevision of Promise.jsm removal, use defer helper module instead of Promise.jsm as that's the only one feature that DOM Promise don't support. PART3: Manual fixes - Go manually fix: http://searchfox.org/mozilla-central/source/devtools/client/dom/dom-panel.js which has duplicated import of defer symbol (it already used to import it) - execute eslint, see all the places where we import of 'promise' is no longer use it (there may be leftovers not covered by eslint that will be covered in bug 1387128) devtools/server/tests/mochitest/inspector-helpers.js needs to keep importing promise as it is a shared test script. - fix devtools/client/performance/panel.js and devtools/client/webconsole/console-output.js which use loader.lazyRequireGetter(this, "promise") and miss the defer import - fix devtools/server/worker.js to use 'worker.require(devtools/shared/defer")' MozReview-Commit-ID: HIOB5Et87Wc
devtools/client/dom/dom-panel.js
devtools/client/performance/modules/widgets/graphs.js
devtools/client/performance/panel.js
devtools/client/webconsole/console-output.js
devtools/client/webconsole/jsterm.js
devtools/server/actors/canvas.js
devtools/server/actors/device.js
devtools/server/actors/webgl.js
devtools/server/main.js
devtools/server/tests/mochitest/inspector-helpers.js
devtools/server/worker.js
devtools/shared/webconsole/test/unit/test_throttle.js
--- a/devtools/client/dom/dom-panel.js
+++ b/devtools/client/dom/dom-panel.js
@@ -1,20 +1,18 @@
 /* -*- 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 } = require("chrome");
-const defer = require("devtools/shared/defer");
 const { ObjectClient } = require("devtools/shared/client/main");
 
-const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const EventEmitter = require("devtools/shared/event-emitter");
 const { Task } = require("devtools/shared/task");
 
 /**
  * This object represents DOM panel. It's responsibility is to
  * render Document Object Model of the current debugger target.
  */
--- a/devtools/client/performance/modules/widgets/graphs.js
+++ b/devtools/client/performance/modules/widgets/graphs.js
@@ -8,17 +8,16 @@
  */
 
 const { Task } = require("devtools/shared/task");
 const { Heritage } = require("devtools/client/shared/widgets/view-helpers");
 const LineGraphWidget = require("devtools/client/shared/widgets/LineGraphWidget");
 const MountainGraphWidget = require("devtools/client/shared/widgets/MountainGraphWidget");
 const { CanvasGraphUtils } = require("devtools/client/shared/widgets/Graphs");
 
-const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const EventEmitter = require("devtools/shared/event-emitter");
 
 const { colorUtils } = require("devtools/shared/css/color");
 const { getColor } = require("devtools/client/shared/theme");
 const ProfilerGlobal = require("devtools/client/performance/modules/global");
 const { MarkersOverview } = require("devtools/client/performance/modules/widgets/markers-overview");
 const { createTierGraphDataFromFrameNode } = require("devtools/client/performance/modules/logic/jit");
--- a/devtools/client/performance/panel.js
+++ b/devtools/client/performance/panel.js
@@ -1,18 +1,18 @@
 /* -*- Mode: javascript; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 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 { Task } = require("devtools/shared/task");
+const defer = require("devtools/shared/defer");
 
-loader.lazyRequireGetter(this, "promise");
 loader.lazyRequireGetter(this, "EventEmitter",
   "devtools/shared/event-emitter");
 
 function PerformancePanel(iframeWindow, toolbox) {
   this.panelWin = iframeWindow;
   this.toolbox = toolbox;
 
   EventEmitter.decorate(this);
--- a/devtools/client/webconsole/console-output.js
+++ b/devtools/client/webconsole/console-output.js
@@ -6,30 +6,30 @@
 
 "use strict";
 
 const {Ci} = require("chrome");
 
 loader.lazyImporter(this, "VariablesView", "resource://devtools/client/shared/widgets/VariablesView.jsm");
 loader.lazyImporter(this, "escapeHTML", "resource://devtools/client/shared/widgets/VariablesView.jsm");
 
-loader.lazyRequireGetter(this, "promise");
 loader.lazyRequireGetter(this, "gDevTools", "devtools/client/framework/devtools", true);
 loader.lazyRequireGetter(this, "TableWidget", "devtools/client/shared/widgets/TableWidget", true);
 loader.lazyRequireGetter(this, "ObjectClient", "devtools/shared/client/main", true);
 
 const XHTML_NS = "http://www.w3.org/1999/xhtml";
 
 const WebConsoleUtils = require("devtools/client/webconsole/utils").Utils;
 const { getSourceNames } = require("devtools/client/shared/source-utils");
 const {Task} = require("devtools/shared/task");
 const l10n = require("devtools/client/webconsole/webconsole-l10n");
 const nodeConstants = require("devtools/shared/dom-node-constants");
 const {PluralForm} = require("devtools/shared/plural-form");
 const {extend} = require("devtools/shared/extend");
+const defer = require("devtools/shared/defer");
 
 const MAX_STRING_GRIP_LENGTH = 36;
 const {ELLIPSIS} = require("devtools/shared/l10n");
 
 const validProtocols = /^(http|https|ftp|data|javascript|resource|chrome):/i;
 
 // Constants for compatibility with the Web Console output implementation before
 // bug 778766.
--- a/devtools/client/webconsole/jsterm.js
+++ b/devtools/client/webconsole/jsterm.js
@@ -3,17 +3,16 @@
 /* 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 {Utils: WebConsoleUtils} =
   require("devtools/client/webconsole/utils");
-const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const Debugger = require("Debugger");
 const Services = require("Services");
 const {KeyCodes} = require("devtools/client/shared/keycodes");
 
 loader.lazyServiceGetter(this, "clipboardHelper",
                          "@mozilla.org/widget/clipboardhelper;1",
                          "nsIClipboardHelper");
--- a/devtools/server/actors/canvas.js
+++ b/devtools/server/actors/canvas.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";
 
 /* global XPCNativeWrapper */
 
-const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const protocol = require("devtools/shared/protocol");
 const {CallWatcherActor} = require("devtools/server/actors/call-watcher");
 const {CallWatcherFront} = require("devtools/shared/fronts/call-watcher");
 const {WebGLPrimitiveCounter} = require("devtools/server/primitive");
 const {
   frameSnapshotSpec,
   canvasSpec,
--- a/devtools/server/actors/device.js
+++ b/devtools/server/actors/device.js
@@ -1,17 +1,16 @@
 /* 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 protocol = require("devtools/shared/protocol");
-const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const {LongStringActor} = require("devtools/server/actors/string");
 const {DebuggerServer} = require("devtools/server/main");
 const {getSystemInfo, getSetting} = require("devtools/shared/system");
 const {deviceSpec} = require("devtools/shared/specs/device");
 const FileReader = require("FileReader");
 
 exports.DeviceActor = protocol.ActorClassWithSpec(deviceSpec, {
--- a/devtools/server/actors/webgl.js
+++ b/devtools/server/actors/webgl.js
@@ -2,17 +2,16 @@
  * 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";
 
 /* global XPCNativeWrapper */
 
 const {Cu} = require("chrome");
 const events = require("sdk/event/core");
-const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const protocol = require("devtools/shared/protocol");
 const { ContentObserver } = require("devtools/shared/content-observer");
 const { on, off, emit } = events;
 const {
   shaderSpec,
   programSpec,
   webGLSpec,
--- a/devtools/server/main.js
+++ b/devtools/server/main.js
@@ -727,17 +727,17 @@ var DebuggerServer = {
     let transport = isWorker ?
                     new WorkerDebuggerTransport(scopeOrManager, prefix) :
                     new ChildDebuggerTransport(scopeOrManager, prefix);
 
     return this._onConnection(transport, prefix, true);
   },
 
   connectToContent(connection, mm, onDestroy) {
-    let deferred = Syncdefer();
+    let deferred = SyncPromise.defer();
 
     let prefix = connection.allocID("content-process");
     let actor, childTransport;
 
     mm.addMessageListener("debug:content-process-actor", function listener(msg) {
       // Arbitrarily choose the first content process to reply
       // XXX: This code needs to be updated if we use more than one content process
       mm.removeMessageListener("debug:content-process-actor", listener);
@@ -1017,17 +1017,17 @@ var DebuggerServer = {
    *        Optional function to invoke when the child process closes
    *        or the connection shuts down. (Need to forget about the
    *        related TabActor)
    * @return object
    *         A promise object that is resolved once the connection is
    *         established.
    */
   connectToChild(connection, frame, onDestroy, {addonId} = {}) {
-    let deferred = Syncdefer();
+    let deferred = SyncPromise.defer();
 
     // Get messageManager from XUL browser (which might be a specialized tunnel for RDM)
     // or else fallback to asking the frameLoader itself.
     let mm = frame.messageManager || frame.frameLoader.messageManager;
     mm.loadFrameScript("resource://devtools/server/child.js", false);
 
     let trackMessageManager = () => {
       frame.addEventListener("DevTools:BrowserSwap", onBrowserSwap);
--- a/devtools/server/tests/mochitest/inspector-helpers.js
+++ b/devtools/server/tests/mochitest/inspector-helpers.js
@@ -7,17 +7,18 @@
 var Cu = Components.utils;
 
 const {require} = Cu.import("resource://devtools/shared/Loader.jsm", {});
 const {DebuggerClient} = require("devtools/shared/client/main");
 const {DebuggerServer} = require("devtools/server/main");
 const { Task } = require("devtools/shared/task");
 
 const Services = require("Services");
-const promise = require("promise");
+// promise is still used in tests using this helper
+const promise = require("promise"); // eslint-disable-line no-unused-vars
 const defer = require("devtools/shared/defer");
 const {_documentWalker} = require("devtools/server/actors/inspector");
 
 // Always log packets when running tests.
 Services.prefs.setBoolPref("devtools.debugger.log", true);
 SimpleTest.registerCleanupFunction(function () {
   Services.prefs.clearUserPref("devtools.debugger.log");
 });
--- a/devtools/server/worker.js
+++ b/devtools/server/worker.js
@@ -23,18 +23,17 @@ this.rpc = function (method, ...params) 
 
   let deferred = defer();
   rpcDeferreds[id] = deferred;
   return deferred.promise;
 };
 
 loadSubScript("resource://devtools/shared/worker/loader.js");
 
-var Promise = worker.require("promise");
-const defer = require("devtools/shared/defer");
+var defer = worker.require("devtools/shared/defer");
 var { ActorPool } = worker.require("devtools/server/actors/common");
 var { ThreadActor } = worker.require("devtools/server/actors/script");
 var { WebConsoleActor } = worker.require("devtools/server/actors/webconsole");
 var { TabSources } = worker.require("devtools/server/actors/utils/TabSources");
 var makeDebugger = worker.require("devtools/server/actors/utils/make-debugger");
 var { DebuggerServer } = worker.require("devtools/server/main");
 
 DebuggerServer.init();
--- a/devtools/shared/webconsole/test/unit/test_throttle.js
+++ b/devtools/shared/webconsole/test/unit/test_throttle.js
@@ -2,17 +2,16 @@
    http://creativecommons.org/publicdomain/zero/1.0/ */
 
 "use strict";
 
 const Cu = Components.utils;
 const Cc = Components.classes;
 const Ci = Components.interfaces;
 const { require } = Cu.import("resource://devtools/shared/Loader.jsm", {});
-const promise = require("promise");
 const defer = require("devtools/shared/defer");
 const { NetworkThrottleManager } =
       require("devtools/shared/webconsole/throttle");
 const nsIScriptableInputStream = Ci.nsIScriptableInputStream;
 
 function TestStreamListener() {
   this.state = "initial";
 }