OLD | NEW |
1 // Asynchronous tests should manually call finishRepaintTest at the appropriate | 1 // Asynchronous tests should manually call finishRepaintTest at the appropriate |
2 // time. | 2 // time. |
3 window.testIsAsync = false; | 3 window.testIsAsync = false; |
4 window.outputRepaintRects = true; | 4 window.outputRepaintRects = true; |
5 window.outputLayerList = false; | 5 window.outputLayerList = false; |
6 | 6 |
7 // All repaint tests are asynchronous. | 7 // All repaint tests are asynchronous. |
8 if (window.testRunner) | 8 if (window.testRunner) |
9 testRunner.waitUntilDone(); | 9 testRunner.waitUntilDone(); |
10 | 10 |
11 if (window.internals) { | 11 if (window.internals) { |
12 internals.settings.setUseDefaultImageInterpolationQuality(true); | 12 internals.settings.setUseDefaultImageInterpolationQuality(true); |
13 internals.runtimeFlags.paintUnderInvalidationCheckingEnabled = true; | 13 internals.runtimeFlags.paintUnderInvalidationCheckingEnabled = true; |
14 } | 14 } |
15 | 15 |
| 16 // Add string names of objects that should be invalidated here. If you use this
feature, |
| 17 // you must also include testharness.js. |
| 18 window.expectedObjectInvalidations = []; |
| 19 |
16 function runRepaintTest() | 20 function runRepaintTest() |
17 { | 21 { |
18 if (!window.testRunner || !window.internals) { | 22 if (!window.testRunner || !window.internals) { |
19 setTimeout(repaintTest, 500); | 23 setTimeout(repaintTest, 500); |
20 return; | 24 return; |
21 } | 25 } |
22 | 26 |
23 if (window.enablePixelTesting) | 27 if (window.enablePixelTesting) |
24 testRunner.dumpAsTextWithPixelResults(); | 28 testRunner.dumpAsTextWithPixelResults(); |
25 else | 29 else |
(...skipping 14 matching lines...) Expand all Loading... |
40 } | 44 } |
41 | 45 |
42 function forceStyleRecalc() | 46 function forceStyleRecalc() |
43 { | 47 { |
44 if (document.body) | 48 if (document.body) |
45 document.body.clientTop; | 49 document.body.clientTop; |
46 else if (document.documentElement) | 50 else if (document.documentElement) |
47 document.documentElement.clientTop; | 51 document.documentElement.clientTop; |
48 } | 52 } |
49 | 53 |
| 54 function checkObjectPaintInvalidations(layersWithInvalidationsText) |
| 55 { |
| 56 var layersWithInvalidations = JSON.parse(layersWithInvalidationsText); |
| 57 var objectNameSet = new Set(); |
| 58 if (layersWithInvalidations["objectPaintInvalidations"]) { |
| 59 layersWithInvalidations["objectPaintInvalidations"].forEach(function(obj
) { |
| 60 objectNameSet.add(obj["object"]); |
| 61 }); |
| 62 } |
| 63 |
| 64 window.expectedObjectInvalidations.forEach(function(objectName) { |
| 65 assert_true(objectNameSet.has(objectName), "Expected object to be invali
dated, but it was not: '" + objectName + "'"); |
| 66 }); |
| 67 } |
| 68 |
50 function finishRepaintTest() | 69 function finishRepaintTest() |
51 { | 70 { |
52 if (!window.testRunner || !window.internals) | 71 if (!window.testRunner || !window.internals) |
53 return; | 72 return; |
54 | 73 |
55 // Force a style recalc. | 74 // Force a style recalc. |
56 forceStyleRecalc(); | 75 forceStyleRecalc(); |
57 | 76 |
58 var flags = window.internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS; | 77 var flags = window.internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS; |
59 | 78 |
60 if (window.layerTreeAsTextAdditionalFlags) | 79 if (window.layerTreeAsTextAdditionalFlags) |
61 flags |= window.layerTreeAsTextAdditionalFlags; | 80 flags |= window.layerTreeAsTextAdditionalFlags; |
62 | 81 |
63 if (window.outputLayerList) | 82 if (window.outputLayerList) |
64 flags |= window.internals.OUTPUT_CHILDREN_AS_LAYER_LIST; | 83 flags |= window.internals.OUTPUT_CHILDREN_AS_LAYER_LIST; |
65 | 84 |
66 var repaintRects = window.internals.layerTreeAsText(document, flags); | 85 var layersWithInvalidationsText = window.internals.layerTreeAsText(document,
flags); |
| 86 |
| 87 checkObjectPaintInvalidations(layersWithInvalidationsText); |
67 | 88 |
68 internals.stopTrackingRepaints(document); | 89 internals.stopTrackingRepaints(document); |
69 | 90 |
70 // Play nice with JS tests which may want to print out assert results. | 91 // Play nice with JS tests which may want to print out assert results. |
71 if (window.isJsTest) | 92 if (window.isJsTest) |
72 window.outputRepaintRects = false; | 93 window.outputRepaintRects = false; |
73 | 94 |
74 if (window.outputRepaintRects) | 95 if (window.outputRepaintRects) |
75 testRunner.setCustomTextOutput(repaintRects); | 96 testRunner.setCustomTextOutput(layersWithInvalidationsText); |
76 | 97 |
77 if (window.afterTest) | 98 if (window.afterTest) |
78 window.afterTest(); | 99 window.afterTest(); |
79 | 100 |
80 // Play nice with async JS tests which want to notifyDone themselves. | 101 // Play nice with async JS tests which want to notifyDone themselves. |
81 if (!window.jsTestIsAsync) | 102 if (!window.jsTestIsAsync) |
82 testRunner.notifyDone(); | 103 testRunner.notifyDone(); |
83 } | 104 } |
OLD | NEW |