OLD | NEW |
1 // Asynchronous tests should manually call finishPaintInvalidationTest at the ap
propriate time. | 1 // Asynchronous tests should manually call finishPaintInvalidationTest at the ap
propriate time. |
2 window.testIsAsync = false; | 2 window.testIsAsync = false; |
3 | 3 |
4 // All paint invalidation tests are asynchronous from test-runner's point of vie
w. | 4 // All paint invalidation tests are asynchronous from test-runner's point of vie
w. |
5 if (window.testRunner) { | 5 if (window.testRunner) { |
6 testRunner.waitUntilDone(); | 6 testRunner.waitUntilDone(); |
7 if (document.location.hash == '#as-text') | 7 if (document.location.hash == '#as-text') |
8 testRunner.dumpAsText(); | 8 testRunner.dumpAsText(); |
9 } | 9 } |
10 | 10 |
11 function runPaintInvalidationTest() | 11 function runPaintInvalidationTest() |
12 { | 12 { |
13 if (!window.testRunner || !window.internals) { | 13 if (!window.testRunner || !window.internals) { |
14 setTimeout(paintInvalidationTest, 500); | 14 setTimeout(paintInvalidationTest, 500); |
15 return; | 15 return; |
16 } | 16 } |
17 | 17 |
18 // TODO(enne): this is a workaround for multiple svg onload events. | |
19 // See: http://crbug.com/372946 | |
20 if (window.hasRunPaintInvalidationTest) | |
21 return; | |
22 window.hasRunPaintInvalidationTest = true; | |
23 | |
24 testRunner.layoutAndPaintAsyncThen(function() | 18 testRunner.layoutAndPaintAsyncThen(function() |
25 { | 19 { |
26 window.internals.startTrackingPaintInvalidationObjects(); | 20 window.internals.startTrackingPaintInvalidationObjects(); |
27 paintInvalidationTest(); | 21 paintInvalidationTest(); |
28 if (!window.testIsAsync) | 22 if (!window.testIsAsync) |
29 finishPaintInvalidationTest(); | 23 finishPaintInvalidationTest(); |
30 }); | 24 }); |
31 } | 25 } |
32 | 26 |
33 function removeAllChildren(element) | 27 function removeAllChildren(element) |
34 { | 28 { |
35 while (element.firstChild) | 29 while (element.firstChild) |
36 element.removeChild(element.firstChild); | 30 element.removeChild(element.firstChild); |
37 } | 31 } |
38 | 32 |
39 function finishPaintInvalidationTest() | 33 function finishPaintInvalidationTest() |
40 { | 34 { |
41 if (!window.testRunner || !window.internals) | 35 if (!window.testRunner || !window.internals) |
42 return; | 36 return; |
43 | 37 |
44 testRunner.layoutAndPaintAsyncThen(function() | 38 testRunner.layoutAndPaintAsyncThen(function() |
45 { | 39 { |
46 testRunner.setCustomTextOutput(JSON.stringify(internals.trackedPaintInva
lidationObjects()).replace(/","/g, '",\n "')); | 40 testRunner.setCustomTextOutput(JSON.stringify(internals.trackedPaintInva
lidationObjects()).replace(/","/g, '",\n "')); |
47 testRunner.notifyDone(); | 41 testRunner.notifyDone(); |
48 }); | 42 }); |
49 } | 43 } |
OLD | NEW |