Bug 1355473 - convert uses of 'defer' to 'new Promise' in client/responsivedesign; r=tromey
authorMatt R <matthieu.rigolot@gmail.com>
Sun, 21 May 2017 12:54:48 +0100
changeset 360664 79fcc56007c1
parent 360663 41e6f5b92613
child 360665 fb3190b6eb58
push id43422
push userttromey@mozilla.com
push dateThu, 25 May 2017 17:30:20 +0000
treeherderautoland@79fcc56007c1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerstromey
bugs1355473
milestone55.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 1355473 - convert uses of 'defer' to 'new Promise' in client/responsivedesign; r=tromey MozReview-Commit-ID: L9tNE28knjF
devtools/client/responsivedesign/test/browser_responsiveui_touch.js
devtools/client/responsivedesign/test/head.js
--- a/devtools/client/responsivedesign/test/browser_responsiveui_touch.js
+++ b/devtools/client/responsivedesign/test/browser_responsiveui_touch.js
@@ -137,12 +137,12 @@ function synthesizeClick(element) {
   BrowserTestUtils.synthesizeMouseAtCenter(element, { type: "mousedown", isSynthesized: false },
         gBrowser.selectedBrowser);
   BrowserTestUtils.synthesizeMouseAtCenter(element, { type: "mouseup", isSynthesized: false },
         gBrowser.selectedBrowser);
   return waitForClickEvent;
 }
 
 function pushPrefs(...aPrefs) {
-  let deferred = promise.defer();
-  SpecialPowers.pushPrefEnv({"set": aPrefs}, deferred.resolve);
-  return deferred.promise;
+  return new Promise(resolve => {
+    SpecialPowers.pushPrefEnv({"set": aPrefs}, resolve);
+  });
 }
--- a/devtools/client/responsivedesign/test/head.js
+++ b/devtools/client/responsivedesign/test/head.js
@@ -125,19 +125,19 @@ var closeToolbox = Task.async(function* 
 
 /**
  * Wait for the toolbox frame to receive focus after it loads
  * @param {Toolbox} toolbox
  * @return a promise that resolves when focus has been received
  */
 function waitForToolboxFrameFocus(toolbox) {
   info("Making sure that the toolbox's frame is focused");
-  let def = promise.defer();
-  waitForFocus(def.resolve, toolbox.win);
-  return def.promise;
+  return new Promise(resolve => {
+    waitForFocus(resolve, toolbox.win);
+  });
 }
 
 /**
  * Open the toolbox, with the inspector tool visible, and the sidebar that
  * corresponds to the given id selected
  * @return a promise that resolves when the inspector is ready and the sidebar
  * view is visible and ready
  */
@@ -205,37 +205,37 @@ var addTab = Task.async(function* (url) 
 });
 
 /**
  * Waits for the next load to complete in the current browser.
  *
  * @return promise
  */
 function waitForDocLoadComplete(aBrowser = gBrowser) {
-  let deferred = promise.defer();
-  let progressListener = {
-    onStateChange: function (webProgress, req, flags, status) {
-      let docStop = Ci.nsIWebProgressListener.STATE_IS_NETWORK |
-                    Ci.nsIWebProgressListener.STATE_STOP;
-      info(`Saw state ${flags.toString(16)} and status ${status.toString(16)}`);
+  return new Promise(resolve => {
+    let progressListener = {
+      onStateChange: function (webProgress, req, flags, status) {
+        let docStop = Ci.nsIWebProgressListener.STATE_IS_NETWORK |
+                      Ci.nsIWebProgressListener.STATE_STOP;
+        info(`Saw state ${flags.toString(16)} and status ${status.toString(16)}`);
 
-      // When a load needs to be retargetted to a new process it is cancelled
-      // with NS_BINDING_ABORTED so ignore that case
-      if ((flags & docStop) == docStop && status != Cr.NS_BINDING_ABORTED) {
-        aBrowser.removeProgressListener(progressListener);
-        info("Browser loaded");
-        deferred.resolve();
-      }
-    },
-    QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
+        // When a load needs to be retargetted to a new process it is cancelled
+        // with NS_BINDING_ABORTED so ignore that case
+        if ((flags & docStop) == docStop && status != Cr.NS_BINDING_ABORTED) {
+          aBrowser.removeProgressListener(progressListener);
+          info("Browser loaded");
+          resolve();
+        }
+      },
+      QueryInterface: XPCOMUtils.generateQI([Ci.nsIWebProgressListener,
                                            Ci.nsISupportsWeakReference])
-  };
-  aBrowser.addProgressListener(progressListener);
-  info("Waiting for browser load");
-  return deferred.promise;
+    };
+    aBrowser.addProgressListener(progressListener);
+    info("Waiting for browser load");
+  });
 }
 
 /**
  * Get the NodeFront for a node that matches a given css selector, via the
  * protocol.
  * @param {String|NodeFront} selector
  * @param {InspectorPanel} inspector The instance of InspectorPanel currently
  * loaded in the toolbox