Bug 1545680 [wpt PR 16368] - Fix flakiness in audioworklet-suspend.https.html, a=testonly

Automatic update from web-platform-tests
Fix flakiness in audioworklet-suspend.https.html

It is because the actual suspension takes time to stop the render loop
completely. So the current time advances a little after the suspension
and the assertion that compares two timestamps fails.

This CL fixes the problem by:
1. Suspend the context immediately after its creation.
2. Cache timestamp A after the worklet module loading is completed.
3. Check timestamp B after 500ms. If the context is not suspended
   (which is the original bug), two timestamps A and B won't match.

Bug: 953332
Test: external/wpt/webaudio/the-audio-api/the-audioworklet-interface/audioworklet-suspend.https.html
Change-Id: I3fc4ccf78ec9c137128f8605d502692be303b02e
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1570129
Reviewed-by: Raymond Toy <rtoy@chromium.org>
Reviewed-by: Robert Ma <robertma@chromium.org>
Commit-Queue: Hongchan Choi <hongchan@chromium.org>
Cr-Commit-Position: refs/heads/master@{#651437}

--

wpt-commits: 3f690a244306cae2276fd1e5f620f5e83096a445
wpt-pr: 16368
This commit is contained in:
Hongchan Choi 2019-05-17 14:37:50 +00:00 коммит произвёл James Graham
Родитель 3183db816e
Коммит 392acd3ba0
1 изменённых файлов: 7 добавлений и 5 удалений

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

@ -14,22 +14,24 @@
const context = new AudioContext();
const filePath = 'processors/dummy-processor.js';
context.suspend();
// Suspends the context right away and then activate worklet. The current
// time must not advance since the context is suspended.
audit.define(
{label: 'load-worklet-and-suspend'},
async (task, should) => {
context.suspend();
const suspendTime = context.currentTime;
await context.audioWorklet.addModule(filePath);
const suspendTime = context.currentTime;
const dummy = new AudioWorkletNode(context, 'dummy');
dummy.connect(context.destination);
task.timeout(() => {
should(context.currentTime, 'context.currentTime')
.beEqualTo(suspendTime);
should(context.currentTime === suspendTime,
'context.currentTime did not change after worklet started')
.beTrue();
should(context.state, 'context.state').beEqualTo('suspended');
task.done();
}, 1000);
}, 500);
});
audit.run();