OLD | NEW |
1 <html> | 1 <html> |
2 <head> | 2 <head> |
3 <script src="../../../resources/js-test.js"></script> | 3 <script src="../../../resources/js-test.js"></script> |
4 <script src="resources/window-property-collector.js"></script> | 4 <script src="resources/window-property-collector.js"></script> |
5 <script> | 5 <script> |
6 var jsTestIsAsync = true; | 6 var jsTestIsAsync = true; |
7 | 7 |
8 var childWindow; | 8 var childWindow; |
9 var propertiesToVerify = []; | 9 var propertiesToVerify = []; |
10 | 10 |
11 function insertExpectedResult(path, expected) | 11 function insertExpectedResult(path, expected) |
12 { | 12 { |
13 if (path.length < 2) | 13 if (path.length < 2) |
14 return; | 14 return; |
15 var propertyDir = path.slice(0, -1).join('.'); | 15 var propertyDir = path.slice(0, -1).join('.'); |
16 var cachedPropertyDir = "cached_" + propertyDir.replace('.', '_'); | 16 var cachedPropertyDir = "cached_" + propertyDir.replace('.', '_'); |
17 window[cachedPropertyDir] = eval("childWindow." + propertyDir); | 17 window[cachedPropertyDir] = eval("childWindow." + propertyDir); |
18 propertiesToVerify.push({ | 18 propertiesToVerify.push({ |
19 'property': ["window", cachedPropertyDir, path[path.length - 1]].join(".
"), | 19 'property': ["window", cachedPropertyDir, path[path.length - 1]].join(".
"), |
20 'expected': expected, | 20 'expected': expected, |
21 }); | 21 }); |
22 } | 22 } |
23 | 23 |
24 function runTest() | 24 function runTest() |
25 { | 25 { |
26 description("Tests access of cached DOMWindow properties after the associate
d frame is removed from a web page and garbage collected. Test should not crash
and properties should be set to sane defaults."); | 26 description("Tests access of cached DOMWindow properties after the associate
d frame is removed from a web page and garbage collected. Test should not crash
and properties should be set to sane defaults."); |
27 var frame = document.getElementById("frame"); | 27 var frame = document.getElementById("frame"); |
28 childWindow = frame.contentWindow; | 28 childWindow = frame.contentWindow; |
29 collectProperties(); | 29 // Have expected results assume that the frame has been closed (=> window.cl
osed = true.) |
| 30 collectProperties(true); |
30 frame.parentNode.removeChild(frame); | 31 frame.parentNode.removeChild(frame); |
31 window.setTimeout(verifyResults, 0); | 32 window.setTimeout(verifyResults, 0); |
32 } | 33 } |
33 | 34 |
34 function verifyResults() | 35 function verifyResults() |
35 { | 36 { |
36 if (window.gc) | 37 if (window.gc) |
37 gc(); | 38 gc(); |
38 for (var i = 0; i < propertiesToVerify.length; ++i) | 39 for (var i = 0; i < propertiesToVerify.length; ++i) |
39 shouldBe(propertiesToVerify[i].property, propertiesToVerify[i].expected)
; | 40 shouldBe(propertiesToVerify[i].property, propertiesToVerify[i].expected)
; |
40 finishJSTest(); | 41 finishJSTest(); |
41 } | 42 } |
42 </script> | 43 </script> |
43 </head> | 44 </head> |
44 <body> | 45 <body> |
45 <iframe id="frame" src="about:blank" onload="runTest()"></iframe> | 46 <iframe id="frame" src="about:blank" onload="runTest()"></iframe> |
46 </body> | 47 </body> |
47 </html> | 48 </html> |
OLD | NEW |