<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description("Test that it is not possible to set the prototype of Window or Location.");

var protoSetter = Object.getOwnPropertyDescriptor(Object.prototype, '__proto__').set;

shouldBe("Object.getPrototypeOf(window)", "Window.prototype");
shouldThrowErrorName("Object.setPrototypeOf(window, Node.prototype)", "TypeError");
shouldBe("Object.getPrototypeOf(window)", "Window.prototype");

shouldBe("Object.getPrototypeOf(window)", "Window.prototype");
shouldThrowErrorName("protoSetter.call(window, Node.prototype)", "TypeError");
shouldBe("Object.getPrototypeOf(window)", "Window.prototype");

shouldBe("Object.getPrototypeOf(window)", "Window.prototype");
shouldThrowErrorName("window.__proto__ = Node.prototype", "TypeError");
shouldBe("Object.getPrototypeOf(window)", "Window.prototype");

shouldBe("Object.getPrototypeOf(window.location)", "Location.prototype");
shouldThrowErrorName("Object.setPrototypeOf(window.location, Node.prototype)", "TypeError");
shouldBe("Object.getPrototypeOf(window.location)", "Location.prototype");

shouldBe("Object.getPrototypeOf(window.location)", "Location.prototype");
shouldThrowErrorName("protoSetter.call(window.location, Node.prototype)", "TypeError");
shouldBe("Object.getPrototypeOf(window.location)", "Location.prototype");

shouldBe("Object.getPrototypeOf(window.location)", "Location.prototype");
shouldThrowErrorName("window.location.__proto__ = Node.prototype", "TypeError");
shouldBe("Object.getPrototypeOf(window.location)", "Location.prototype");

shouldNotThrow("Object.setPrototypeOf(window, window.__proto__)");
shouldNotThrow("Object.setPrototypeOf(window.location, window.location.__proto__)");

</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</script>
