| <!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_DETAILED_INVALIDATIONS); |
| var layers = JSON.parse(layerTree)['layers']; |
| var scrollingContentsLayer = layers[0]; |
| var invalidations = scrollingContentsLayer.invalidations; |
| 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 = 20, actual = 0; |
| |
| t.add_cleanup(function() { |
| if (t.status == t.PASS) |
| return; |
| console.log('FAIL! An unexpected number of repaints occurred for the current time display;' + |
| ' expected ' + minExpected + ' to ' + maxExpected + '; actual ' + actual + |
| '. Actual layer tree: ' + layerTree); |
| }); |
| |
| for (var i = 0; i < invalidations.length; ++i) { |
| if (invalidations[i].object.includes('InlineTextBox')) |
| actual++; |
| } |
| assert_between_inclusive(actual, minExpected, maxExpected); |
| |
| t.done(); |
| }), false); |
| |
| video.src = '../../media/content/silence.wav'; |
| }); |
| </script> |