fix(storage): preserve IndexedDB Map and Set values - #42707
Conversation
Fixes: microsoft#42703 Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
|
|
||
| function isMap(obj: any): obj is Map<unknown, unknown> { | ||
| try { | ||
| return obj instanceof Map || Object.prototype.toString.call(obj) === '[object Map]'; |
There was a problem hiding this comment.
we can be strict and drop [object Map]
There was a problem hiding this comment.
instanceof Map fails for Firefox’s cross-world wrappers; removing the fallback breaks both IndexedDB roundtrip tests
|
|
||
| return { fallThrough: v }; | ||
| }); | ||
| }, { serializeMapAndSet: true }); |
There was a problem hiding this comment.
expose this in evaluate?
There was a problem hiding this comment.
Will do in a separate pr.
This comment has been minimized.
This comment has been minimized.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
| const iterator = value.entries(); | ||
| const next = new Map().entries().next; |
There was a problem hiding this comment.
is the idea here that we're trying to use our Map instead of whatever is in the object's realm? or are we just trying to avoid our code being observable by the page?
regardless, i think this maybe should be const iterator = Map.prototype.entries.call(value) to avoid it having overridden value.entries = function() { ... })
There was a problem hiding this comment.
This to workaround Firefox not exposing iterator.next cross worlds. For storage state this code is running in the utility world, so we don't need to worry about entries override. I'll probably update it in the pr where this option become public on evaluate.
| const s: SerializedValue[] = []; | ||
| const id = ++visitorInfo.lastId; | ||
| visitorInfo.visited.set(value, id); | ||
| const iterator = value.values(); |
There was a problem hiding this comment.
ditto with Set.prototype.values.call(value)
d4ce80d
into
microsoft:main
Test results for "tests 1"2 failed 7 flaky51719 passed, 1247 skipped Merge workflow run. |
Test results for "MCP"8564 passed, 1446 skipped Merge workflow run. |
|
Hi, I'm the Playwright bot and I triaged the CI failures on this PR. 🟢 Both failures are pre-existing — neither is caused by this PR. The Firefox storage-state failure is broken on DetailsThis PR only touches IndexedDB snapshot serialization: Pre-existing flake / infra
Method: queried the aggregated CI results DB (2021 runs, topped up with Triaged by the Playwright bot - agent run |
Fixes #42703