OLD | NEW |
1 // include resources/js-test.js before this file. | 1 // include resources/js-test.js before this file. |
2 | 2 |
3 function getCounterValues() { | 3 function getCounterValues(callback) { |
4 testRunner.resetTestHelperControllers(); | 4 testRunner.resetTestHelperControllers(); |
5 gc(); | 5 asyncGC(function() { |
| 6 var ret = {'numberOfLiveDocuments': window.internals.numberOfLiveDocumen
ts()}; |
6 | 7 |
7 var ret = {'numberOfLiveDocuments': window.internals.numberOfLiveDocuments()
}; | 8 var refCountedInstances = JSON.parse(window.internals.dumpRefCountedInst
anceCounts()); |
| 9 for (typename in refCountedInstances) |
| 10 ret['numberOfInstances-'+typename] = refCountedInstances[typename]; |
8 | 11 |
9 var refCountedInstances = JSON.parse(window.internals.dumpRefCountedInstance
Counts()); | 12 callback(ret); |
10 for (typename in refCountedInstances) | 13 }); |
11 ret['numberOfInstances-'+typename] = refCountedInstances[typename]; | |
12 | 14 |
13 return ret; | |
14 } | 15 } |
15 | 16 |
16 function compareValues(countersBefore, countersAfter, tolerance) { | 17 function compareValues(countersBefore, countersAfter, tolerance) { |
17 for (type in tolerance) { | 18 for (type in tolerance) { |
18 var before = countersBefore[type]; | 19 var before = countersBefore[type]; |
19 var after = countersAfter[type]; | 20 var after = countersAfter[type]; |
20 | 21 |
21 if (after - before <= tolerance[type]) | 22 if (after - before <= tolerance[type]) |
22 testPassed('The difference of counter "'+type+'" before and after th
e cycle is under the threshold of '+tolerance[type]+'.'); | 23 testPassed('The difference of counter "'+type+'" before and after th
e cycle is under the threshold of '+tolerance[type]+'.'); |
23 else | 24 else |
(...skipping 18 matching lines...) Expand all Loading... |
42 } | 43 } |
43 | 44 |
44 jsTestIsAsync = true; | 45 jsTestIsAsync = true; |
45 if (!window.internals) { | 46 if (!window.internals) { |
46 debug("This test only runs on DumpRenderTree, as it requires existence o
f window.internals and cross-domain resource access check disabled."); | 47 debug("This test only runs on DumpRenderTree, as it requires existence o
f window.internals and cross-domain resource access check disabled."); |
47 finishJSTest(); | 48 finishJSTest(); |
48 } | 49 } |
49 | 50 |
50 loadSourceIntoIframe('about:blank', function() { | 51 loadSourceIntoIframe('about:blank', function() { |
51 // blank document loaded... | 52 // blank document loaded... |
52 var countersBefore = getCounterValues(); | 53 getCounterValues(function(countersBefore) { |
| 54 loadSourceIntoIframe(src, function() { |
| 55 // target document loaded... |
53 | 56 |
54 loadSourceIntoIframe(src, function() { | 57 loadSourceIntoIframe('about:blank', function() { |
55 // target document loaded... | 58 // target document unloaded... |
56 | 59 |
57 loadSourceIntoIframe('about:blank', function() { | 60 // Measure counter values on next timer event. This is neede
d |
58 // target document unloaded... | 61 // to correctly handle deref cycles for some ActiveDOMObject
s |
59 | 62 // such as XMLHttpRequest. |
60 // Measure counter values on next timer event. This is needed | 63 setTimeout(function() { |
61 // to correctly handle deref cycles for some ActiveDOMObjects | 64 getCounterValues(function(countersAfter) { |
62 // such as XMLHttpRequest. | 65 compareValues(countersBefore, countersAfter, toleran
ce); |
63 setTimeout(function() { | 66 finishJSTest(); |
64 var countersAfter = getCounterValues(); | 67 }); |
65 compareValues(countersBefore, countersAfter, tolerance); | 68 }, 0); |
66 finishJSTest(); | 69 }); |
67 }, 0); | |
68 }); | 70 }); |
69 }); | 71 }); |
70 }); | 72 }); |
71 } | 73 } |
72 | 74 |
73 function htmlToUrl(html) { | 75 function htmlToUrl(html) { |
74 return 'data:text/html;charset=utf-8,' + html; | 76 return 'data:text/html;charset=utf-8,' + html; |
75 } | 77 } |
76 | 78 |
77 function grabScriptText(id) { | 79 function grabScriptText(id) { |
78 return document.getElementById(id).innerText; | 80 return document.getElementById(id).innerText; |
79 } | 81 } |
80 | 82 |
81 // include fast/js/resources/js-test-post.js after this file. | 83 // include fast/js/resources/js-test-post.js after this file. |
OLD | NEW |