Bug 1387128: Drop all promise = require("promise") and replace promise by Promise. r=tromey
Part5: manually get rid of some require("promise") leftovers.
MozReview-Commit-ID: G9JiSX7gRBy
--- a/devtools/server/actors/script.js
+++ b/devtools/server/actors/script.js
@@ -13,18 +13,16 @@ const { ObjectActor, createValueGrip, lo
const { ActorClassWithSpec } = require("devtools/shared/protocol");
const DevToolsUtils = require("devtools/shared/DevToolsUtils");
const flags = require("devtools/shared/flags");
const { assert, dumpn } = DevToolsUtils;
const xpcInspector = require("xpcInspector");
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, "CssLogic", "devtools/server/css-logic", true);
loader.lazyRequireGetter(this, "findCssSelector", "devtools/shared/inspector/css-logic", true);
loader.lazyRequireGetter(this, "events", "sdk/event/core");
@@ -730,17 +728,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 => {
@@ -904,18 +902,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"].indexOf(steppingType) == -1) {
- 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);
@@ -1015,17 +1013,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);
@@ -1286,17 +1284,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",
@@ -1328,17 +1326,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/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);
@@ -349,17 +348,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);
@@ -392,21 +391,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);
@@ -423,24 +422,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.
*
@@ -556,17 +555,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