blob: 795d74b9c016fe36f66f6c874fc2b332531daffb [file] [log] [blame]
<body>
<script>
function print(message, color)
{
var paragraph = document.createElement("div");
paragraph.appendChild(document.createTextNode(message));
paragraph.style.fontFamily = "monospace";
if (color)
paragraph.style.color = color;
document.getElementById("console").appendChild(paragraph);
}
if (window.layoutTestController)
layoutTestController.dumpAsText();
</script>
<iframe id=i src='about:blank' width=10 height=10>
</iframe><br>
<div id=console></div>
<script>
var otherWindow = document.getElementById('i').contentWindow;
var res;
var localVar = 1;
res = otherWindow.eval('localVar == 1');
print("Test that otherWindow.eval() keeps variables of calling context visible: " + (res ? "PASS" : "FAIL")) ;
otherWindow.localVar = 2;
res = otherWindow.eval('localVar == 2');
print("Test that otherWindow.eval() is executed with otherWindow in scope: " + (res ? "PASS" : "FAIL")) ;
res = otherWindow.eval('window == otherWindow');
print("Test that otherWindow.eval() has otherWindow as the window object: " + (res ? "PASS" : "FAIL")) ;
var savedThis = this;
res = otherWindow.eval('this == savedThis');
print("Test that otherWindow.eval() does not change 'this': " + (res ? "PASS" : "FAIL")) ;
otherWindow.eval('var myObject = new Object()');
res = (typeof myObject == "undefined");
print("Test that otherWindow.eval() changes variable context: " + (res ? "PASS" : "FAIL")) ;
</script>