Bug 1084381 - Do not wrap the DOMRequest in a promise in test_mmi_call_forwarding.js; r=hsinyi
authorEhsan Akhgari <ehsan@mozilla.com>
Mon, 20 Oct 2014 09:07:41 -0400
changeset 211321 ec0ccbcbb95ffb1d820c5959793b302ca315a83a
parent 211320 5019f9def6b6838bfdbb60d871567d62f93d0763
child 211322 57ed7482de8033b9d161c4d69a5af5a1eb7e3064
push id27673
push userkwierso@gmail.com
push dateTue, 21 Oct 2014 01:57:45 +0000
treeherdermozilla-central@29fbfc1b31aa [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewershsinyi
bugs1084381
milestone36.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 1084381 - Do not wrap the DOMRequest in a promise in test_mmi_call_forwarding.js; r=hsinyi DOMRequest now has a .then() method compatible with Promise.
dom/telephony/test/marionette/test_mmi_call_forwarding.js
--- a/dom/telephony/test/marionette/test_mmi_call_forwarding.js
+++ b/dom/telephony/test/marionette/test_mmi_call_forwarding.js
@@ -27,59 +27,31 @@ function waitForManagerEvent(aEventName)
     ok(true, "MobileConnection event '" + aEventName + "' got.");
     deferred.resolve(aEvent);
   });
 
   return deferred.promise;
 }
 
 /**
- * Wrap DOMRequest onsuccess/onerror events to Promise resolve/reject.
- *
- * Fulfill params: A DOMEvent.
- * Reject params: A DOMEvent.
- *
- * @param aRequest
- *        A DOMRequest instance.
- *
- * @return A deferred promise.
- */
-function wrapDomRequestAsPromise(aRequest) {
-  let deferred = Promise.defer();
-
-  ok(aRequest instanceof DOMRequest,
-     "aRequest is instanceof " + aRequest.constructor);
-
-  aRequest.addEventListener("success", function(aEvent) {
-    deferred.resolve(aEvent);
-  });
-  aRequest.addEventListener("error", function(aEvent) {
-    deferred.reject(aEvent);
-  });
-
-  return deferred.promise;
-}
-
-/**
  * Configures call forward options.
  *
  * Fulfill params: (none)
  * Reject params:
  *   'RadioNotAvailable', 'RequestNotSupported', 'InvalidParameter', or
  *   'GenericFailure'.
  *
  * @param aOptions
  *        A MozCallForwardingOptions.
  *
  * @return A deferred promise.
  */
 function setCallForwardingOption(aOptions) {
   let request = connection.setCallForwardingOption(aOptions);
-  return wrapDomRequestAsPromise(request)
-    .then(null, () => { throw request.error; });
+  return request.then(null, () => { throw request.error; });
 }
 
 const TEST_DATA = [
   {
     reason: MozMobileConnection.CALL_FORWARD_REASON_UNCONDITIONAL,
     number: "+886912345678",
     serviceClass: MozMobileConnection.ICC_SERVICE_CLASS_VOICE,
     timeSeconds: 5