capricorn86 / happy-dom

A JavaScript implementation of a web browser without its graphical user interface
MIT License
3.09k stars 185 forks source link

fix: [#1418] Fix Object.{entries,key,values} on Storage #1423

Closed motss closed 2 months ago

motss commented 2 months ago

Background

This fixes #1418.

L79-84 checks that if a property does not exist in proxy target it return undefined for the configuration of the property and Object.keys(window.sessionStorage, '<existent_property_key>') returns { configurable: true, /** truncated for brevity */ } on the browser (Tested on MS Edge 124).

https://github.com/capricorn86/happy-dom/blob/c29f36c5644eacd0546b5c302ecd6bd7feacf50f/packages/happy-dom/src/storage/StorageFactory.ts#L78-L92

Changes

  1. Fix Object.{entries,keys,values}() throwing TypeError on Storage by setting { configurable: true } for all existent property in the Storage
  2. Add tests for above changes