Bug 1185106 - Part 11.2: Add helper functions for async/await test. r=till

MozReview-Commit-ID: B3lwv5ejz5g
This commit is contained in:
Tooru Fujisawa 2016-08-29 02:06:19 +09:00
Родитель 5d7377b42e
Коммит 0cfe3ce610
1 изменённых файлов: 26 добавлений и 0 удалений

Просмотреть файл

@ -0,0 +1,26 @@
(function(global) {
function getPromiseResult(promise) {
var result, error, caught = false;
promise.then(r => { result = r; },
e => { caught = true; error = e; });
drainJobQueue();
if (caught)
throw error;
return result;
}
function assertEventuallyEq(promise, expected) {
assertEq(getPromiseResult(promise), expected);
}
global.assertEventuallyEq = assertEventuallyEq;
function assertEventuallyThrows(promise, expectedErrorType) {
assertThrowsInstanceOf(() => getPromiseResult(promise), expectedErrorType);
};
global.assertEventuallyThrows = assertEventuallyThrows;
function assertEventuallyDeepEq(promise, expected) {
assertDeepEq(getPromiseResult(promise), expected);
};
global.assertEventuallyDeepEq = assertEventuallyDeepEq;
})(this);