| <html> |
| <head> |
| <script src="../../../resources/gc.js"></script> |
| <script src="../../../resources/js-test.js"></script> |
| <script src="resources/window-property-collector.js"></script> |
| <script> |
| var jsTestIsAsync = true; |
| |
| var childWindow; |
| var propertiesToVerify = []; |
| |
| function insertExpectedResult(path, expected) |
| { |
| if (path.length < 2) |
| return; |
| var propertyDir = path.slice(0, -1).join('.'); |
| var cachedPropertyDir = "cached_" + propertyDir.replace('.', '_'); |
| window[cachedPropertyDir] = eval("childWindow." + propertyDir); |
| propertiesToVerify.push({ |
| 'property': ["window", cachedPropertyDir, path[path.length - 1]].join("."), |
| 'expected': expected, |
| }); |
| } |
| |
| function runTest() |
| { |
| description("Tests access of cached DOMWindow properties after the associated frame is removed from a web page and garbage collected. Test should not crash and properties should be set to sane defaults."); |
| var frame = document.getElementById("test_frame"); |
| childWindow = frame.contentWindow; |
| // Have expected results assume that the frame has been closed (=> window.closed = true.) |
| collectProperties(document.getElementById("src_frame").contentWindow, true); |
| frame.parentNode.removeChild(frame); |
| asyncGC(function () { |
| for (var i = 0; i < propertiesToVerify.length; ++i) |
| shouldBe(propertiesToVerify[i].property, propertiesToVerify[i].expected); |
| finishJSTest(); |
| }); |
| } |
| </script> |
| </head> |
| <body onload="runTest()"> |
| <iframe id="src_frame"></iframe> |
| <iframe id="test_frame" src="about:blank"></iframe> |
| </body> |
| </html> |