diff options
-rw-r--r-- | runtime/js/99_main.js | 1 | ||||
-rw-r--r-- | tests/specs/run/location/__test__.jsonc | 8 | ||||
-rw-r--r-- | tests/specs/run/location/location.js | 24 | ||||
-rw-r--r-- | tests/specs/run/location/location.out | 5 |
4 files changed, 38 insertions, 0 deletions
diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 8f53cffc4..9134ac48a 100644 --- a/runtime/js/99_main.js +++ b/runtime/js/99_main.js @@ -654,6 +654,7 @@ function bootstrapMainRuntime(runtimeOptions, warmup = false) { if (location_ == null) { mainRuntimeGlobalProperties.location = { writable: true, + configurable: true, }; } else { location.setLocationHref(location_); diff --git a/tests/specs/run/location/__test__.jsonc b/tests/specs/run/location/__test__.jsonc new file mode 100644 index 000000000..551463d59 --- /dev/null +++ b/tests/specs/run/location/__test__.jsonc @@ -0,0 +1,8 @@ +{ + "tests": { + "location_object_define_property": { + "args": "run location.js", + "output": "location.out" + } + } +} diff --git a/tests/specs/run/location/location.js b/tests/specs/run/location/location.js new file mode 100644 index 000000000..8562a3995 --- /dev/null +++ b/tests/specs/run/location/location.js @@ -0,0 +1,24 @@ +let _location = undefined; + +console.log(globalThis.location); + +Object.defineProperty(globalThis, "location", { + get() { + return _location; + }, + set(v) { + _location = v; + }, + configurable: true, +}); + +console.log(globalThis.location); + +globalThis.location = "https://deno.com"; + +console.log(_location); +console.log(location); + +delete globalThis["location"]; + +console.log(globalThis.location); diff --git a/tests/specs/run/location/location.out b/tests/specs/run/location/location.out new file mode 100644 index 000000000..bcb3ff67b --- /dev/null +++ b/tests/specs/run/location/location.out @@ -0,0 +1,5 @@ +undefined +undefined +https://deno.com +https://deno.com +undefined |