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 // Cached Location properties become undefined. | |
17 if (propertyDir == "location") | |
18 expected = "undefined"; | |
19 var cachedPropertyDir = "cached_" + propertyDir.replace('.', '_'); | 16 var cachedPropertyDir = "cached_" + propertyDir.replace('.', '_'); |
20 window[cachedPropertyDir] = eval("childWindow." + propertyDir); | 17 window[cachedPropertyDir] = eval("childWindow." + propertyDir); |
21 propertiesToVerify.push({ | 18 propertiesToVerify.push({ |
22 'property': ["window", cachedPropertyDir, path[path.length - 1]].join(".
"), | 19 'property': ["window", cachedPropertyDir, path[path.length - 1]].join(".
"), |
23 'expected': expected, | 20 'expected': expected, |
24 }); | 21 }); |
25 } | 22 } |
26 | 23 |
27 function runTest() | 24 function runTest() |
28 { | 25 { |
29 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."); |
30 var frame = document.getElementById("test_frame"); | 27 var frame = document.getElementById("test_frame"); |
31 childWindow = frame.contentWindow; | 28 childWindow = frame.contentWindow; |
32 // Have expected results assume that the frame has been closed (=> window.cl
osed = true.) | 29 // Have expected results assume that the frame has been closed (=> window.cl
osed = true.) |
33 collectProperties(document.getElementById("src_frame").contentWindow, true); | 30 collectProperties(document.getElementById("src_frame").contentWindow, true); |
34 frame.parentNode.removeChild(frame); | 31 frame.parentNode.removeChild(frame); |
35 asyncGC(function () { | 32 asyncGC(function () { |
36 for (var i = 0; i < propertiesToVerify.length; ++i) | 33 for (var i = 0; i < propertiesToVerify.length; ++i) |
37 shouldBe(propertiesToVerify[i].property, propertiesToVerify[i].expec
ted); | 34 shouldBe(propertiesToVerify[i].property, propertiesToVerify[i].expec
ted); |
38 finishJSTest(); | 35 finishJSTest(); |
39 }); | 36 }); |
40 } | 37 } |
41 </script> | 38 </script> |
42 </head> | 39 </head> |
43 <body onload="runTest()"> | 40 <body onload="runTest()"> |
44 <iframe id="src_frame"></iframe> | 41 <iframe id="src_frame"></iframe> |
45 <iframe id="test_frame" src="about:blank"></iframe> | 42 <iframe id="test_frame" src="about:blank"></iframe> |
46 </body> | 43 </body> |
47 </html> | 44 </html> |
OLD | NEW |