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

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

Issue 2047333002: Pause autoplay muted video when unmuting if there's no user gesture (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@autoplay-flag
Patch Set: Addressed comments Created 4 years, 6 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-muted.html
diff --git a/third_party/WebKit/LayoutTests/media/autoplay-muted.html b/third_party/WebKit/LayoutTests/media/autoplay-muted.html
index 3ac13cbffad04950725f67645c0bd43cd19010e6..bd83ef15f90ecaae5e2f62d522701319693ebc67 100644
--- a/third_party/WebKit/LayoutTests/media/autoplay-muted.html
+++ b/third_party/WebKit/LayoutTests/media/autoplay-muted.html
@@ -3,34 +3,61 @@
<script src="../resources/testharness.js"></script>
<script src="../resources/testharnessreport.js"></script>
<script src="media-file.js"></script>
+<script src="media-controls.js"></script>
<script>
+ test(function() {
+ assert_true(!!window.internals
+ && !!window.internals.settings
+ && !!window.internals.runtimeFlags
+ && !!window.eventSender,
+ "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.runtimeFlags.autoplayMutedVideosEnabled = true;
function createMutedVideoElement() {
- var e = document.createElement('video');
- e.src = findMediaFile('video', 'content/test');
- e.muted = true;
- return e;
+ var e = document.createElement('video');
+ e.src = findMediaFile('video', 'content/test');
+ e.muted = true;
+ return e;
}
- async_test(function(t)
- {
+ async_test(function(t) {
var e = createMutedVideoElement();
e.autoplay = true;
- var expectedEvents = [
- 'canplay', 'play', 'playing'];
+ 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);
- }));
- }, "muted-autoplay");
-
- promise_test(function()
- {
+ eventWatcher.wait_for(expectedEvents).then(
+ t.step_func_done(function() {
+ assert_false(e.paused);
+ }));
+ }, "Test that a muted video with an autoplay attribute autoplays.");
+
+ promise_test(function() {
return createMutedVideoElement().play();
- }, "muted-playjs");
+ }, "Test that play() on a muted video succeeds without gesture.");
+
+ promise_test(function(t) {
+ var e = createMutedVideoElement();
+ return e.play().then(t.step_func_done(function() {
+ e.muted = false;
+ assert_true(e.paused, "The video should be paused.");
+ }));
+ }, "Test that unmuting an autoplayed video without gesture pauses.");
+
+ async_test(function(t) {
+ var e = createMutedVideoElement();
+
+ e.play().then(t.step_func(function() {
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }));
+
+ document.onclick = t.step_func_done(function() {
+ e.muted = false;
+ assert_false(e.paused, "The video should not be paused.");
+ });
+ }, "Test that unmuting autoplayed video with gesture doesn't pause it.");
</script>
« 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