OLD | NEW |
1 <!doctype html> | 1 <!doctype html> |
2 <title>Verifies there are no spurious repaints for audio in a video tag.</title> | 2 <title>Verifies there are no spurious repaints for audio in a video tag.</title> |
3 <script src="../resources/testharness.js"></script> | 3 <script src="../../resources/testharness.js"></script> |
4 <script src="../resources/testharnessreport.js"></script> | 4 <script src="../../resources/testharnessreport.js"></script> |
5 <video></video> | 5 <video></video> |
6 <script> | 6 <script> |
7 async_test(function(t) { | 7 async_test(function(t) { |
8 var video = document.querySelector('video'); | 8 var video = document.querySelector('video'); |
9 | 9 |
10 video.addEventListener('canplaythrough', t.step_func(function() { | 10 video.addEventListener('canplaythrough', t.step_func(function() { |
11 internals.startTrackingRepaints(document); | 11 internals.startTrackingRepaints(document); |
12 video.play(); | 12 video.play(); |
13 }), false); | 13 }), false); |
14 | 14 |
15 video.addEventListener('ended', t.step_func(function() { | 15 video.addEventListener('ended', t.step_func(function() { |
16 var layerTree = internals.layerTreeAsText( | 16 var layerTree = internals.layerTreeAsText( |
17 document, internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS); | 17 document, internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS); |
18 var repaintRects = JSON.parse(layerTree).children[0].repaintRects; | 18 var paintInvalidations = JSON.parse(layerTree).children[0].paintInvalida
tions; |
19 internals.stopTrackingRepaints(document); | 19 internals.stopTrackingRepaints(document); |
20 | 20 |
21 // Manually verify the number of repaints instead of using a repaint | 21 // Manually verify the number of repaints instead of using a repaint |
22 // test since media playback is asynchronous by nature and its threading | 22 // test since media playback is asynchronous by nature and its threading |
23 // will cause a variance in the number of repaints on test bots. | 23 // will cause a variance in the number of repaints on test bots. |
24 var minExpected = 3, maxExpected = 4, expectedRect = [8, 8, 300, 150]; | 24 var minExpected = 3, maxExpected = 4, expectedRect = [8, 8, 300, 150]; |
25 | 25 |
26 t.add_cleanup(function() { | 26 t.add_cleanup(function() { |
27 if (t.status == t.PASS) | 27 if (t.status == t.PASS) |
28 return; | 28 return; |
29 console.log('FAIL! An unexpected number of repaints occurred;' + | 29 console.log('FAIL! An unexpected number of repaints occurred;' + |
30 ' expected ' + minExpected + ' to ' + maxExpected + | 30 ' expected ' + minExpected + ' to ' + maxExpected + |
31 ' with rects of [' + expectedRect.join(', ') + '].' + | 31 ' with rects of [' + expectedRect.join(', ') + '].' + |
32 ' Actual layer tree: ' + layerTree); | 32 ' Actual layer tree: ' + layerTree); |
33 }); | 33 }); |
34 | 34 |
35 assert_between_inclusive(repaintRects.length, minExpected, maxExpected); | 35 assert_between_inclusive(paintInvalidations.length, minExpected, maxExpe
cted); |
36 for (var i = 0; i < repaintRects.length; ++i) | 36 for (var i = 0; i < paintInvalidations.length; ++i) |
37 assert_array_equals(repaintRects[i], expectedRect); | 37 assert_array_equals(paintInvalidations[i].rect, expectedRect); |
38 | 38 |
39 t.done(); | 39 t.done(); |
40 }), false); | 40 }), false); |
41 | 41 |
42 video.src = 'content/silence.wav'; | 42 video.src = '../../media/content/silence.wav'; |
43 }); | 43 }); |
44 </script> | 44 </script> |
OLD | NEW |