blob: 80760ac9e44e2513017b583329e1a9cddeccdb60 [file] [log] [blame]
<!DOCTYPE html>
<meta charset="utf-8">
<title>Same-origin Location objects have non-configurable "toString" and "valueOf" properties</title>
<link rel="help" href="https://html.spec.whatwg.org/multipage/history.html#location-defineownproperty">
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script>
"use strict";
test(() => {
assert_own_property(location, "toString");
const origToString = location.toString;
assert_throws_js(TypeError, () => {
Object.defineProperty(location, "toString", {
get() {},
set(_v) {},
enumerable: true,
configurable: true,
});
});
assert_equals(location.toString, origToString);
}, "'toString' redefinition with accessor fails");
test(() => {
assert_own_property(location, "valueOf");
const origValueOf = location.valueOf;
assert_throws_js(TypeError, () => {
Object.defineProperty(location, "valueOf", {
get() {},
enumerable: false,
configurable: true,
});
});
assert_equals(location.valueOf, origValueOf);
}, "'valueOf' redefinition with accessor fails");
</script>