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