4 <script src=
"resources/WindowProperties.js"></script>
7 testRunner
.dumpAsText();
9 function log(message
, color
)
11 var paragraph
= document
.createElement("div");
12 paragraph
.appendChild(document
.createTextNode(message
));
13 paragraph
.style
.fontFamily
= "monospace";
15 paragraph
.style
.color
= color
;
16 document
.getElementById("console").appendChild(paragraph
);
19 function shouldBe(a
, b
, printOnlyOnFailure
)
28 if (!printOnlyOnFailure
)
29 log("PASS: " + a
+ " should be " + b
+ " and is.", "green");
31 log("FAIL: " + a
+ " should be " + b
+ " but instead is " + evalA
, "red");
34 function testFunction(functionName
)
36 var element
= document
.createElement('div');
37 element
.id
= functionName
;
38 document
.body
.appendChild(element
);
40 shouldBe("typeof window." + functionName
, "function");
42 document
.body
.removeChild(element
);
47 for (var func
in windowFunctions
) {
48 testFunction(windowFunctions
[func
])
51 window
.myFunction = function() { return "myFunction"; }
52 testFunction("myFunction");
53 window
.__proto__
.myPrototypeFunction = function() { return "myPrototypeFunction"; }
54 testFunction("myPrototypeFunction");
58 <body onload=
"runTests();">
59 <p>This tests that functions of the window object and it's prototype have precedence in lookup over elements with id's of the same name.
</p>
60 <pre id=
"console"></pre>