chromium/third_party/blink/web_tests/fast/dom/Window/window-lookup-precedence.html

<html>
<head>
<script src="../../../resources/js-test.js"></script>
<script type="text/javascript" src="resources/window-properties.js"></script>
</head>
<body>
<p id="description"></p>

<br>
<iframe src="about:blank"></iframe>

<br>
<form>
<input id="MYINPUT" value="Hello World" type="text"/>
</form>

<div id="console"></div>

<script>
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).');

var win = window.window;
var myInput = document.getElementById("MYINPUT");
var subframe = win.frames[0];

function checkValue(name, original) {
    // Handle a correct Location, as well as any numerical values (screenX and
    // so on), separately to avoid depending on the test file or window
    // location.
    if ((name.toLowerCase() == "location" || typeof original == "number")
        && win[name] == original)
        testPassed("win['" + name + "'] matched original");
    else
        shouldEvaluateTo("win['" + name + "']", original);
}

function check(prop) {
    var name = prop[0];
    var original = win[name];
    if (name != "location") { // Avoid navigating the subframe.
      // Check subframe precedence.
      try {
        subframe[name] = name;
      } catch (e) {
        debug("Unable to set subframe[" + name + "]: " + e);
      }
    }
    checkValue(name, original);

    // Check prototype precedence.
    myInput.setAttribute("id", name);
    checkValue(name, original);
}

var originalWindowOnError = window.onerror;
window.onerror = null;

for (var i = 0; i < propertyInfo.length; ++i) {
    check(propertyInfo[i]);
}

window.onerror = originalWindowOnError ;

</script>
</body>
</html>