Upstream version 10.39.225.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / fast / dom / Window / property-access-on-cached-properties-after-frame-removed-and-gced.html
1 <html>
2 <head>
3 <script src="../../../resources/js-test.js"></script>
4 <script src="resources/window-property-collector.js"></script>
5 <script>
6 var jsTestIsAsync = true;
7
8 var childWindow;
9 var propertiesToVerify = [];
10
11 function insertExpectedResult(path, expected)
12 {
13     if (path.length < 2)
14         return;
15     var propertyDir = path.slice(0, -1).join('.');
16     var cachedPropertyDir = "cached_" + propertyDir.replace('.', '_');
17     window[cachedPropertyDir] = eval("childWindow." + propertyDir);
18     propertiesToVerify.push({
19         'property': ["window", cachedPropertyDir, path[path.length - 1]].join("."),
20         'expected': expected,
21     });
22 }
23
24 function runTest()
25 {
26     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.");
27     var frame = document.getElementById("frame");
28     childWindow = frame.contentWindow;
29     // Have expected results assume that the frame has been closed (=> window.closed = true.)
30     collectProperties(true);
31     frame.parentNode.removeChild(frame);
32     asyncGC(function () {
33         for (var i = 0; i < propertiesToVerify.length; ++i)
34             shouldBe(propertiesToVerify[i].property, propertiesToVerify[i].expected);
35         finishJSTest();
36     });
37 }
38 </script>
39 </head>
40 <body>
41 <iframe id="frame" src="about:blank" onload="runTest()"></iframe>
42 </body>
43 </html>