Bug 1233891 - Use DOM promises instead of deprecated sync promises in devtools/shared. r=jryans draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 20 Jun 2018 05:22:24 -0700
changeset 808706 88176c9163506e2d1aad80bf2e6e08c96dc886cc
parent 808705 3750a1d2a8c65a5281ffa293347c95c5501ed55a
child 808707 f4c5e0aa72ef6d260b4b3bff77eafaca9fe89978
push id113465
push userbmo:poirot.alex@gmail.com
push dateWed, 20 Jun 2018 12:30:56 +0000
reviewersjryans
bugs1233891
milestone62.0a1
Bug 1233891 - Use DOM promises instead of deprecated sync promises in devtools/shared. r=jryans MozReview-Commit-ID: 6QpV2e8JdwU
devtools/shared/client/debugger-client.js
devtools/shared/client/tab-client.js
devtools/shared/client/thread-client.js
--- a/devtools/shared/client/debugger-client.js
+++ b/devtools/shared/client/debugger-client.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";
 
 const Services = require("Services");
-const promise = require("devtools/shared/deprecated-sync-thenables");
 
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const { getStack, callFunctionWithAsyncStack } = require("devtools/shared/platform/stack");
 const eventSource = require("devtools/shared/client/event-source");
 const {
   ThreadStateTypes,
   UnsolicitedNotifications,
   UnsolicitedPauses,
@@ -332,17 +331,17 @@ DebuggerClient.prototype = {
   attachTab: function(targetActor) {
     if (this._clients.has(targetActor)) {
       const cachedTab = this._clients.get(targetActor);
       const cachedResponse = {
         cacheDisabled: cachedTab.cacheDisabled,
         javascriptEnabled: cachedTab.javascriptEnabled,
         traits: cachedTab.traits,
       };
-      return promise.resolve([cachedResponse, cachedTab]);
+      return Promise.resolve([cachedResponse, cachedTab]);
     }
 
     const packet = {
       to: targetActor,
       type: "attach"
     };
     return this.request(packet).then(response => {
       const tabClient = new TabClient(this, response);
@@ -354,17 +353,17 @@ DebuggerClient.prototype = {
   attachWorker: function(workerTargetActor) {
     let workerClient = this._clients.get(workerTargetActor);
     if (workerClient !== undefined) {
       const response = {
         from: workerClient.actor,
         type: "attached",
         url: workerClient.url
       };
-      return promise.resolve([response, workerClient]);
+      return Promise.resolve([response, workerClient]);
     }
 
     return this.request({ to: workerTargetActor, type: "attach" }).then(response => {
       workerClient = new WorkerClient(this, response);
       this.registerClient(workerClient);
       return [response, workerClient];
     });
   },
@@ -422,17 +421,17 @@ DebuggerClient.prototype = {
    *        The actor ID for the thread to attach.
    * @param object options
    *        Configuration options.
    *        - useSourceMaps: whether to use source maps or not.
    */
   attachThread: function(threadActor, options = {}) {
     if (this._clients.has(threadActor)) {
       const client = this._clients.get(threadActor);
-      return promise.resolve([{}, client]);
+      return Promise.resolve([{}, client]);
     }
 
     const packet = {
       to: threadActor,
       type: "attach",
       options,
     };
     return this.request(packet).then(response => {
@@ -537,17 +536,17 @@ DebuggerClient.prototype = {
       return onResponse(response) || response;
     };
 
     if (this._closed) {
       const msg = "'" + type + "' request packet to " +
                 "'" + packet.to + "' " +
                "can't be sent as the connection is closed.";
       const resp = { error: "connectionClosed", message: msg };
-      return promise.reject(safeOnResponse(resp));
+      return Promise.reject(safeOnResponse(resp));
     }
 
     const request = new Request(packet);
     request.format = "json";
     request.stack = getStack();
 
     // Implement a Promise like API on the returned object
     // that resolves/rejects on request response
--- a/devtools/shared/client/tab-client.js
+++ b/devtools/shared/client/tab-client.js
@@ -1,16 +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";
 
-const promise = require("devtools/shared/deprecated-sync-thenables");
-
 const eventSource = require("devtools/shared/client/event-source");
 const {arg, DebuggerClient} = require("devtools/shared/client/debugger-client");
 loader.lazyRequireGetter(this, "ThreadClient", "devtools/shared/client/thread-client");
 
 /**
  * Creates a tab client for the remote debugging protocol server. This client
  * is a front to the tab actor created in the server side, hiding the protocol
  * details in a traditional JavaScript API.
@@ -44,17 +42,17 @@ TabClient.prototype = {
    * Attach to a thread actor.
    *
    * @param object options
    *        Configuration options.
    *        - useSourceMaps: whether to use source maps or not.
    */
   attachThread: function(options = {}) {
     if (this.thread) {
-      return promise.resolve([{}, this.thread]);
+      return Promise.resolve([{}, this.thread]);
     }
 
     const packet = {
       to: this._threadActor,
       type: "attach",
       options,
     };
     return this.request(packet).then(response => {
--- a/devtools/shared/client/thread-client.js
+++ b/devtools/shared/client/thread-client.js
@@ -1,16 +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";
 
-const promise = require("devtools/shared/deprecated-sync-thenables");
-
 const DevToolsUtils = require("devtools/shared/DevToolsUtils");
 const {arg, DebuggerClient} = require("devtools/shared/client/debugger-client");
 const eventSource = require("devtools/shared/client/event-source");
 const {ThreadStateTypes} = require("devtools/shared/client/constants");
 
 loader.lazyRequireGetter(this, "ArrayBufferClient", "devtools/shared/client/array-buffer-client");
 loader.lazyRequireGetter(this, "EnvironmentClient", "devtools/shared/client/environment-client");
 loader.lazyRequireGetter(this, "LongStringClient", "devtools/shared/client/long-string-client");
@@ -234,17 +232,17 @@ ThreadClient.prototype = {
           onResponse(response);
           return response;
         }
         return this.resume(onResponse);
       });
     }
 
     onResponse();
-    return promise.resolve();
+    return Promise.resolve();
   },
 
   /**
    * Enable pausing when the specified DOM events are triggered. Disabling
    * pausing on an event can be realized by calling this method with the updated
    * array of events that doesn't contain it.
    *
    * @param array|string events