OLD | NEW |
1 // Run a callback after layout and paint of all pending document changes. | 1 // Run a callback after layout and paint of all pending document changes. |
2 // | 2 // |
3 // It has two modes: | 3 // It has two modes: |
4 // - traditional mode, for existing tests, and tests needing customized notifyDo
ne timing: | 4 // - traditional mode, for existing tests, and tests needing customized notifyDo
ne timing: |
5 // Usage: | 5 // Usage: |
6 // if (window.testRunner) | 6 // if (window.testRunner) |
7 // testRunner.waitUntilDone(); | 7 // testRunner.waitUntilDone(); |
8 // runAfterLayoutAndPaint(function() { | 8 // runAfterLayoutAndPaint(function() { |
9 // ... // some code which modifies style/layout | 9 // ... // some code which modifies style/layout |
10 // if (window.testRunner) | 10 // if (window.testRunner) |
11 // testRunner.notifyDone(); | 11 // testRunner.notifyDone(); |
12 // // Or to ensure the next paint is executed before the test finishes: | 12 // // Or to ensure the next paint is executed before the test finishes: |
13 // // if (window.testRunner) | 13 // // if (window.testRunner) |
14 // // runAfterAfterLayoutAndPaint(function() { testRunner.notifyDone() }
); | 14 // // runAfterAfterLayoutAndPaint(function() { testRunner.notifyDone() }
); |
15 // // Or notifyDone any time later if needed. | 15 // // Or notifyDone any time later if needed. |
16 // }); | 16 // }); |
17 // | 17 // |
18 // - autoNotifyDone mode, for new tests which just need to change style/layout a
nd finish: | 18 // - autoNotifyDone mode, for new tests which just need to change style/layout a
nd finish: |
19 // Usage: | 19 // Usage: |
20 // runAfterLayoutAndPaint(function() { | 20 // runAfterLayoutAndPaint(function() { |
21 // ... // some code which modifies style/layout | 21 // ... // some code which modifies style/layout |
22 // }, true); | 22 // }, true); |
23 | 23 |
24 if (window.internals) | 24 if (window.internals) |
25 internals.runtimeFlags.slimmingPaintUnderInvalidationCheckingEnabled = true; | 25 internals.runtimeFlags.paintUnderInvalidationCheckingEnabled = true; |
26 | 26 |
27 function runAfterLayoutAndPaint(callback, autoNotifyDone) { | 27 function runAfterLayoutAndPaint(callback, autoNotifyDone) { |
28 if (!window.testRunner) { | 28 if (!window.testRunner) { |
29 // For manual test. Delay 500ms to allow us to see the visual change | 29 // For manual test. Delay 500ms to allow us to see the visual change |
30 // caused by the callback. | 30 // caused by the callback. |
31 setTimeout(callback, 500); | 31 setTimeout(callback, 500); |
32 return; | 32 return; |
33 } | 33 } |
34 | 34 |
35 if (autoNotifyDone) | 35 if (autoNotifyDone) |
36 testRunner.waitUntilDone(); | 36 testRunner.waitUntilDone(); |
37 | 37 |
38 testRunner.layoutAndPaintAsyncThen(function() { | 38 testRunner.layoutAndPaintAsyncThen(function() { |
39 callback(); | 39 callback(); |
40 if (autoNotifyDone) | 40 if (autoNotifyDone) |
41 testRunner.notifyDone(); | 41 testRunner.notifyDone(); |
42 }); | 42 }); |
43 } | 43 } |
OLD | NEW |