blob: 47f4f4183716b31c8ae2fef76059e7578131ab96 [file] [log] [blame]
<html>
<head>
<script src="../../../resources/js-test-pre.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];
// showModalDialog is not currently implemented in DumpRenderTree for all platforms.
if (name == "showModalDialog")
return;
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>
<script src="../../../resources/js-test-post.js"></script>
</body>
</html>