Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(289)

Side by Side Diff: LayoutTests/fast/dom/resources/leak-check.js

Issue 21274004: Fix Document leak from NodeFilter. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: don't print numberOfLiveDocuments when test passed Created 7 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch | Annotate | Revision Log
OLDNEW
(Empty)
1 // include fast/js/resources/js-test-pre.js before this file.
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)
16 return true;
17
18 callback();
19 return true;
20 };
21 frame.src = src;
22 }
23
24 function compareValues(countersBefore, countersAfter, tolerance) {
25 for (type in tolerance) {
26 var before = countersBefore[type];
27 var after = countersAfter[type];
28
29 if(after - before <= tolerance[type])
30 testPassed('The difference of counter "'+type+'" before and afte r the cycle is under the threshold of '+tolerance[type]+'.');
31 else
32 testFailed('counter "'+type+'" was '+before+' before and now '+a fter+' after the cycle. This exceeds the threshold of '+tolerance[type]+'.');
33 }
34 }
35
36 jsTestIsAsync = true;
37 if (!window.internals) {
38 debug("This test only runs on DumpRenderTree, as it requires existence o f window.internals and cross-domain resource access check disabled.");
39 finishJSTest();
40 }
41
42 loadSourceIntoIframe('about:blank', function() {
43 // blank document loaded...
44 var countersBefore = getCounterValues();
45
46 loadSourceIntoIframe(src, function() {
47 // target document loaded...
48
49 loadSourceIntoIframe('about:blank', function() {
50 // target document unloaded...
51
52 var countersAfter = getCounterValues();
53 compareValues(countersBefore, countersAfter, tolerance);
54 finishJSTest();
55 });
56 });
57 });
58 }
59
60 function htmlToUrl(html) {
61 return 'data:text/html;charset=utf-8,' + html;
62 }
63
64 function grabScriptText(id) {
65 return document.getElementById(id).innerText;
66 }
67
68 // include fast/js/resources/js-test-post.js after this file.
OLDNEW
« no previous file with comments | « LayoutTests/fast/dom/TreeWalker/TreeWalker-leak-document-expected.txt ('k') | Source/bindings/bindings.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698