Bug 1454373 - Switch protocol.js to native promises. r=jryans
☠☠ backed out by 3ee4cf8dc2ed ☠ ☠
authorAlexandre Poirot <poirot.alex@gmail.com>
Fri, 13 Apr 2018 14:34:12 -0700
changeset 467535 b2ada4fddfa05ef471e99aec6035e63519b6f10d
parent 467519 8b0ba3f7d09995395787369b653c5976dd69fab5
child 467536 4ec712f0aa130867806fa76a9fe275f37f307a6b
push id9165
push userasasaki@mozilla.com
push dateThu, 26 Apr 2018 21:04:54 +0000
treeherdermozilla-beta@064c3804de2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersjryans
bugs1454373
milestone61.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 1454373 - Switch protocol.js to native promises. r=jryans MozReview-Commit-ID: ALifNayHJJG
devtools/server/tests/unit/test_protocol_stack.js
devtools/shared/protocol.js
--- a/devtools/server/tests/unit/test_protocol_stack.js
+++ b/devtools/server/tests/unit/test_protocol_stack.js
@@ -71,17 +71,17 @@ function run_test() {
 
   client.connect().then(function onConnect() {
     rootClient = RootFront(client);
 
     rootClient.simpleReturn().then(() => {
       let stack = Components.stack;
       while (stack) {
         info(stack.name);
-        if (stack.name == "onConnect") {
+        if (stack.name.includes("run_test/onConnect")) {
           // Reached back to outer function before request
           ok(true, "Complete stack");
           return;
         }
         stack = stack.asyncCaller || stack.caller;
       }
       ok(false, "Incomplete stack");
     }, () => {
--- a/devtools/shared/protocol.js
+++ b/devtools/shared/protocol.js
@@ -1,15 +1,14 @@
 /* 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 promise = require("promise");
 var defer = require("devtools/shared/defer");
 const { extend } = require("devtools/shared/extend");
 var EventEmitter = require("devtools/shared/event-emitter");
 var {getStack, callFunctionWithAsyncStack} = require("devtools/shared/platform/stack");
 var {settleAll} = require("devtools/shared/DevToolsUtils");
 var {lazyLoadSpec, lazyLoadFront} = require("devtools/shared/specs/index");
 
 /**
@@ -978,17 +977,17 @@ Actor.prototype = extend(Pool.prototype,
     this.conn.send({
       from: this.actorID,
       error: error.error || "unknownError",
       message: error.message
     });
   },
 
   _queueResponse: function(create) {
-    let pending = this._pendingResponse || promise.resolve(null);
+    let pending = this._pendingResponse || Promise.resolve(null);
     let response = create(pending);
     this._pendingResponse = response;
   }
 });
 exports.Actor = Actor;
 
 /**
  * Tags a prtotype method as an actor method implementation.
@@ -1243,17 +1242,17 @@ Front.prototype = extend(Pool.prototype,
     return Pool.prototype.manage.call(this, front);
   },
 
   /**
    * @returns a promise that will resolve to the actorID this front
    * represents.
    */
   actor: function() {
-    return promise.resolve(this.actorID);
+    return Promise.resolve(this.actorID);
   },
 
   toString: function() {
     return "[Front for " + this.typeName + "/" + this.actorID + "]";
   },
 
   /**
    * Update the actor from its representation.
@@ -1309,17 +1308,17 @@ Front.prototype = extend(Pool.prototype,
         throw ex;
       }
       if (event.pre) {
         let results = event.pre.map(pre => pre.apply(this, args));
 
         // Check to see if any of the preEvents returned a promise -- if so,
         // wait for their resolution before emitting. Otherwise, emit synchronously.
         if (results.some(result => result && typeof result.then === "function")) {
-          promise.all(results).then(() => {
+          Promise.all(results).then(() => {
             return EventEmitter.emit.apply(null, [this, event.name].concat(args));
           });
           return;
         }
       }
 
       EventEmitter.emit.apply(null, [this, event.name].concat(args));
       return;