зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1541630 [wpt PR 16142] - Use step_timeout() to force spin the EventLoop, a=testonly
Automatic update from web-platform-tests Use step_timeout() to force spin the EventLoop (#16142) Use step_timeout() to force spin the EventLoop. Also allow eventPromise to reject before acceptPromise resolves. -- wpt-commits: 3bfdeb8976fc51748935c8d1f1014dfba8e08dfb wpt-pr: 16142
This commit is contained in:
Родитель
90f325e1fe
Коммит
3c538314c0
|
@ -55,26 +55,29 @@ function testImmediateUpdate({ textContent: testName }) {
|
|||
const eventPromise = new Promise((resolve, reject) => {
|
||||
request.addEventListener(
|
||||
"shippingaddresschange",
|
||||
async ev => {
|
||||
// spin the event loop, sets [[waitForUpdate]] to true.
|
||||
await Promise.resolve();
|
||||
try {
|
||||
ev.updateWith(validDetails);
|
||||
resolve(); // This is bad.
|
||||
} catch (err) {
|
||||
reject(err); // this is good.
|
||||
}
|
||||
ev => {
|
||||
// Forces updateWith() to be run in the next event loop tick so that
|
||||
// [[waitForUpdate]] is already true when it runs.
|
||||
t.step_timeout(() => {
|
||||
try {
|
||||
ev.updateWith(validDetails);
|
||||
resolve(); // This is bad.
|
||||
} catch (err) {
|
||||
reject(err); // this is good.
|
||||
}
|
||||
});
|
||||
},
|
||||
{ once: true }
|
||||
);
|
||||
});
|
||||
const response = await request.show();
|
||||
const acceptPromise = request.show();
|
||||
await promise_rejects(
|
||||
t,
|
||||
"InvalidStateError",
|
||||
eventPromise,
|
||||
"The event loop already spun, so [[waitForUpdate]] is now true"
|
||||
);
|
||||
const response = await acceptPromise;
|
||||
await response.complete();
|
||||
}, testName.trim());
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче