| OLD | NEW |
| (Empty) |
| 1 // include fast/js/resources/js-test-pre.js before this file. | |
| 2 | |
| 3 function doLeakTest(src, tolerance) { | |
| 4 function getCounterValues() { | |
| 5 testRunner.resetTestHelperControllers(); | |
| 6 gc(); | |
| 7 return {'numberOfLiveDocuments': window.internals.numberOfLiveDocuments(
)}; | |
| 8 } | |
| 9 | |
| 10 var frame = document.createElement('iframe'); | |
| 11 document.body.appendChild(frame); | |
| 12 function loadSourceIntoIframe(src, callback) { | |
| 13 var originalSrc = frame.src; | |
| 14 | |
| 15 frame.onload = function() { | |
| 16 if (frame.src === originalSrc) | |
| 17 return true; | |
| 18 | |
| 19 callback(); | |
| 20 return true; | |
| 21 }; | |
| 22 frame.src = src; | |
| 23 } | |
| 24 | |
| 25 function compareValues(countersBefore, countersAfter, tolerance) { | |
| 26 for (type in tolerance) { | |
| 27 var before = countersBefore[type]; | |
| 28 var after = countersAfter[type]; | |
| 29 | |
| 30 if(after - before <= tolerance[type]) | |
| 31 testPassed('The difference of counter "'+type+'" before and afte
r the cycle is under the threshold of '+tolerance[type]+'.'); | |
| 32 else | |
| 33 testFailed('counter "'+type+'" was '+before+' before and now '+a
fter+' after the cycle. This exceeds the threshold of '+tolerance[type]+'.'); | |
| 34 } | |
| 35 } | |
| 36 | |
| 37 jsTestIsAsync = true; | |
| 38 if (!window.internals) { | |
| 39 debug("This test only runs on DumpRenderTree, as it requires existence o
f window.internals and cross-domain resource access check disabled."); | |
| 40 finishJSTest(); | |
| 41 } | |
| 42 | |
| 43 loadSourceIntoIframe('about:blank', function() { | |
| 44 // blank document loaded... | |
| 45 var countersBefore = getCounterValues(); | |
| 46 | |
| 47 loadSourceIntoIframe(src, function() { | |
| 48 // target document loaded... | |
| 49 | |
| 50 loadSourceIntoIframe('about:blank', function() { | |
| 51 // target document unloaded... | |
| 52 | |
| 53 var countersAfter = getCounterValues(); | |
| 54 compareValues(countersBefore, countersAfter, tolerance); | |
| 55 finishJSTest(); | |
| 56 }); | |
| 57 }); | |
| 58 }); | |
| 59 } | |
| 60 | |
| 61 function htmlToUrl(html) { | |
| 62 return 'data:text/html;charset=utf-8,' + html; | |
| 63 } | |
| 64 | |
| 65 function grabScriptText(id) { | |
| 66 return document.getElementById(id).innerText; | |
| 67 } | |
| 68 | |
| 69 // include fast/js/resources/js-test-post.js after this file. | |
| OLD | NEW |