Bug 1436978 - Manual fixes r=jdescottes draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Thu, 08 Feb 2018 09:02:24 -0800
changeset 754404 a751a5783f12da77055a0ab70df592dedefb8412
parent 754403 ff4a6a39e7d9d41e9cad9cf8407746d955509657
push id98837
push userbmo:poirot.alex@gmail.com
push dateTue, 13 Feb 2018 10:36:35 +0000
reviewersjdescottes
bugs1436978
milestone60.0a1
Bug 1436978 - Manual fixes r=jdescottes MozReview-Commit-ID: 3Me9swaixBH
devtools/server/actors/string.js
devtools/server/actors/thread.js
devtools/server/actors/utils/TabSources.js
--- a/devtools/server/actors/string.js
+++ b/devtools/server/actors/string.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";
 
 var {DebuggerServer} = require("devtools/server/main");
 
-
 var protocol = require("devtools/shared/protocol");
 const {longStringSpec} = require("devtools/shared/specs/string");
 
 exports.LongStringActor = protocol.ActorClassWithSpec(longStringSpec, {
   initialize: function (conn, str) {
     protocol.Actor.prototype.initialize.call(this, conn);
     this.str = str;
     this.short = (this.str.length < DebuggerServer.LONG_STRING_LENGTH);
--- a/devtools/server/actors/thread.js
+++ b/devtools/server/actors/thread.js
@@ -12,18 +12,16 @@ const { ActorPool, GeneratedLocation } =
 const { createValueGrip, longStringGrip } = require("devtools/server/actors/object");
 const { ActorClassWithSpec } = require("devtools/shared/protocol");
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const flags = require("devtools/shared/flags");
 const { assert, dumpn } = DevToolsUtils;
 const { DevToolsWorker } = require("devtools/shared/worker/worker");
 const { threadSpec } = require("devtools/shared/specs/script");
 
-const { resolve, reject, all } = promise;
-
 loader.lazyGetter(this, "Debugger", () => {
   let Debugger = require("Debugger");
   hackDebugger(Debugger);
   return Debugger;
 });
 loader.lazyRequireGetter(this, "findCssSelector", "devtools/shared/inspector/css-logic", true);
 loader.lazyRequireGetter(this, "BreakpointActor", "devtools/server/actors/breakpoint", true);
 loader.lazyRequireGetter(this, "setBreakpointAtEntryPoints", "devtools/server/actors/breakpoint", true);
@@ -374,17 +372,17 @@ const ThreadActor = ActorClassWithSpec(t
                       return undefined;
                     }
 
                     packet.frame.where = {
                       source: originalLocation.originalSourceActor.form(),
                       line: originalLocation.originalLine,
                       column: originalLocation.originalColumn
                     };
-                    resolve(onPacket(packet))
+                    Promise.resolve(onPacket(packet))
           .catch(error => {
             reportError(error);
             return {
               error: "unknownError",
               message: error.message + "\n" + error.stack
             };
           })
           .then(pkt => {
@@ -559,18 +557,18 @@ const ThreadActor = ActorClassWithSpec(t
    * @param Object request
    *        The request packet received over the RDP.
    * @returns A promise that resolves to true once the hooks are attached, or is
    *          rejected with an error packet.
    */
   _handleResumeLimit: function (request) {
     let steppingType = request.resumeLimit.type;
     if (!["break", "step", "next", "finish"].includes(steppingType)) {
-      return reject({ error: "badParameterType",
-                      message: "Unknown resumeLimit type" });
+      return Promise.reject({ error: "badParameterType",
+                              message: "Unknown resumeLimit type" });
     }
 
     const generatedLocation = this.sources.getFrameLocation(this.youngestFrame);
     return this.sources.getOriginalLocation(generatedLocation)
       .then(originalLocation => {
         const { onEnterFrame, onPop, onStep } = this._makeSteppingHooks(originalLocation,
                                                                         steppingType);
 
@@ -670,17 +668,17 @@ const ThreadActor = ActorClassWithSpec(t
       };
     }
 
     let resumeLimitHandled;
     if (request && request.resumeLimit) {
       resumeLimitHandled = this._handleResumeLimit(request);
     } else {
       this._clearSteppingHooks(this.youngestFrame);
-      resumeLimitHandled = resolve(true);
+      resumeLimitHandled = Promise.resolve(true);
     }
 
     return resumeLimitHandled.then(() => {
       if (request) {
         this._options.pauseOnExceptions = request.pauseOnExceptions;
         this._options.ignoreCaughtExceptions = request.ignoreCaughtExceptions;
         this.maybePauseOnExceptions();
         this._maybeListenToEvents(request);
@@ -941,17 +939,17 @@ const ThreadActor = ActorClassWithSpec(t
           column: originalLocation.originalColumn
         };
         form.source = sourceForm;
         return form;
       });
       promises.push(framePromise);
     }
 
-    return all(promises).then(function (frames) {
+    return Promise.all(promises).then(function (frames) {
       // Filter null values because sourcemapping may have failed.
       return { frames: frames.filter(x => !!x) };
     });
   },
 
   onReleaseMany: function (request) {
     if (!request.actors) {
       return { error: "missingParameter",
@@ -983,17 +981,17 @@ const ThreadActor = ActorClassWithSpec(t
 
     for (let i = 0, len = scripts.length; i < len; i++) {
       let s = scripts[i];
       if (s.source) {
         sourcesToScripts.set(s.source, s);
       }
     }
 
-    return all([...sourcesToScripts.values()].map(script => {
+    return Promise.all([...sourcesToScripts.values()].map(script => {
       return this.sources.createSourceActors(script.source);
     }));
   },
 
   onSources: function (request) {
     return this._discoverSources().then(() => {
       // No need to flush the new source packets here, as we are sending the
       // list of sources out immediately and we don't need to invoke the
--- a/devtools/server/actors/utils/TabSources.js
+++ b/devtools/server/actors/utils/TabSources.js
@@ -3,17 +3,16 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 "use strict";
 
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const { assert, fetch } = DevToolsUtils;
 const EventEmitter = require("devtools/shared/old-event-emitter");
 const { OriginalLocation, GeneratedLocation } = require("devtools/server/actors/common");
-const { resolve } = require("promise");
 const { joinURI } = require("devtools/shared/path");
 
 loader.lazyRequireGetter(this, "SourceActor", "devtools/server/actors/source", true);
 loader.lazyRequireGetter(this, "isEvalSource", "devtools/server/actors/source", true);
 loader.lazyRequireGetter(this, "SourceMapConsumer", "source-map", true);
 loader.lazyRequireGetter(this, "SourceMapGenerator", "source-map", true);
 loader.lazyRequireGetter(this, "WasmRemap", "devtools/shared/wasm-source-map", true);
 
@@ -367,17 +366,17 @@ TabSources.prototype = {
    * instead of this.
    *
    * @param Debugger.Source source
    *        The source instance to create actors for.
    * @return Promise of an array of source actors
    */
   _createSourceMappedActors: function (source) {
     if (!this._useSourceMaps || !source.sourceMapURL) {
-      return resolve(null);
+      return Promise.resolve(null);
     }
 
     return this.fetchSourceMap(source)
       .then(map => {
         if (map) {
           return map.sources.map(s => {
             return this.source({ originalUrl: s, generatedSource: source });
           }).filter(isNotNull);
@@ -410,21 +409,21 @@ TabSources.prototype = {
    * and source maps are enabled (see `_fetchSourceMap`).
    *
    * @param Debugger.Source source
    *        The source instance to get sourcemaps for.
    * @return Promise of a SourceMapConsumer
    */
   fetchSourceMap: function (source) {
     if (!this._useSourceMaps) {
-      return resolve(null);
+      return Promise.resolve(null);
     } else if (this._sourceMaps.has(source)) {
       return this._sourceMaps.get(source);
     } else if (!source || !source.sourceMapURL) {
-      return resolve(null);
+      return Promise.resolve(null);
     }
 
     let sourceMapURL = source.sourceMapURL;
     if (source.url) {
       sourceMapURL = joinURI(source.url, sourceMapURL);
     }
     let result = this._fetchSourceMap(sourceMapURL, source.url);
 
@@ -441,24 +440,24 @@ TabSources.prototype = {
   },
 
   /**
    * Return a promise of a SourceMapConsumer for the source map for
    * `source`. The resolved result may be null if the source does not
    * have a source map or source maps are disabled.
    */
   getSourceMap: function (source) {
-    return resolve(this._sourceMaps.get(source));
+    return Promise.resolve(this._sourceMaps.get(source));
   },
 
   /**
    * Set a SourceMapConsumer for the source map for |source|.
    */
   setSourceMap: function (source, map) {
-    this._sourceMaps.set(source, resolve(map));
+    this._sourceMaps.set(source, Promise.resolve(map));
   },
 
   /**
    * Return a promise of a SourceMapConsumer for the source map located at
    * |absSourceMapURL|, which must be absolute. If there is already such a
    * promise extant, return it. This will not fetch if source maps are
    * disabled.
    *
@@ -561,17 +560,17 @@ TabSources.prototype = {
       // avoid tons of work serializing the sourcemap into a data url,
       // just make a fake URL and stick the sourcemap there.
       url = "internal://sourcemap" + (this._anonSourceMapId++) + "/";
     }
     source.sourceMapURL = url;
 
     // Forcefully set the sourcemap cache. This will be used even if
     // sourcemaps are disabled.
-    this._sourceMapCache[url] = resolve(map);
+    this._sourceMapCache[url] = Promise.resolve(map);
     this.emit("updatedSource", this.getSourceActor(source));
   },
 
   /**
    * Return the non-source-mapped location of the given Debugger.Frame. If the
    * frame does not have a script, the location's properties are all null.
    *
    * @param Debugger.Frame frame