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 window.expectedObjectInvalidations = []; | |
fs
2016/10/06 10:51:49
Maybe document that using this part of the framewo
chrishtr
2016/10/06 16:52:04
Done.
| |
17 | |
16 function runRepaintTest() | 18 function runRepaintTest() |
17 { | 19 { |
18 if (!window.testRunner || !window.internals) { | 20 if (!window.testRunner || !window.internals) { |
19 setTimeout(repaintTest, 500); | 21 setTimeout(repaintTest, 500); |
20 return; | 22 return; |
21 } | 23 } |
22 | 24 |
23 if (window.enablePixelTesting) | 25 if (window.enablePixelTesting) |
24 testRunner.dumpAsTextWithPixelResults(); | 26 testRunner.dumpAsTextWithPixelResults(); |
25 else | 27 else |
(...skipping 14 matching lines...) Expand all Loading... | |
40 } | 42 } |
41 | 43 |
42 function forceStyleRecalc() | 44 function forceStyleRecalc() |
43 { | 45 { |
44 if (document.body) | 46 if (document.body) |
45 document.body.clientTop; | 47 document.body.clientTop; |
46 else if (document.documentElement) | 48 else if (document.documentElement) |
47 document.documentElement.clientTop; | 49 document.documentElement.clientTop; |
48 } | 50 } |
49 | 51 |
52 function checkObjectPaintInvalidations(layersWithInvalidationsText) | |
53 { | |
54 var layersWithInvalidations = JSON.parse(layersWithInvalidationsText); | |
55 var objectNameSet = new Set(); | |
56 layersWithInvalidations["objectPaintInvalidations"].forEach(function(obj) { | |
57 objectNameSet.add(obj["object"]); | |
58 }); | |
59 | |
60 window.expectedObjectInvalidations.forEach(function(objectName) { | |
61 assert_true(objectNameSet.has(objectName), "Expected object to be invali dated, but was not: '" + objectName + "'"); | |
fs
2016/10/06 10:51:49
Nit: ...but it was not
?
chrishtr
2016/10/06 16:52:04
Done.
| |
62 }); | |
63 } | |
64 | |
50 function finishRepaintTest() | 65 function finishRepaintTest() |
51 { | 66 { |
52 if (!window.testRunner || !window.internals) | 67 if (!window.testRunner || !window.internals) |
53 return; | 68 return; |
54 | 69 |
55 // Force a style recalc. | 70 // Force a style recalc. |
56 forceStyleRecalc(); | 71 forceStyleRecalc(); |
57 | 72 |
58 var flags = window.internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS; | 73 var flags = window.internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS; |
59 | 74 |
60 if (window.layerTreeAsTextAdditionalFlags) | 75 if (window.layerTreeAsTextAdditionalFlags) |
61 flags |= window.layerTreeAsTextAdditionalFlags; | 76 flags |= window.layerTreeAsTextAdditionalFlags; |
62 | 77 |
63 if (window.outputLayerList) | 78 if (window.outputLayerList) |
64 flags |= window.internals.OUTPUT_CHILDREN_AS_LAYER_LIST; | 79 flags |= window.internals.OUTPUT_CHILDREN_AS_LAYER_LIST; |
65 | 80 |
66 var repaintRects = window.internals.layerTreeAsText(document, flags); | 81 var layersWithInvalidationsText = window.internals.layerTreeAsText(document, flags); |
82 | |
83 checkObjectPaintInvalidations(layersWithInvalidationsText); | |
67 | 84 |
68 internals.stopTrackingRepaints(document); | 85 internals.stopTrackingRepaints(document); |
69 | 86 |
70 // Play nice with JS tests which may want to print out assert results. | 87 // Play nice with JS tests which may want to print out assert results. |
71 if (window.isJsTest) | 88 if (window.isJsTest) |
72 window.outputRepaintRects = false; | 89 window.outputRepaintRects = false; |
73 | 90 |
74 if (window.outputRepaintRects) | 91 if (window.outputRepaintRects) |
75 testRunner.setCustomTextOutput(repaintRects); | 92 testRunner.setCustomTextOutput(layersWithInvalidationsText); |
76 | 93 |
77 if (window.afterTest) | 94 if (window.afterTest) |
78 window.afterTest(); | 95 window.afterTest(); |
79 | 96 |
80 // Play nice with async JS tests which want to notifyDone themselves. | 97 // Play nice with async JS tests which want to notifyDone themselves. |
81 if (!window.jsTestIsAsync) | 98 if (!window.jsTestIsAsync) |
82 testRunner.notifyDone(); | 99 testRunner.notifyDone(); |
83 } | 100 } |
OLD | NEW |