Skip to content

Commit

Permalink
fix: make self and window getters only & make getterOnly ignore setti…
Browse files Browse the repository at this point in the history
…ng (#17362)
  • Loading branch information
crowlKats authored and dsherret committed Jan 13, 2023
1 parent 0003cf7 commit 257471f
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 27 deletions.
1 change: 1 addition & 0 deletions runtime/js/06_util.js
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,7 @@
function getterOnly(getter) {
return {
get: getter,
set() {},
enumerable: true,
configurable: true,
};
Expand Down
34 changes: 7 additions & 27 deletions runtime/js/98_global_scope.js
Original file line number Diff line number Diff line change
Expand Up @@ -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),
};

Expand All @@ -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 = {
Expand Down

0 comments on commit 257471f

Please sign in to comment.