Commit 70f5eed3 authored by Becca Hughes's avatar Becca Hughes Committed by Commit Bot

Autoplay: Force enable on desktop for Web Audio

Force enable on desktop for Web Audio.

BUG=841933

Change-Id: I29a5257973c777c84c046576518e970d7cb0d2ba
Reviewed-on: https://chromium-review.googlesource.com/1054433
Commit-Queue: Becca Hughes <beccahughes@chromium.org>
Reviewed-by: default avatarMounir Lamouri <mlamouri@chromium.org>
Reviewed-by: default avatarRaymond Toy <rtoy@chromium.org>
Cr-Commit-Position: refs/heads/master@{#557945}
parent 1d6bd985
...@@ -4685,3 +4685,6 @@ crbug.com/839332 [ Mac ] virtual/video-surface-layer/media/video-no-audio.html [ ...@@ -4685,3 +4685,6 @@ crbug.com/839332 [ Mac ] virtual/video-surface-layer/media/video-no-audio.html [
# Sheriff 2018-05-17 # Sheriff 2018-05-17
crbug.com/840792 [ Mac10.12 Mac10.13 ] external/wpt/pointerevents/pointerevent_touch-action-table-test_touch-manual.html [ Pass Timeout ] crbug.com/840792 [ Mac10.12 Mac10.13 ] external/wpt/pointerevents/pointerevent_touch-action-table-test_touch-manual.html [ Pass Timeout ]
crbug.com/810437 fast/events/hr-timestamp/input-events.html [ Pass Timeout ] crbug.com/810437 fast/events/hr-timestamp/input-events.html [ Pass Timeout ]
# This will break for now
crbug.com/841933 http/tests/webaudio/autoplay-crossorigin.html [ Skip ]
<!DOCTYPE html>
<html>
<body>
<script>
let result = 'failed';
try {
const ac = new AudioContext();
result = ac.state;
} catch (e) {
result = 'creation_failed';
}
top.postMessage(result, '*');
</script>
<!DOCTYPE html>
<html>
<style>
html, body { width: 100%; height: 100%; }
</style>
<body>
<script>
document.body.addEventListener('click', () => {
let result = 'failed';
try {
const ac = new AudioContext();
result = ac.state;
} catch (e) {
result = 'creation_failed';
}
top.postMessage(result, '*');
}, { once: true });
const elementBoundingRect = document.body.getBoundingClientRect();
const xPos = elementBoundingRect.left + elementBoundingRect.width / 2;
const yPos = elementBoundingRect.top + elementBoundingRect.height / 2;
chrome.gpuBenchmarking.pointerActionSequence([
{
source: 'mouse',
actions: [
{ name: 'pointerMove', x: xPos, y: yPos },
{ name: 'pointerDown', x: xPos, y: yPos, button: 'left' },
{ name: 'pointerUp' }
]
}
]);
</script>
<!DOCTYPE html>
<title>Test webaudio autoplay on a cross origin iframe</title>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<iframe style="width: 500px; height: 500px;"></iframe>
<script>
async_test(t => {
// Make sure this overrides any preset autoplay policy.
window.internals.settings.setAutoplayPolicy('document-user-activation-required');
// Setup the event listener.
window.addEventListener('message', t.step_func_done((e) => {
assert_equals(e.data, navigator.userAgent.search('Android') > 0 ? 'suspended' : 'running');
}), { once: true });
// Navigate the iframe to a cross origin site.
document.getElementsByTagName('iframe')[0].src = 'http://localhost:8000/media/autoplay/resources/webaudio-iframe-no-gesture.html';
});
</script>
<!DOCTYPE html>
<title>Test webaudio autoplay on a cross origin iframe</title>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<iframe style="width: 500px; height: 500px;"></iframe>
<script>
async_test(t => {
// Make sure this overrides any preset autoplay policy.
window.internals.settings.setAutoplayPolicy('document-user-activation-required');
// Setup the event listener.
window.addEventListener('message', t.step_func_done((e) => {
assert_equals(e.data, 'running');
}), { once: true });
// Navigate the iframe to a cross origin site.
document.getElementsByTagName('iframe')[0].src = 'http://localhost:8000/media/autoplay/resources/webaudio-iframe-with-gesture.html';
});
</script>
<!DOCTYPE html>
<title>Test that webaudio can be created without a user gesture</title>
<script src='../../resources/testharness.js'></script>
<script src='../../resources/testharnessreport.js'></script>
<script>
test(t => {
// Make sure this overrides any preset autoplay policy.
window.internals.settings.setAutoplayPolicy('document-user-activation-required');
try {
const ac = new AudioContext();
assert_equals('running', ac.state);
} catch (e) {
assert_unreached();
}
});
</script>
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include "third_party/blink/renderer/modules/webaudio/base_audio_context.h" #include "third_party/blink/renderer/modules/webaudio/base_audio_context.h"
#include "build/build_config.h"
#include "third_party/blink/public/platform/platform.h" #include "third_party/blink/public/platform/platform.h"
#include "third_party/blink/public/platform/task_type.h" #include "third_party/blink/public/platform/task_type.h"
#include "third_party/blink/renderer/bindings/core/v8/dictionary.h" #include "third_party/blink/renderer/bindings/core/v8/dictionary.h"
...@@ -677,9 +678,13 @@ Document* BaseAudioContext::GetDocument() const { ...@@ -677,9 +678,13 @@ Document* BaseAudioContext::GetDocument() const {
} }
AutoplayPolicy::Type BaseAudioContext::GetAutoplayPolicy() const { AutoplayPolicy::Type BaseAudioContext::GetAutoplayPolicy() const {
Document* document = GetDocument(); // The policy is different on Android compared to Desktop.
DCHECK(document); #if defined(OS_ANDROID)
return AutoplayPolicy::GetAutoplayPolicyForDocument(*document); return AutoplayPolicy::Type::kUserGestureRequired;
#else
// Force no user gesture required on desktop.
return AutoplayPolicy::Type::kNoUserGestureRequired;
#endif
} }
bool BaseAudioContext::AreAutoplayRequirementsFulfilled() const { bool BaseAudioContext::AreAutoplayRequirementsFulfilled() const {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment