| 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 // TODO(wangxianzhu): Some spv2 tests crash with under-invalidation-checking | 25 internals.runtimeFlags.slimmingPaintUnderInvalidationCheckingEnabled = true; |
| 26 // because the extra display items between Subsequence/EndSubsequence for | |
| 27 // under-invalidation checking breaks paint chunks. Should fix this when fix
ing | |
| 28 // crbug.com/596983. | |
| 29 if (!internals.runtimeFlags.slimmingPaintV2Enabled) | |
| 30 internals.runtimeFlags.slimmingPaintUnderInvalidationCheckingEnabled = t
rue; | |
| 31 } | |
| 32 | 26 |
| 33 function runAfterLayoutAndPaint(callback, autoNotifyDone) { | 27 function runAfterLayoutAndPaint(callback, autoNotifyDone) { |
| 34 if (!window.testRunner) { | 28 if (!window.testRunner) { |
| 35 // 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 |
| 36 // caused by the callback. | 30 // caused by the callback. |
| 37 setTimeout(callback, 500); | 31 setTimeout(callback, 500); |
| 38 return; | 32 return; |
| 39 } | 33 } |
| 40 | 34 |
| 41 if (autoNotifyDone) | 35 if (autoNotifyDone) |
| 42 testRunner.waitUntilDone(); | 36 testRunner.waitUntilDone(); |
| 43 | 37 |
| 44 testRunner.layoutAndPaintAsyncThen(function() { | 38 testRunner.layoutAndPaintAsyncThen(function() { |
| 45 callback(); | 39 callback(); |
| 46 if (autoNotifyDone) | 40 if (autoNotifyDone) |
| 47 testRunner.notifyDone(); | 41 testRunner.notifyDone(); |
| 48 }); | 42 }); |
| 49 } | 43 } |
| OLD | NEW |