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

Unified Diff: third_party/WebKit/LayoutTests/media/autoplay-unmute-offscreen.html

Issue 2250393002: Cancel autoplay muted when visible if the video gets unmuted before being visible. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 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
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/LayoutTests/media/autoplay-unmute-offscreen.html
diff --git a/third_party/WebKit/LayoutTests/media/autoplay-unmute-offscreen.html b/third_party/WebKit/LayoutTests/media/autoplay-unmute-offscreen.html
new file mode 100644
index 0000000000000000000000000000000000000000..5124f311d32cf579606ba8b8ecad3e24bd275195
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/media/autoplay-unmute-offscreen.html
@@ -0,0 +1,66 @@
+<!DOCTYPE html>
+<title>Test that unmuting offscreen video will not allow it to autoplay</title>
+<script src="../resources/testharness.js"></script>
+<script src="../resources/testharnessreport.js"></script>
+<script src="media-file.js"></script>
+<body>
+<script>
+ window.internals.settings.setMediaPlaybackRequiresUserGesture(true);
+ window.internals.runtimeFlags.autoplayMutedVideosEnabled = true;
+
+ async_test(function(t) {
+ // Create a video off screen that will be unmuted before moving on screen.
+ {
+ var video = document.createElement('video');
+ video.id = 'offscreen-unmute';
+ video.src = findMediaFile('video', 'content/test');
+ video.muted = true;
+ video.autoplay = true;
+ video.loop = true;
+ video.style.position = 'absolute';
+ video.style.top = '-10000px';
+ document.body.appendChild(video);
+ }
+
+ // Create a video off screen that will not be unmuted before moving on screen.
+ {
+ var video = document.createElement('video');
+ video.id = 'offscreen-mute';
+ video.src = findMediaFile('video', 'content/test');
+ video.muted = true;
+ video.autoplay = true;
+ video.loop = true;
+ video.style.position = 'absolute';
+ video.style.top = '-10000px';
+ document.body.appendChild(video);
+ }
+
+ var offscreenUnmute = document.querySelector('#offscreen-unmute');
+ var offscreenMute = document.querySelector('#offscreen-mute');
+ var loaded = 0;
+
+ function canPlayTroughHandler() {
+ ++loaded;
+ if (loaded != 2)
+ return;
+
+ assert_greater_than_equal(offscreenUnmute.readyState, HTMLMediaElement.HAVE_ENOUGH_DATA);
+ assert_greater_than_equal(offscreenMute.readyState, HTMLMediaElement.HAVE_ENOUGH_DATA);
+
+ offscreenUnmute.muted = false;
+ offscreenUnmute.style.top = '0px';
+
+ offscreenMute.style.top = '0px';
+ offscreenMute.addEventListener('playing', t.step_func(_ => {
+ setTimeout(t.step_func_done(_ => {
+ assert_true(offscreenUnmute.paused);
+ assert_false(offscreenMute.paused);
+ }), 0);
+ }));
+ }
+
+ offscreenUnmute.addEventListener('canplaythrough', t.step_func(canPlayTroughHandler));
+ offscreenMute.addEventListener('canplaythrough', t.step_func(canPlayTroughHandler));
+ });
+</script>
+</body>
« no previous file with comments | « no previous file | third_party/WebKit/Source/core/html/HTMLMediaElement.cpp » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698