Commit 6742ce1a authored by Dale Curtis's avatar Dale Curtis Committed by Commit Bot

Enable web tests for media preload=metadata suspend and lazy loading.

These were accidentally left disabled. Fix some flakiness and use the
new video.rAF API to ensure they are testing the right thing.

R=tguilbert

Fixed: 694855
Change-Id: I1f6b8211209e405e0d81bb6368494031a89453b2
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1954316
Commit-Queue: Dale Curtis <dalecurtis@chromium.org>
Auto-Submit: Dale Curtis <dalecurtis@chromium.org>
Reviewed-by: default avatarThomas Guilbert <tguilbert@chromium.org>
Cr-Commit-Position: refs/heads/master@{#722310}
parent 9386ce0b
...@@ -4584,15 +4584,6 @@ crbug.com/769056 virtual/text-antialias/emoji-web-font.html [ Failure ] ...@@ -4584,15 +4584,6 @@ crbug.com/769056 virtual/text-antialias/emoji-web-font.html [ Failure ]
# Paint-timing tests timeout without threaded-compositing, so skip them. # Paint-timing tests timeout without threaded-compositing, so skip them.
crbug.com/720047 external/wpt/paint-timing [ Skip ] crbug.com/720047 external/wpt/paint-timing [ Skip ]
# This feature is disabled currently, these tests should be enabled once the
# feature has been enabled by default.
crbug.com/694855 media/audio-src-suspend-after-have-metadata.html [ Skip ]
crbug.com/694855 media/video-src-skip-suspend-after-have-metadata.html [ Skip ]
crbug.com/694855 media/video-src-suspend-after-have-metadata.html [ Skip ]
crbug.com/694855 virtual/audio-service/media/audio-src-suspend-after-have-metadata.html [ Skip ]
crbug.com/694855 virtual/audio-service/media/video-src-skip-suspend-after-have-metadata.html [ Skip ]
crbug.com/694855 virtual/audio-service/media/video-src-suspend-after-have-metadata.html [ Skip ]
### See crbug.com/891427 comment near the top of this file: ### See crbug.com/891427 comment near the top of this file:
###crbug.com/849979 media/video-layer-crash.html [ Pass Timeout ] ###crbug.com/849979 media/video-layer-crash.html [ Pass Timeout ]
......
let UPON_VISIBILITY = 'uponVisibility';
// Requests that |video| suspends upon reaching or exceeding |expectedState|; // Requests that |video| suspends upon reaching or exceeding |expectedState|;
// |callback| will be called once the suspend is detected. // |callback| will be called once the suspend is detected.
function suspendMediaElement(video, expectedState, callback) { function suspendMediaElement(video, expectedState, callback) {
...@@ -18,7 +20,8 @@ function suspendMediaElement(video, expectedState, callback) { ...@@ -18,7 +20,8 @@ function suspendMediaElement(video, expectedState, callback) {
function completeTestUponPlayback(t, video) { function completeTestUponPlayback(t, video) {
var timeWatcher = t.step_func(function() { var timeWatcher = t.step_func(function() {
if (video.currentTime > 0) { if (video.currentTime > 0) {
assert_false(internals.isMediaElementSuspended(video)); assert_false(internals.isMediaElementSuspended(video),
'Element should not be suspended.');
t.done(); t.done();
} else { } else {
window.requestAnimationFrame(timeWatcher); window.requestAnimationFrame(timeWatcher);
...@@ -33,17 +36,41 @@ function preloadMetadataSuspendTest(t, video, src, expectSuspend) { ...@@ -33,17 +36,41 @@ function preloadMetadataSuspendTest(t, video, src, expectSuspend) {
assert_true(!!window.internals, 'This test requires windows.internals.'); assert_true(!!window.internals, 'This test requires windows.internals.');
video.onerror = t.unreached_func(); video.onerror = t.unreached_func();
var retried = false;
var eventListener = t.step_func(function() { var eventListener = t.step_func(function() {
assert_equals(expectSuspend, var hasExpectedSuspendState =
internals.isMediaElementSuspended(video)); !!expectSuspend == internals.isMediaElementSuspended(video);
// The delivery of 'loadedmetadata' may occur immediately before the element
// reaches the suspended state; so allow one retry in that case.
if (!hasExpectedSuspendState && !retried) {
retried = true;
setTimeout(eventListener, 0);
return;
}
assert_true(hasExpectedSuspendState,
'Element has incorrect suspend state.');
if (!expectSuspend) { if (!expectSuspend) {
t.done(); t.done();
return; return;
} }
if (expectSuspend == UPON_VISIBILITY)
return;
completeTestUponPlayback(t, video); completeTestUponPlayback(t, video);
}); });
if (expectSuspend == UPON_VISIBILITY) {
video.requestAnimationFrame(t.step_func(function() {
assert_false(
internals.isMediaElementSuspended(video),
'Element should not have been suspended by the first frame.');
t.done();
}));
}
video.addEventListener('loadedmetadata', eventListener, false); video.addEventListener('loadedmetadata', eventListener, false);
video.src = src; video.src = src;
} }
...@@ -55,7 +82,8 @@ function suspendTest(t, video, src, expectedState) { ...@@ -55,7 +82,8 @@ function suspendTest(t, video, src, expectedState) {
// We can't force a suspend state until loading has started. // We can't force a suspend state until loading has started.
video.addEventListener('loadstart', t.step_func(function() { video.addEventListener('loadstart', t.step_func(function() {
suspendMediaElement(video, expectedState, t.step_func(function() { suspendMediaElement(video, expectedState, t.step_func(function() {
assert_true(internals.isMediaElementSuspended(video)); assert_true(internals.isMediaElementSuspended(video),
'Element did not suspend as expected.');
completeTestUponPlayback(t, video); completeTestUponPlayback(t, video);
})); }));
}), false); }), false);
......
...@@ -7,6 +7,6 @@ ...@@ -7,6 +7,6 @@
<script> <script>
async_test(function(t) { async_test(function(t) {
preloadMetadataSuspendTest( preloadMetadataSuspendTest(
t, document.querySelector('video'), 'content/test.webm', false); t, document.querySelector('video'), 'content/test.webm', UPON_VISIBILITY);
}); });
</script> </script>
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