OLD | NEW |
---|---|
(Empty) | |
1 // include ../../js/resources/js-test-pre.js before this file. | |
haraken
2013/08/02 03:47:59
../../js/resources/js-test-pre.js => fast/js/resou
kouhei (in TOK)
2013/08/02 04:04:25
Done.
| |
2 | |
3 function doLeakTest(src, tolerance) { | |
4 function getCounterValues() { | |
5 gc(); | |
6 return {'numberOfLiveDocuments': window.internals.numberOfLiveDocuments( )}; | |
7 } | |
8 | |
9 var frame = document.createElement('frame'); | |
10 document.body.appendChild(frame); | |
11 function loadSourceIntoIframe(src, callback) { | |
12 var originalSrc = frame.src; | |
13 | |
14 frame.onload = function() { | |
15 if (frame.src === originalSrc) return true; | |
16 | |
17 callback(); | |
18 }; | |
19 frame.src = src; | |
20 } | |
21 | |
22 function cyclePage(src, continuation) { | |
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('counter "'+type+'" was '+before+' before and now '+a fter+' after the cycle. This is under threshold of '+tolerance[type]+'.'); | |
32 else | |
33 testFailed('counter "'+type+'" was '+before+' before and now '+a fter+' after the cycle. This exceeds threshold of '+tolerance[type]+'.'); | |
34 } | |
35 } | |
36 | |
37 jsTestIsAsync = true; | |
38 if (!window.internals) { | |
39 console.log("This test only runs on DumpRenderTree, as it requires exist ence of window.internals and cross-domain resource access check disabled."); | |
haraken
2013/08/02 03:47:59
Nit: We prefer debug("...") instead of console.log
kouhei (in TOK)
2013/08/02 04:04:25
Done.
| |
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; | |
haraken
2013/08/02 03:47:59
Nit: Spaces are needed around '+'.
kouhei (in TOK)
2013/08/02 04:04:25
Done.
| |
63 } | |
64 | |
65 function grabScriptText(id) { | |
66 document.getElementById(id).innerText; | |
67 } | |
68 | |
69 // include ../../js/resources/js-test-post.js after this file. | |
haraken
2013/08/02 03:47:59
../../js/resources/js-test-post.js => fast/js/reso
kouhei (in TOK)
2013/08/02 04:04:25
Done.
| |
OLD | NEW |