<!DOCTYPE html>
<html>
<body>
<script src="../../resources/js-test-pre.js"></script>
<script>
description("Tests various cases of const variable shadowing on Window.");

let sentinel = "good";
</script>
<script>
debug("Should throw because Window has a non-configurable location own property.");
</script>
<script>
const location = 3;
sentinel = "bad";
</script>
<script>
shouldBeEqualToString("sentinel", "good");
</script>

<script>
debug("");
debug("Should throw because window has an own property foo that is not configurable, even though its value is undefined.");
Object.defineProperty(window, 'foo', {value: undefined, configurable: false, writable: true});
</script>
<script>
const foo = 3;
sentinel = "bad";
</script>
<script>
shouldBeEqualToString("sentinel", "good");
</script>

<script>
debug("");
debug("Should work because Window's own bar property is configurable.");
Object.defineProperty(window, 'bar', {value: 2, configurable: true, writable: true});
sentinel = "bad";
</script>
<script>
const bar = 3;
sentinel = "good";
shouldBe("bar", "3");
</script>
<script>
shouldBeEqualToString("sentinel", "good");
</script>

<script>
debug("");
debug("Should work because dispatchEvent is not an own property, it comes from the prototype chain.");
sentinel = "bad"
</script>
<script>
const dispatchEvent = 3;
sentinel = "good";
shouldBe("dispatchEvent", "3");
</script>
<script>
shouldBeEqualToString("sentinel", "good");
</script>

<script>
successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>
