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

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

Issue 58533003: Move fast/js/resources files to resources. (Closed) Base URL: svn://svn.chromium.org/blink/trunk
Patch Set: Created 7 years, 1 month 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 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 // Measure counter values on next timer event. This is needed
54 // to correctly handle deref cycles for some ActiveDOMObjects
55 // such as XMLHttpRequest.
56 setTimeout(function() {
57 var countersAfter = getCounterValues();
58 compareValues(countersBefore, countersAfter, tolerance);
59 finishJSTest();
60 }, 0);
61 });
62 });
63 });
64 }
65
66 function htmlToUrl(html) {
67 return 'data:text/html;charset=utf-8,' + html;
68 }
69
70 function grabScriptText(id) {
71 return document.getElementById(id).innerText;
72 }
73
74 // include fast/js/resources/js-test-post.js after this file.
OLDNEW
« no previous file with comments | « LayoutTests/fast/js/resources/js-test-pre.js ('k') | LayoutTests/fast/js/script-tests/TEMPLATE.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698