Source code
Revision control
Copy as Markdown
Other Tools
Test Info:
- This WPT test may be referenced by the following Test IDs:
- /html/browsers/history/the-location-interface/location-non-configurable-toString-valueOf.html - WPT Dashboard Interop Dashboard
<!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>