Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / dom / Window / window-lookup-precedence.html
blobadd430c0cae1409be0aba0423d17b5682ffead6b
1 <html>
2 <head>
3 <script src="../../../resources/js-test.js"></script>
4 <script type="text/javascript" src="resources/window-properties.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
9 <br>
10 <iframe src="about:blank"></iframe>
12 <br>
13 <form>
14 <input id="MYINPUT" value="Hello World" type="text"/>
15 </form>
17 <div id="console"></div>
19 <script>
20 description('Tests lookup precedence for properties on Window objects in the presence of a child frame, and that IDL properties defined in the prototype (window.location, window.focus, etc) have higher lookup precedence than named document elements (such as input elements).');
22 var win = window.window;
23 var myInput = document.getElementById("MYINPUT");
24 var subframe = win.frames[0];
26 function checkValue(name, original) {
27 // Handle a correct Location, as well as any numerical values (screenX and
28 // so on), separately to avoid depending on the test file or window
29 // location.
30 if ((name.toLowerCase() == "location" || typeof original == "number")
31 && win[name] == original)
32 testPassed("win['" + name + "'] matched original");
33 else
34 shouldEvaluateTo("win['" + name + "']", original);
37 function check(prop) {
38 var name = prop[0];
39 var original = win[name];
40 if (name != "location") { // Avoid navigating the subframe.
41 // Check subframe precedence.
42 try {
43 subframe[name] = name;
44 } catch (e) {
45 debug("Unable to set subframe[" + name + "]: " + e);
48 checkValue(name, original);
50 // Check prototype precedence.
51 myInput.setAttribute("id", name);
52 checkValue(name, original);
55 var originalWindowOnError = window.onerror;
56 window.onerror = null;
58 for (var i = 0; i < propertyInfo.length; ++i) {
59 check(propertyInfo[i]);
62 window.onerror = originalWindowOnError ;
64 </script>
65 </body>
66 </html>