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.
This commit is contained in:
Ehsan Akhgari 2014-10-20 09:07:41 -04:00
parent 92b4c47ea6
commit 4ad13a373c

View File

@ -31,33 +31,6 @@ function waitForManagerEvent(aEventName) {
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.
*
@ -73,8 +46,7 @@ function wrapDomRequestAsPromise(aRequest) {
*/
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 = [