Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Window / window-function-name-getter-precedence.html
blob7075254574b875f54a5aff883a57076efd758082
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="resources/WindowProperties.js"></script>
5 <script>
6 if (window.testRunner)
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";
14 if (color)
15 paragraph.style.color = color;
16 document.getElementById("console").appendChild(paragraph);
19 function shouldBe(a, b, printOnlyOnFailure)
21 var evalA;
22 try {
23 evalA = eval(a);
24 } catch(e) {
25 evalA = e;
27 if (evalA == b) {
28 if (!printOnlyOnFailure)
29 log("PASS: " + a + " should be " + b + " and is.", "green");
30 } else
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);
45 function runTests()
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");
56 </script>
57 </head>
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>
61 </body>
62 </html>