summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/html/browsers/history/the-location-interface/location-non-configurable-toString-valueOf.html
diff options
context:
space:
mode:
Diffstat (limited to 'testing/web-platform/tests/html/browsers/history/the-location-interface/location-non-configurable-toString-valueOf.html')
-rw-r--r--testing/web-platform/tests/html/browsers/history/the-location-interface/location-non-configurable-toString-valueOf.html42
1 files changed, 42 insertions, 0 deletions
diff --git a/testing/web-platform/tests/html/browsers/history/the-location-interface/location-non-configurable-toString-valueOf.html b/testing/web-platform/tests/html/browsers/history/the-location-interface/location-non-configurable-toString-valueOf.html
new file mode 100644
index 0000000000..80760ac9e4
--- /dev/null
+++ b/testing/web-platform/tests/html/browsers/history/the-location-interface/location-non-configurable-toString-valueOf.html
@@ -0,0 +1,42 @@
+<!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>