Skip to content

Instantly share code, notes, and snippets.

@lgrahl
Last active May 14, 2018
Embed
What would you like to do?
Expose "done" promise
// Disable global timeout
// IMPORTANT: You need to add a timeout to *every test* of this file!
setup({ explicit_timeout: true });
promise_test(async (t) => {
const pc1 = new RTCPeerConnection();
const pc2 = new RTCPeerConnection();
t.add_cleanup(() => pc1.close());
t.add_cleanup(() => pc2.close());
exchangeIceCandidates(pc1, pc2);
// Create a channel on pc1
const dc = pc1.createDataChannel('onopen');
dc.onopen = t.step_func(() => {
assert_equals(dc.readyState, 'open', 'Channel should be open after onopen has fired');
t.done();
});
await doSignalingHandshake(pc1, pc2);
await t.done_promise;
}, 'In-band channel: Open event should be fired (local) when the data channel opens', {
timeout: 5000
});
diff --git a/resources/testharness.js b/resources/testharness.js
index 39a467c..8862b2a 100644
--- a/resources/testharness.js
+++ b/resources/testharness.js
@@ -526,7 +526,7 @@ policies and contribution forms [3].
tests.promise_tests = Promise.resolve();
}
tests.promise_tests = tests.promise_tests.then(function() {
- var donePromise = new Promise(function(resolve) {
+ test.done_promise = new Promise(function(resolve) {
test._add_cleanup(resolve);
});
var promise = test.step(func, test, test);
@@ -545,7 +545,7 @@ policies and contribution forms [3].
assert(false, "promise_test", null,
"Unhandled rejection with value: ${value}", {value:value});
}));
- return donePromise;
+ return test.done_promise;
});
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment