haikuwebkit/LayoutTests/webaudio/suspend-context-before-firs...

27 lines
741 B
HTML
Raw Permalink Normal View History

Calling suspend() on audio context with no node does not prevent auto transition to running when first node is created https://bugs.webkit.org/show_bug.cgi?id=216972 <rdar://problem/69878834> Reviewed by Darin Adler. Source/WebCore: Add support for the [[suspended by user]] flag in the WebAudio specification: - https://www.w3.org/TR/webaudio/#dom-audiocontext-suspended-by-user-slot We set this flag when the script calls AudioContext.suspend(): - https://www.w3.org/TR/webaudio/#ref-for-dom-audiocontext-suspended-by-user-slot① We clear this flag when the script calls AudioContext.resume(): - https://www.w3.org/TR/webaudio/#ref-for-dom-audiocontext-suspended-by-user-slot We then prevent automated transition of the AudioContext to "rendering" when this flag is set: - https://www.w3.org/TR/webaudio/#ref-for-dom-audiocontext-suspended-by-user-slot② - https://www.w3.org/TR/webaudio/#ref-for-dom-audiocontext-suspended-by-user-slot③ Test: webaudio/suspend-context-before-first-node-creation.html * Modules/webaudio/BaseAudioContext.cpp: (WebCore::BaseAudioContext::startRendering): (WebCore::BaseAudioContext::suspendRendering): (WebCore::BaseAudioContext::resumeRendering): * Modules/webaudio/BaseAudioContext.h: LayoutTests: Add layout test coverage. * webaudio/suspend-context-before-first-node-creation-expected.txt: Added. * webaudio/suspend-context-before-first-node-creation.html: Added. Canonical link: https://commits.webkit.org/230022@main git-svn-id: https://svn.webkit.org/repository/webkit/trunk@267911 268f45cc-cd09-0410-ab3c-d52691b4dbfc
2020-10-03 01:26:13 +00:00
<!DOCTYPE html>
<html>
<body>
<script src="../resources/js-test.js"></script>
<script>
description("Tests that calling an AudioContext does not start rendering when adding a node if suspend() was called right after creation.");
jsTestIsAsync = true;
async function test() {
audioContext = new AudioContext();
shouldBeEqualToString("audioContext.state", "suspended");
await audioContext.suspend();
shouldBeEqualToString("audioContext.state", "suspended");
node = audioContext.createOscillator();
shouldBeEqualToString("audioContext.state", "suspended");
setTimeout(() => {
shouldBeEqualToString("audioContext.state", "suspended");
finishJSTest();
}, 10);
}
test();
</script>
</body>
</html>