fix(ext/webstorage): make web storages re-assignable (#16661)

This commit is contained in:
Yoshiya Hinosawa 2022-11-17 02:12:58 +09:00 committed by GitHub
parent 38542e849d
commit 1d85c25205
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 17 additions and 0 deletions

View file

@ -0,0 +1,13 @@
// Copyright 2018-2022 the Deno authors. All rights reserved. MIT license.
// deno-lint-ignore-file no-explicit-any
import { assert } from "./test_util.ts";
Deno.test({ permissions: "none" }, function webStoragesReassignable() {
// Can reassign to web storages
globalThis.localStorage = 1 as any;
globalThis.sessionStorage = 1 as any;
// The actual values don't change
assert(globalThis.localStorage instanceof globalThis.Storage);
assert(globalThis.sessionStorage instanceof globalThis.Storage);
});

View file

@ -587,11 +587,15 @@ delete Intl.v8BreakIterator;
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: () => {},
},
Storage: util.nonEnumerable(webStorage.Storage),
};