blob: b853d323e2eacbf6fcd09a6854daa35e4ebf0ff7 [file] [log] [blame]
<!doctype html>
<title>Verifies there are no spurious repaints for audio in a video tag.</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<video controls></video>
<script>
async_test(function(t) {
if (!window.internals)
return;
var video = document.querySelector('video');
video.addEventListener('canplaythrough', t.step_func(function() {
internals.startTrackingRepaints(document);
video.play();
}), false);
video.addEventListener('ended', t.step_func(function() {
var layerTree = internals.layerTreeAsText(
document, internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS);
var layers = JSON.parse(layerTree)['layers'];
var scrollingContentsLayer = layers[2];
var paintInvalidations = scrollingContentsLayer.paintInvalidations;
internals.stopTrackingRepaints(document);
// Manually verify the number of repaints instead of using a repaint
// test since media playback is asynchronous by nature and its threading
// will cause a variance in the number of repaints on test bots.
var minExpected = 5, maxExpected = 15, actual = 0;
t.add_cleanup(function() {
if (t.status == t.PASS)
return;
console.log('FAIL! An unexpected number of repaints occurred for the thumb;' +
' expected ' + minExpected + ' to ' + maxExpected + '; actual ' + actual +
'. Actual layer tree: ' + layerTree);
});
for (var i = 0; i < paintInvalidations.length; ++i) {
if (paintInvalidations[i].object.includes('thumb'))
actual++;
}
assert_between_inclusive(actual, minExpected, maxExpected);
t.done();
}), false);
video.src = '../../media/content/silence.wav';
});
</script>