blob: 6905e41f8b249faf1214c66490367ce2ee00af02 [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;
shouldThrowErrorName(function() {
window.__defineGetter__("x", function() { return "window.x __getter__"; });
}, "TypeError");
shouldBe("window.x", "1");
shouldBe("typeof window.__lookupGetter__('x')", "'undefined'");
shouldBe("typeof Object.getOwnPropertyDescriptor(window, 'x').get", "'undefined'");
debug("");
shouldThrowErrorName(function() {
window.__defineSetter__("x", function() { debug("window.x __setter__ called"); });
}, "TypeError");
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>