Bug 1233891 - Use defer module instead of deprecated-sync-thenable. r=jryans draft
authorAlexandre Poirot <poirot.alex@gmail.com>
Wed, 20 Jun 2018 05:27:57 -0700
changeset 808707 f4c5e0aa72ef6d260b4b3bff77eafaca9fe89978
parent 808706 88176c9163506e2d1aad80bf2e6e08c96dc886cc
child 808708 4f6141610a3ca0852050f7aea77e648e3b83ba59
push id113465
push userbmo:poirot.alex@gmail.com
push dateWed, 20 Jun 2018 12:30:56 +0000
reviewersjryans
bugs1233891
milestone62.0a1
Bug 1233891 - Use defer module instead of deprecated-sync-thenable. r=jryans MozReview-Commit-ID: 6KNRbw1uxsg
devtools/shared/client/breakpoint-client.js
devtools/shared/client/debugger-client.js
--- a/devtools/shared/client/breakpoint-client.js
+++ b/devtools/shared/client/breakpoint-client.js
@@ -1,18 +1,17 @@
 /* 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 {DebuggerClient} = require("devtools/shared/client/debugger-client");
+const defer = require("devtools/shared/defer");
 
 /**
  * Breakpoint clients are used to remove breakpoints that are no longer used.
  *
  * @param client DebuggerClient
  *        The debugger client parent.
  * @param sourceClient SourceClient
  *        The source where this breakpoint exists
@@ -84,17 +83,17 @@ BreakpointClient.prototype = {
     return this.conditionalExpression;
   },
 
   /**
    * Set the condition of this breakpoint
    */
   setCondition: function(gThreadClient, condition) {
     const root = this._client.mainRoot;
-    const deferred = promise.defer();
+    const deferred = defer();
 
     if (root.traits.conditionalBreakpoints) {
       const info = {
         line: this.location.line,
         column: this.location.column,
         condition: condition
       };
 
--- a/devtools/shared/client/debugger-client.js
+++ b/devtools/shared/client/debugger-client.js
@@ -1,15 +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 defer = require("devtools/shared/defer");
 
 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,
@@ -164,17 +165,17 @@ DebuggerClient.prototype = {
    *
    * @return Promise
    *         Resolves once connected with an array whose first element
    *         is the application type, by default "browser", and the second
    *         element is the traits object (help figure out the features
    *         and behaviors of the server we connect to. See RootActor).
    */
   connect: function(onConnected) {
-    const deferred = promise.defer();
+    const deferred = defer();
 
     this.addOneTimeListener("connected", (name, applicationType, traits) => {
       this.traits = traits;
       if (onConnected) {
         onConnected(applicationType, traits);
       }
       deferred.resolve([applicationType, traits]);
     });
@@ -249,17 +250,17 @@ DebuggerClient.prototype = {
    * @param onClosed function
    *        If specified, will be called when the debugging connection
    *        has been closed. This parameter is deprecated - please use
    *        the returned Promise.
    * @return Promise
    *         Resolves after the underlying transport is closed.
    */
   close: function(onClosed) {
-    const deferred = promise.defer();
+    const deferred = defer();
     if (onClosed) {
       deferred.promise.then(onClosed);
     }
 
     // Disable detach event notifications, because event handlers will be in a
     // cleared scope by the time they run.
     this._eventsEnabled = false;
 
@@ -545,17 +546,17 @@ DebuggerClient.prototype = {
     }
 
     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
-    const deferred = promise.defer();
+    const deferred = defer();
     function listenerJson(resp) {
       removeRequestListeners();
       if (resp.error) {
         deferred.reject(safeOnResponse(resp));
       } else {
         deferred.resolve(safeOnResponse(resp));
       }
     }