Skip to content
This repository was archived by the owner on Sep 19, 2018. It is now read-only.

Commit 7e0a754

Browse files
pwnallMs2ger
authored andcommitted
Unblock test promise chain when done() is called early.
This makes it possible to end a promise_test by calling Test.done(). Previously, that would work for a single test, but would get any follow-up test stuck waiting for the global promise chain to resolve.
1 parent 65ae060 commit 7e0a754

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

testharness.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -527,12 +527,14 @@ policies and contribution forms [3].
527527
tests.promise_tests = Promise.resolve();
528528
}
529529
tests.promise_tests = tests.promise_tests.then(function() {
530+
var donePromise = new Promise(function(resolve) {
531+
test.add_cleanup(resolve);
532+
});
530533
var promise = test.step(func, test, test);
531534
test.step(function() {
532535
assert_not_equals(promise, undefined);
533536
});
534-
return Promise.resolve(promise)
535-
.then(
537+
Promise.resolve(promise).then(
536538
function() {
537539
test.done();
538540
})
@@ -544,6 +546,7 @@ policies and contribution forms [3].
544546
assert(false, "promise_test", null,
545547
"Unhandled rejection with value: ${value}", {value:value});
546548
}));
549+
return donePromise;
547550
});
548551
}
549552

0 commit comments

Comments
 (0)