1 if (window.layoutTestController)
2 layoutTestController.waitUntilDone();
4 var constructors = ["Image", "MessageChannel", "Option", "XMLHttpRequest", "Audio"];
6 window.onload = function () {
7 testFrame = document.getElementById("testFrame");
8 storedConstructors = [];
10 for (var i = 0; i < constructors.length; i++) {
11 var constructor = constructors[i];
13 shouldBe("testFrame.contentWindow." + constructor, "testFrame.contentWindow."+constructor);
14 shouldBeTrue("testFrame.contentWindow." + constructor + " !== window." + constructor);
15 testFrame.contentWindow[constructor].testProperty = "property set successfully";
16 shouldBe("testFrame.contentWindow." + constructor + ".testProperty", '"property set successfully"');
17 storedConstructors[constructor] = testFrame.contentWindow[constructor];
19 testFailed("Testing " + constructor + " threw " + e);
22 testFrame.onload = function() {
23 if (window.GCController)
24 GCController.collect();
26 // Test properties after load
27 for (var i = 0; i < constructors.length; i++) {
28 var constructor = constructors[i];
30 // Repeat the identity checks to be safe
31 shouldBe("testFrame.contentWindow." + constructor, "testFrame.contentWindow."+constructor);
32 shouldBeTrue("testFrame.contentWindow." + constructor + " !== window." + constructor);
34 // Make sure that we haven't reused the constructors from the old document
35 shouldBeTrue("testFrame.contentWindow." + constructor + " !== storedConstructors." + constructor);
36 shouldBe("storedConstructors." + constructor + ".testProperty", '"property set successfully"');
38 // Make sure we haven't kept anything over from the original document
39 shouldBeUndefined("testFrame.contentWindow." + constructor + ".testProperty");
40 // Make sure we're getting the same constructor as the frame does internally
41 shouldBeTrue("testFrame.contentWindow." + constructor + ".cachedOnOwnerDocument");
43 testFailed("Testing " + constructor + " threw " + e);
47 if (window.layoutTestController)
48 layoutTestController.notifyDone();
50 testFrame.src = 'data:text/html,<script>var constructors = ["Image", "MessageChannel", "Option", "XMLHttpRequest", "Audio"];'
51 + 'for(var i = 0; i < constructors.length; i++) if(window[constructors[i]])'
52 + 'window[constructors[i]].cachedOnOwnerDocument = true;</script>';
55 successfullyParsed = true;