From 886652156e0e548a44fd41b293916bf37594eaa3 Mon Sep 17 00:00:00 2001 From: Kenta Moriuchi Date: Tue, 14 Nov 2023 15:01:15 +0900 Subject: fix(ext/web): webstorage has trap for symbol (#21090) --- cli/tests/unit/webstorage_test.ts | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) (limited to 'cli/tests') diff --git a/cli/tests/unit/webstorage_test.ts b/cli/tests/unit/webstorage_test.ts index e6ca5bb88..9c71b6320 100644 --- a/cli/tests/unit/webstorage_test.ts +++ b/cli/tests/unit/webstorage_test.ts @@ -1,7 +1,7 @@ // Copyright 2018-2023 the Deno authors. All rights reserved. MIT license. // deno-lint-ignore-file no-explicit-any -import { assert, assertThrows } from "./test_util.ts"; +import { assert, assertEquals, assertThrows } from "./test_util.ts"; Deno.test({ permissions: "none" }, function webStoragesReassignable() { // Can reassign to web storages @@ -21,7 +21,7 @@ Deno.test(function webstorageSizeLimit() { Error, "Exceeded maximum storage size", ); - assert(localStorage.getItem("k") === null); + assertEquals(localStorage.getItem("k"), null); assertThrows( () => { localStorage.setItem("k".repeat(15 * 1024 * 1024), "v"); @@ -40,3 +40,13 @@ Deno.test(function webstorageSizeLimit() { "Exceeded maximum storage size", ); }); + +Deno.test(function webstorageProxy() { + localStorage.clear(); + localStorage.foo = "foo"; + assertEquals(localStorage.foo, "foo"); + const symbol = Symbol("bar"); + localStorage[symbol as any] = "bar"; + assertEquals(localStorage[symbol as any], "bar"); + assertEquals(symbol in localStorage, true); +}); -- cgit v1.2.3