WebAudio does not resume when moving from background to foreground tab.
authorjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Oct 2016 01:18:45 +0000 (01:18 +0000)
committerjer.noble@apple.com <jer.noble@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Sat, 29 Oct 2016 01:18:45 +0000 (01:18 +0000)
https://bugs.webkit.org/show_bug.cgi?id=164043

Reviewed by Darin Adler.

Source/WebCore:

Test: webaudio/page-canstartmedia.html

* Modules/webaudio/AudioContext.cpp:
(WebCore::AudioContext::mediaCanStart):

LayoutTests:

* webaudio/page-canstartmedia-expected.txt: Added.
* webaudio/page-canstartmedia.html: Added.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@208092 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/webaudio/page-canstartmedia-expected.txt [new file with mode: 0644]
LayoutTests/webaudio/page-canstartmedia.html [new file with mode: 0644]
Source/WebCore/ChangeLog
Source/WebCore/Modules/webaudio/AudioContext.cpp

index 33233a4..ac898ab 100644 (file)
@@ -1,3 +1,13 @@
+2016-10-28  Jer Noble  <jer.noble@apple.com>
+
+        WebAudio does not resume when moving from background to foreground tab.
+        https://bugs.webkit.org/show_bug.cgi?id=164043
+
+        Reviewed by Darin Adler.
+
+        * webaudio/page-canstartmedia-expected.txt: Added.
+        * webaudio/page-canstartmedia.html: Added.
+
 2016-10-28  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         iOS autocorrection does not trigger an input event of inputType "insertReplacementText"
diff --git a/LayoutTests/webaudio/page-canstartmedia-expected.txt b/LayoutTests/webaudio/page-canstartmedia-expected.txt
new file mode 100644 (file)
index 0000000..2948785
--- /dev/null
@@ -0,0 +1,9 @@
+Tests that AudioContext resume method resolve promises when notified by Page that it can start media playback.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+PASS context resolve callback called
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/webaudio/page-canstartmedia.html b/LayoutTests/webaudio/page-canstartmedia.html
new file mode 100644 (file)
index 0000000..ca1b514
--- /dev/null
@@ -0,0 +1,55 @@
+<!DOCTYPE html>
+
+<html>
+<head>
+<script src="../resources/js-test-pre.js"></script>
+</head>
+
+<body>
+
+<div id="description"></div>
+<div id="console"></div>
+
+<script>
+description("Tests that AudioContext resume method resolve promises when notified by Page that it can start media playback.");
+
+function runTest() {
+    if (window.testRunner) {
+        testRunner.dumpAsText();
+        testRunner.waitUntilDone();
+    }
+
+    if (window.internals)
+        internals.settings.setCanStartMedia(false);
+
+    window.jsTestIsAsync = true;
+
+    context = new webkitAudioContext();
+
+    context.resume().then(resumePromiseResolved).catch(resumePromiseRejected);
+
+    setTimeout(allowStartMedia, 100);
+}
+
+function allowStartMedia() {
+    if (window.internals)
+        internals.settings.setCanStartMedia(true);
+}
+
+function resumePromiseResolved() {
+    testPassed('context resolve callback called')
+    finishJSTest();
+}
+
+function resumePromiseRejected() {
+    testFailed('context reject callback called');
+    finishJSTest();
+}
+
+runTest();
+
+</script>
+
+<script src="../resources/js-test-post.js"></script>
+</body>
+</html>
index e4404f1..07dc9dd 100644 (file)
@@ -1,3 +1,15 @@
+2016-10-28  Jer Noble  <jer.noble@apple.com>
+
+        WebAudio does not resume when moving from background to foreground tab.
+        https://bugs.webkit.org/show_bug.cgi?id=164043
+
+        Reviewed by Darin Adler.
+
+        Test: webaudio/page-canstartmedia.html
+
+        * Modules/webaudio/AudioContext.cpp:
+        (WebCore::AudioContext::mediaCanStart):
+
 2016-10-28  Wenson Hsieh  <wenson_hsieh@apple.com>
 
         iOS autocorrection does not trigger an input event of inputType "insertReplacementText"
index 5eaf15a..b8708af 100644 (file)
@@ -960,6 +960,7 @@ void AudioContext::startRendering()
 void AudioContext::mediaCanStart()
 {
     removeBehaviorRestriction(AudioContext::RequirePageConsentForAudioStartRestriction);
+    mayResumePlayback(true);
 }
 
 MediaProducer::MediaStateFlags AudioContext::mediaState() const