| 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 frame; | 8 var frame; |
| 9 var childWindow; | 9 var childWindow; |
| 10 var propertiesToVerify = []; | 10 var propertiesToVerify = []; |
| 11 | 11 |
| 12 function insertExpectedResult(path, expected) | 12 function insertExpectedResult(path, expected) |
| 13 { | 13 { |
| 14 if (path.length < 2) | 14 if (path.length < 2) |
| 15 return; | 15 return; |
| 16 var propertyDir = path.slice(0, -1).join('.'); | 16 var propertyDir = path.slice(0, -1).join('.'); |
| 17 // Cached Location properties become undefined. | |
| 18 if (propertyDir == "location") | |
| 19 expected = "undefined"; | |
| 20 var cachedPropertyDir = "cached_" + propertyDir.replace('.', '_'); | 17 var cachedPropertyDir = "cached_" + propertyDir.replace('.', '_'); |
| 21 window[cachedPropertyDir] = eval("childWindow." + propertyDir); | 18 window[cachedPropertyDir] = eval("childWindow." + propertyDir); |
| 22 propertiesToVerify.push({ | 19 propertiesToVerify.push({ |
| 23 'property': ["window", cachedPropertyDir, path[path.length - 1]].join(".
"), | 20 'property': ["window", cachedPropertyDir, path[path.length - 1]].join(".
"), |
| 24 'expected': expected, | 21 'expected': expected, |
| 25 }); | 22 }); |
| 26 } | 23 } |
| 27 | 24 |
| 28 function runTest() | 25 function runTest() |
| 29 { | 26 { |
| 30 frame = document.getElementById("test_frame"); | 27 frame = document.getElementById("test_frame"); |
| 31 description("Tests access of cached DOMWindow properties after the associate
d frame is navigated. Test should not crash and properties should be set to sane
defaults."); | 28 description("Tests access of cached DOMWindow properties after the associate
d frame is navigated. Test should not crash and properties should be set to sane
defaults."); |
| 32 childWindow = frame.contentWindow; | 29 childWindow = frame.contentWindow; |
| 33 // Have expected results assume that the frame hasn't been closed (=> window
.closed = false.) | 30 // Have expected results assume that the frame hasn't been closed (=> window
.closed = false.) |
| 34 collectProperties(document.getElementById("src_frame").contentWindow, false)
; | 31 collectProperties(document.getElementById("src_frame").contentWindow, false)
; |
| 35 frame.src = 'about:blank'; | 32 frame.onload = testFrameLoaded; |
| 33 frame.src = 'data:text/plain,'; |
| 36 } | 34 } |
| 37 | 35 |
| 38 function testFrameLoaded() | 36 function testFrameLoaded() |
| 39 { | 37 { |
| 40 if (frame) { | 38 if (frame) { |
| 41 for (var i = 0; i < propertiesToVerify.length; ++i) | 39 for (var i = 0; i < propertiesToVerify.length; ++i) |
| 42 shouldBe(propertiesToVerify[i].property, propertiesToVerify[i].expec
ted); | 40 shouldBe(propertiesToVerify[i].property, propertiesToVerify[i].expec
ted); |
| 43 finishJSTest(); | 41 finishJSTest(); |
| 44 } | 42 } |
| 45 } | 43 } |
| 46 </script> | 44 </script> |
| 47 </head> | 45 </head> |
| 48 <body onload="runTest()"> | 46 <body onload="runTest()"> |
| 49 <iframe id="src_frame"></iframe> | 47 <iframe id="src_frame"></iframe> |
| 50 <iframe id="test_frame" src="resources/blank.html" onload="testFrameLoaded()"></
iframe> | 48 <iframe id="test_frame"></iframe> |
| 51 </body> | 49 </body> |
| 52 </html> | 50 </html> |
| OLD | NEW |