forked from chromium/chromium
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtext-based-repaint.js
More file actions
83 lines (65 loc) · 2.19 KB
/
text-based-repaint.js
File metadata and controls
83 lines (65 loc) · 2.19 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Asynchronous tests should manually call finishRepaintTest at the appropriate
// time.
window.testIsAsync = false;
window.outputRepaintRects = true;
// All repaint tests are asynchronous.
if (window.testRunner)
testRunner.waitUntilDone();
if (window.internals)
internals.runtimeFlags.paintUnderInvalidationCheckingEnabled = true;
// Add string names of objects that should be invalidated here. If you use this feature,
// you must also include testharness.js.
window.expectedObjectInvalidations = [];
// Objects which must *not* be invalidated.
window.expectedObjectNonInvalidations = [];
function runRepaintTest()
{
if (!window.testRunner || !window.internals) {
setTimeout(repaintTest, 500);
return;
}
if (window.enablePixelTesting)
testRunner.dumpAsTextWithPixelResults();
else
testRunner.dumpAsText();
testRunner.layoutAndPaintAsyncThen(function() {
internals.startTrackingRepaints(top.document);
repaintTest();
if (!window.testIsAsync)
finishRepaintTest();
});
}
function runRepaintAndPixelTest()
{
window.enablePixelTesting = true;
runRepaintTest();
}
function forceStyleRecalc()
{
if (document.body)
document.body.clientTop;
else if (document.documentElement)
document.documentElement.clientTop;
}
function finishRepaintTest()
{
if (!window.testRunner || !window.internals)
return;
// Force a style recalc.
forceStyleRecalc();
var flags = internals.LAYER_TREE_INCLUDES_PAINT_INVALIDATIONS;
if (window.layerTreeAsTextAdditionalFlags)
flags |= layerTreeAsTextAdditionalFlags;
var layersWithInvalidationsText = internals.layerTreeAsText(top.document, flags);
internals.stopTrackingRepaints(top.document);
// Play nice with JS tests which may want to print out assert results.
if (window.isJsTest)
window.outputRepaintRects = false;
if (window.outputRepaintRects)
testRunner.setCustomTextOutput(layersWithInvalidationsText);
if (window.afterTest)
window.afterTest();
// Play nice with async JS tests which want to notifyDone themselves.
if (!window.jsTestIsAsync)
testRunner.notifyDone();
}