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 | 6 |
6 // All repaint tests are asynchronous. | 7 // All repaint tests are asynchronous. |
7 if (window.testRunner) | 8 if (window.testRunner) |
8 testRunner.waitUntilDone(); | 9 testRunner.waitUntilDone(); |
9 | 10 |
10 if (window.internals) { | 11 if (window.internals) { |
11 internals.settings.setUseDefaultImageInterpolationQuality(true); | 12 internals.settings.setUseDefaultImageInterpolationQuality(true); |
12 internals.runtimeFlags.slimmingPaintUnderInvalidationCheckingEnabled = true; | 13 internals.runtimeFlags.paintUnderInvalidationCheckingEnabled = true; |
13 } | 14 } |
14 | 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 |
15 function runRepaintTest() | 20 function runRepaintTest() |
16 { | 21 { |
17 if (!window.testRunner || !window.internals) { | 22 if (!window.testRunner || !window.internals) { |
18 setTimeout(repaintTest, 500); | 23 setTimeout(repaintTest, 500); |
19 return; | 24 return; |
20 } | 25 } |
21 | 26 |
22 if (window.enablePixelTesting) | 27 if (window.enablePixelTesting) |
23 testRunner.dumpAsTextWithPixelResults(); | 28 testRunner.dumpAsTextWithPixelResults(); |
24 else | 29 else |
(...skipping 14 matching lines...) Expand all Loading... |
39 } | 44 } |
40 | 45 |
41 function forceStyleRecalc() | 46 function forceStyleRecalc() |
42 { | 47 { |
43 if (document.body) | 48 if (document.body) |
44 document.body.clientTop; | 49 document.body.clientTop; |
45 else if (document.documentElement) | 50 else if (document.documentElement) |
46 document.documentElement.clientTop; | 51 document.documentElement.clientTop; |
47 } | 52 } |
48 | 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 |
49 function finishRepaintTest() | 69 function finishRepaintTest() |
50 { | 70 { |
51 if (!window.testRunner || !window.internals) | 71 if (!window.testRunner || !window.internals) |
52 return; | 72 return; |
53 | 73 |
54 // Force a style recalc. | 74 // Force a style recalc. |
55 forceStyleRecalc(); | 75 forceStyleRecalc(); |
56 | 76 |
57 var flags = window.internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS; | 77 var flags = window.internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS; |
58 | 78 |
59 if (window.layerTreeAsTextAdditionalFlags) | 79 if (window.layerTreeAsTextAdditionalFlags) |
60 flags |= window.layerTreeAsTextAdditionalFlags; | 80 flags |= window.layerTreeAsTextAdditionalFlags; |
61 | 81 |
62 var repaintRects = window.internals.layerTreeAsText(document, flags); | 82 if (window.outputLayerList) |
| 83 flags |= window.internals.OUTPUT_CHILDREN_AS_LAYER_LIST; |
| 84 |
| 85 var layersWithInvalidationsText = window.internals.layerTreeAsText(document,
flags); |
| 86 |
| 87 checkObjectPaintInvalidations(layersWithInvalidationsText); |
63 | 88 |
64 internals.stopTrackingRepaints(document); | 89 internals.stopTrackingRepaints(document); |
65 | 90 |
66 // 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. |
67 if (window.isJsTest) | 92 if (window.isJsTest) |
68 window.outputRepaintRects = false; | 93 window.outputRepaintRects = false; |
69 | 94 |
70 if (window.outputRepaintRects) | 95 if (window.outputRepaintRects) |
71 testRunner.setCustomTextOutput(repaintRects); | 96 testRunner.setCustomTextOutput(layersWithInvalidationsText); |
72 | 97 |
73 if (window.afterTest) | 98 if (window.afterTest) |
74 window.afterTest(); | 99 window.afterTest(); |
75 | 100 |
76 // Play nice with async JS tests which want to notifyDone themselves. | 101 // Play nice with async JS tests which want to notifyDone themselves. |
77 if (!window.jsTestIsAsync) | 102 if (!window.jsTestIsAsync) |
78 testRunner.notifyDone(); | 103 testRunner.notifyDone(); |
79 } | 104 } |
OLD | NEW |