mirror of
https://github.com/denoland/deno.git
synced 2025-01-11 00:21:05 -05:00
fix(ext/webstorage): make web storages re-assignable (#16661)
This commit is contained in:
parent
38542e849d
commit
1d85c25205
2 changed files with 17 additions and 0 deletions
13
cli/tests/unit/webstorage_test.ts
Normal file
13
cli/tests/unit/webstorage_test.ts
Normal 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);
|
||||
});
|
|
@ -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),
|
||||
};
|
||||
|
|
Loading…
Reference in a new issue