AudioBufferSourceNode start method causes OfflineAudioContext to start running
https://bugs.webkit.org/show_bug.cgi?id=181939
<rdar://problem/36755393>
Reviewed by Eric Carlson.
Source/WebCore:
Test: webaudio/offlineaudiocontext-restriction.html
Don't respect playback restrictions for offline AudioContexts.
* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::constructCommon):
* Modules/webaudio/AudioContext.h:
(WebCore::AudioContext::isOfflineContext const):
(WebCore::AudioContext::userGestureRequiredForAudioStart const):
(WebCore::AudioContext::pageConsentRequiredForAudioStart const):
(WebCore::AudioContext::isOfflineContext): Deleted.
LayoutTests:
* webaudio/offlineaudiocontext-restriction-expected.txt: Added.
* webaudio/offlineaudiocontext-restriction.html: Added.
git-svn-id: http://svn.webkit.org/repository/webkit/trunk@230158 268f45cc-cd09-0410-ab3c-d52691b4dbfc
diff --git a/LayoutTests/webaudio/offlineaudiocontext-restriction.html b/LayoutTests/webaudio/offlineaudiocontext-restriction.html
new file mode 100644
index 0000000..f9d6a6f
--- /dev/null
+++ b/LayoutTests/webaudio/offlineaudiocontext-restriction.html
@@ -0,0 +1,45 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<script src="../resources/js-test.js"></script>
+<script type="text/javascript" src="resources/audio-testing.js"></script>
+</head>
+
+<body>
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description('OfflineAudioContexts should not have behavior restrictions.');
+
+var context = null;
+var node = null;
+var calledResumeWithUserGesture = false;
+
+function runTest() {
+ window.jsTestIsAsync = true;
+
+ context = new webkitOfflineAudioContext(2, 1000, 44100);
+
+ if (window.internals)
+ internals.setAudioContextRestrictions(context, 'RequireUserGestureForAudioStart');
+
+ shouldBe('context.state', '"suspended"');
+
+ node = context.createBufferSource();
+ evalAndLog('node.connect(context.destination)');
+ evalAndLog('node.start()');
+ shouldBe('context.state', '"suspended"');
+
+ debug('Calling context.startRendering() without a user gesture');
+ context.startRendering();
+ shouldBe('context.state', '"running"');
+ finishJSTest();
+}
+
+runTest();
+
+</script>
+</body>
+</html>