Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(59)

Unified Diff: third_party/WebKit/LayoutTests/media/autoplay-whitelisted-scope.html

Issue 2640143002: Allow autoplay unmuted for WebAPK in the manifest scope (Closed)
Patch Set: addressed nits Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/media/autoplay-whitelisted-scope.html
diff --git a/third_party/WebKit/LayoutTests/media/autoplay-whitelisted-scope.html b/third_party/WebKit/LayoutTests/media/autoplay-whitelisted-scope.html
new file mode 100644
index 0000000000000000000000000000000000000000..b69759c1683b2260b1ccb0aecd03d19d63ab8018
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/media/autoplay-whitelisted-scope.html
@@ -0,0 +1,72 @@
+<!DOCTYPE html>
+<title>Test for autoplay of whitelisted frames</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="media-file.js"></script>
+<script src="media-controls.js"></script>
+<body>
+<script>
+
+test(function() {
+ assert_true(!!window.internals
+ && !!window.internals.settings,
+ "This test only works when run as a layout test!");
+}, "Prerequisites to running the rest of the tests");
+
+window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
+window.internals.settings.setMediaPlaybackGestureWhitelistScope(
+ document.URL.substring(0, document.URL.lastIndexOf('/') + 1)
+ );
+
+testRunner.setAutoplayAllowed(true);
+
+function createMediaElement(type) {
+ var e = document.createElement(type);
+ e.src = findMediaFile(type, 'content/test');
+ return e;
+}
+
+function createVideoElement() {
+ return createMediaElement('video');
+}
+
+function createAudioElement() {
+ return createMediaElement('audio');
+}
+
+async_test(function(t) {
+ var e = createVideoElement();
+ e.autoplay = true;
+ document.body.appendChild(e);
+
+ var expectedEvents = [ 'canplay', 'play', 'playing'];
+ var eventWatcher = new EventWatcher(t, e, expectedEvents);
+ eventWatcher.wait_for(expectedEvents).then(
+ t.step_func_done(function() {
+ assert_false(e.paused);
+ }));
+}, "Test that a video with an autoplay attribute autoplays when whitelisted.");
+
+promise_test(function() {
+ return createVideoElement().play();
+}, "Test that play() on a video succeeds without gesture when whitelisted.");
+
+async_test(function(t) {
+ var e = createAudioElement();
+ e.autoplay = true;
+ document.body.appendChild(e);
+
+ var expectedEvents = [ 'canplay', 'play', 'playing'];
+ var eventWatcher = new EventWatcher(t, e, expectedEvents);
+ eventWatcher.wait_for(expectedEvents).then(
+ t.step_func_done(function() {
+ assert_false(e.paused);
+ }));
+}, "Test that an audio with an autoplay attribute autoplays when whitelisted.");
+
+promise_test(function() {
+ return createAudioElement().play();
+}, "Test that play() on an audio succeeds without gesture when whitelisted.");
+
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698