blob: a8af3fa457143650ba20f810a375af7ea16fe657 [file] [log] [blame]
<script src="../../resources/js-test-pre.js"></script>
<script>
description("This page tests what happens when a getter / setter on the window object conflicts with another property or declared variable");
var x = 1;
try {
window.__defineGetter__("x", function() { return "window.x __getter__"; });
} catch(e) { debug(e); }
shouldBe("window.x", "1");
shouldBe("typeof window.__lookupGetter__('x')", "'undefined'");
shouldBe("typeof Object.getOwnPropertyDescriptor(window, 'x').get", "'undefined'");
debug("");
try {
window.__defineSetter__("x", function() { debug("window.x __setter__ called"); });
} catch(e) { debug(e); }
x = 2;
shouldBe("window.x", "2");
shouldBe("typeof window.__lookupGetter__('x')", "'undefined'");
shouldBe("typeof Object.getOwnPropertyDescriptor(window, 'x').get", "'undefined'");
debug("");
window.y = 1;
try {
window.__defineGetter__("y", function() { return "window.y __getter__"; });
} catch(e) { debug(e); }
shouldBe("window.y", "'window.y __getter__'");
shouldBe("typeof window.__lookupGetter__('y')", "'function'");
shouldBe("typeof Object.getOwnPropertyDescriptor(window, 'y').get", "'function'");
debug("");
try {
window.__defineSetter__("y", function() { "window.y __setter__ called"; });
} catch(e) { debug(e); }
window.y = 2;
shouldBe("window.y", "'window.y __getter__'");
shouldBe("typeof window.__lookupGetter__('y')", "'function'");
shouldBe("typeof Object.getOwnPropertyDescriptor(window, 'y').get", "'function'");
debug("");
try {
window.__defineSetter__("z", function() { "window.z __setter__ called"; });
} catch(e) { debug(e); }
window.z = 1;
shouldBeUndefined("window.z");
shouldBe("typeof window.__lookupSetter__('z')", "'function'");
shouldBe("typeof Object.getOwnPropertyDescriptor(window, 'z').set", "'function'");
</script>