[StorageFactory] Unable to use Object.keys|entries|values(sessionStorage) after #1385
Closed this issue · 0 comments
motss commented
Describe the bug
We can actually get all the keys of a Storage
using Object.<keys|entries|values>()
(Also see here). After #1385, it no longer works and we will seethe following error:
TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property '<key>' which is either non-existent or configurable in the proxy target
To Reproduce
Simple go to https://stackblitz.com/edit/vitest-dev-vitest-9lccsx and you will see the error in the terminal.
Also a simple code snippet to reproduce the error:
import { expect, it } from 'vitest';
it('Object.keys on window.sessionStorage', () => {
window.sessionStorage.setItem('a', '1');
expect(Object.keys(window.sessionStorage)).toEqual(['a']); // TypeError
expect(Object.values(window.sessionStorage)).toEqual(['1']); // TypeError
expect(Object.entries(window.sessionStorage)).toEqual([['a','1']]); // TypeError
});
Expected behavior
Object.keys(widow.sessionStorage)
should return a list of keys in the sessionStorage
Screenshots
FAIL test/basic.test.ts > Object.keys on window.sessionStorage
TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property 'a' which is either non-existent or configurable in the proxy target
❯ eval test/basic.test.ts:5:39
4| window.sessionStorage.setItem('a', '1');
5|
6| expect(Object.keys(window.sessionStorage)).toEqual(['a']);
| ^
7| });
8|
Device:
- OS: Windows
- Browser: Chrome
- Version 125
Additional context
happy-dom
version: 14.7.1