Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Window / window-function-frame-getter-precedence.html
bloba56302b12b8d215f8bdb343b1f4ea6de2a09c3ce
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 iframe = document.createElement('iframe');
37 iframe.src = "about:blank";
38 iframe.name = functionName;
39 document.body.appendChild(iframe);
41 shouldBe("typeof window." + functionName, "function");
43 document.body.removeChild(iframe);
46 function runTests()
48 for (var func in windowFunctions) {
49 testFunction(windowFunctions[func])
52 window.myFunction = function() { return "myFunction"; }
53 testFunction("myFunction");
54 window.__proto__.myPrototypeFunction = function() { return "myPrototypeFunction"; }
55 testFunction("myPrototypeFunction");
57 </script>
58 </head>
59 <body onload="runTests();">
60 <p>This tests that functions of the window object and it's prototype have precedence in lookup over frames with name's of the same name.</p>
61 <pre id="console"></pre>
62 </body>
63 </html>