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

Unified Diff: third_party/WebKit/LayoutTests/media/media-play-promise.html

Issue 2199363002: Change play promises behaviour in the load algorithm. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: comments 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/media-play-promise.html
diff --git a/third_party/WebKit/LayoutTests/media/media-play-promise.html b/third_party/WebKit/LayoutTests/media/media-play-promise.html
index 317a4c027fd2630db8696fc2c48fd434c680722f..80ba9ad0f00603ccdeed266c152c74df8668be0a 100644
--- a/third_party/WebKit/LayoutTests/media/media-play-promise.html
+++ b/third_party/WebKit/LayoutTests/media/media-play-promise.html
@@ -220,7 +220,98 @@ var tests = [
audio.oncanplaythrough = t.step_func(function() {
audio.play();
});
- }
+ },
+
+ // Test that running the load algorithm will not drop all the promises about
+ // to be resolved.
+ function loadAlgorithmDoesNotCancelTasks(t, audio) {
+ audio.src = findMediaFile('audio', 'content/test');
+ audio.addEventListener('canplaythrough', t.step_func(function() {
+ // The play() promise will be queued to be resolved.
+ playExpectingResolvedPromise(t, audio);
+ audio.src = findMediaFile('audio', 'content/test');
+ assert_true(audio.paused);
+ }));
+ },
+
+ // Test that when the load algorithm is run, if it does not pause the
+ // playback, it will leave the promise pending, allowing it to be resolved.
+ function loadAlgorithmKeepPromisesPendingWhenNotPausing(t, audio) {
+ playExpectingResolvedPromise(t, audio);
+ setTimeout(t.step_func(function() {
+ audio.src = findMediaFile('audio', 'content/test');
+ assert_false(audio.paused);
+ }), 0);
+ },
+
+ // Test that when the load algorithm is run, if it resolves multiple
+ // promises, they are resolved in the order in which they were added.
+ function loadAlgorithmResolveOrdering(t, audio) {
+ audio.src = findMediaFile('audio', 'content/test');
+ audio.addEventListener('canplaythrough', t.step_func(function() {
+ var firstPromiseResolved = false;
+ audio.play().then(t.step_func(_ => firstPromiseResolved = true),
+ t.unreached_func());
+
+ audio.play().then(t.step_func_done(function() {
+ assert_true(firstPromiseResolved);
+ }), t.unreached_func());
+
+ audio.src = findMediaFile('audio', 'content/test');
+ }));
+ },
+
+ // Test that when the load algorithm is run, if it does not pause the
+ // playback, it will leave the promise pending, allowing it to be resolved
+ // (version with preload='none').
+ // TODO(mlamouri): there is a bug in Blink where the media element ends up
+ // in a broken state, see https://crbug.com/633591
+ // function loadAlgorithmKeepPromisesPendingWhenNotPausingAndPreloadNone(t, audio) {
+ // audio.preload = 'none';
+ // playExpectingRejectedPromise(t, audio, 'AbortError');
+ // setTimeout(_ => audio.src = findMediaFile('audio', 'content/test'), 0);
+ // },
+
+ // Test that when the load algorithm is run, if it does pause the playback,
+ // it will reject the pending promises.
+ function loadAlgorithmRejectPromisesWhenPausing(t, audio) {
+ playExpectingRejectedPromise(t, audio, 'AbortError');
+ audio.src = findMediaFile('audio', 'content/test');
+ assert_true(audio.paused);
+ },
+
+ // Test that when the load algorithm is run, if it does pause the playback,
+ // it will reject the pending promises (version with preload='none').
+ function loadAlgorithmRejectPromisesWhenPausingAndPreloadNone(t, audio) {
+ audio.preload = 'none';
+ playExpectingRejectedPromise(t, audio, 'AbortError');
+ audio.src = findMediaFile('audio', 'content/test');
+ assert_true(audio.paused);
+ },
+
+ // Test that when the load algorithm is run, if it rejects multiple
+ // promises, they are rejected in the order in which they were added.
+ function loadAlgorithmResolveOrdering(t, audio) {
+ var firstPromiseRejected = false;
+ audio.play().then(t.unreached_func(), t.step_func(function(e) {
+ assert_equals(e.name, 'AbortError');
+ assert_equals(e.message,
+ 'The play() request was interrupted by a call to pause().');
+ firstPromiseRejected = true;
+ }));
+
+ audio.play().then(t.unreached_func(), t.step_func_done(function(e) {
+ assert_equals(e.name, 'AbortError');
+ assert_equals(e.message,
+ 'The play() request was interrupted by a call to pause().');
+ assert_true(firstPromiseRejected);
+ }));
+
+ setTimeout(t.step_func(function() {
+ audio.pause();
+ audio.src = findMediaFile('audio', 'content/test');
+ }), 0);
+ },
];
tests.forEach(function(test) {
@@ -278,4 +369,4 @@ function playWithUserGesture(t, audio) {
eventSender.mouseDown();
eventSender.mouseUp();
}
-</script>
+</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