summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/js/resources/js-constructors-use-correct-global.js
blob: df8cb085556e35fc2afbef21b0a3f0cbe7f16e82 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
description("Test to ensure that js constructors create objects with the correct constructor");

var otherGlobal = document.getElementsByTagName("iframe")[0].contentWindow;
var constructors = ["Object", "Function", "Array", "Number", "String", "Boolean", "RegExp", "Date", "Error", "RangeError", "ReferenceError", "SyntaxError", "TypeError", "URIError", "Image"];

for (var i = 0; i < constructors.length; i++) {
    shouldBeTrue("new otherGlobal." + constructors[i] + "() instanceof otherGlobal." + constructors[i]);
    try {
        if ((typeof (otherGlobal[constructors[i]]())) === "object" || (typeof (otherGlobal[constructors[i]]())) === "function")
            shouldBeTrue("otherGlobal." + constructors[i] + "() instanceof otherGlobal." + constructors[i]);
    } catch(e) {
    
    }
}

successfullyParsed = true;