diff --git a/runtime/js/99_main.js b/runtime/js/99_main.js index 8f53cffc42df92..9134ac48a15d95 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 00000000000000..551463d594d8dd --- /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 00000000000000..8562a39957d084 --- /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 00000000000000..bcb3ff67b91dbf --- /dev/null +++ b/tests/specs/run/location/location.out @@ -0,0 +1,5 @@ +undefined +undefined +https://deno.com +https://deno.com +undefined