Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / repaint / resources / text-based-repaint.js
1 // Asynchronous tests should manually call finishRepaintTest at the appropriate time.
2 window.testIsAsync = false;
3 window.outputRepaintRects = true;
4
5 if (window.internals)
6     window.internals.settings.setForceCompositingMode(true)
7
8 function runRepaintTest()
9 {
10     if (!window.testRunner || !window.internals) {
11         setTimeout(repaintTest, 100);
12         return;
13     }
14
15     if (window.enablePixelTesting)
16         testRunner.dumpAsTextWithPixelResults();
17     else
18         testRunner.dumpAsText();
19
20     if (window.testIsAsync)
21         testRunner.waitUntilDone();
22
23     forceStyleRecalc();
24
25     window.internals.startTrackingRepaints(document);
26
27     repaintTest();
28
29     if (!window.testIsAsync)
30         finishRepaintTest();
31 }
32
33 function runRepaintAndPixelTest()
34 {
35     window.enablePixelTesting = true;
36     runRepaintTest();
37 }
38
39 function forceStyleRecalc()
40 {
41     if (document.body)
42         document.body.offsetTop;
43     else if (document.documentElement)
44         document.documentElement.offsetTop;
45 }
46
47 function finishRepaintTest()
48 {
49     // Force a style recalc.
50     forceStyleRecalc();
51
52     var repaintRects = window.internals.layerTreeAsText(document, window.internals.LAYER_TREE_INCLUDES_REPAINT_RECTS);
53
54     internals.stopTrackingRepaints(document);
55
56     if (window.outputRepaintRects)
57         testRunner.setCustomTextOutput(repaintRects);
58
59     if (window.afterTest)
60         window.afterTest();
61
62     if (window.testIsAsync)
63         testRunner.notifyDone();
64 }