diff options
author | Leo Kettmeir <crowlkats@toaxl.com> | 2023-01-13 02:06:50 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-13 02:06:50 +0100 |
commit | 919a0cd6796f2a9bbfbfddc9fae53c6afa3dbdda (patch) | |
tree | 8fe929394f7abb1086b79492b922543976fecb34 /runtime/js | |
parent | 5a84ecf0cd90e65b37de2acd5ceded5535576dfe (diff) |
fix: make self and window getters only & make getterOnly ignore setting (#17362)
Diffstat (limited to 'runtime/js')
-rw-r--r-- | runtime/js/06_util.js | 1 | ||||
-rw-r--r-- | runtime/js/98_global_scope.js | 34 |
2 files changed, 8 insertions, 27 deletions
diff --git a/runtime/js/06_util.js b/runtime/js/06_util.js index 5b6944ccc..391497ba8 100644 --- a/runtime/js/06_util.js +++ b/runtime/js/06_util.js @@ -131,6 +131,7 @@ function getterOnly(getter) { return { get: getter, + set() {}, enumerable: true, configurable: true, }; diff --git a/runtime/js/98_global_scope.js b/runtime/js/98_global_scope.js index b4296278c..5a3dfffb0 100644 --- a/runtime/js/98_global_scope.js +++ b/runtime/js/98_global_scope.js @@ -296,31 +296,15 @@ Location: location.locationConstructorDescriptor, location: location.locationDescriptor, Window: globalInterfaces.windowConstructorDescriptor, - window: util.readOnly(globalThis), - self: util.writable(globalThis), + window: util.getterOnly(() => globalThis), + self: util.getterOnly(() => globalThis), Navigator: util.nonEnumerable(Navigator), - navigator: { - configurable: true, - enumerable: true, - get: () => navigator, - }, + navigator: util.getterOnly(() => navigator), alert: util.writable(prompt.alert), confirm: util.writable(prompt.confirm), prompt: util.writable(prompt.prompt), - localStorage: { - configurable: true, - enumerable: true, - get: webStorage.localStorage, - // Makes this reassignable to make astro work - set: () => {}, - }, - sessionStorage: { - configurable: true, - enumerable: true, - get: webStorage.sessionStorage, - // Makes this reassignable to make astro work - set: () => {}, - }, + localStorage: util.getterOnly(webStorage.localStorage), + sessionStorage: util.getterOnly(webStorage.sessionStorage), Storage: util.nonEnumerable(webStorage.Storage), }; @@ -331,12 +315,8 @@ DedicatedWorkerGlobalScope: globalInterfaces.dedicatedWorkerGlobalScopeConstructorDescriptor, WorkerNavigator: util.nonEnumerable(WorkerNavigator), - navigator: { - configurable: true, - enumerable: true, - get: () => workerNavigator, - }, - self: util.readOnly(globalThis), + navigator: util.getterOnly(() => workerNavigator), + self: util.getterOnly(() => globalThis), }; window.__bootstrap.globalScope = { |