feat: recreate IndexedDB in storagestate#34591
Conversation
There was a problem hiding this comment.
Copilot reviewed 7 out of 7 changed files in this pull request and generated no comments.
Comments suppressed due to low confidence (2)
docs/src/api/params.md:268
- The documentation for the
indexedDBfield is incomplete. The 'TODO: document more' comment should be replaced with a proper description.
indexedDB ?<[Array]<[Object]>>
tests/library/browsercontext-storage-state.spec.ts:320
- The test case should also cover scenarios where the 'indexedDB' array is empty or null.
it('should support IndexedDB', async ({ page, contextFactory }) => {
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
|
||
| const idbResult = await Promise.all((await indexedDB.databases()).map(async dbInfo => { | ||
| if (!dbInfo.name) | ||
| throw new Error('Database name is empty'); |
There was a problem hiding this comment.
Let's make sure any error clearly states that it was not able to serialize IndexedDB. Probably a big try/catch around IndexedDB code would be the best.
There was a problem hiding this comment.
i've added .catch to the two big promises.
| for (const store of db.stores) { | ||
| for (const record of store.records) { | ||
| if (record.key !== undefined) | ||
| record.key = JSON.stringify(utilitySerializers.serializeAsCallArgument(record.value, v => ({ fallThrough: v }))); |
There was a problem hiding this comment.
WDYT about including keys/values verbatim, as long as they are serializable as JSON? And if not, we can have additional keyEncoded/valueEncoded properties that will hold the serialized value in any format. This way, the format is usually readable, except for when encoding is actually required.
There was a problem hiding this comment.
makes sense to me 👍 doing this in a follow-up
This comment has been minimized.
This comment has been minimized.
| properties: | ||
| origin: string | ||
| localStorage: | ||
| type: array |
There was a problem hiding this comment.
I guess we can make this one optional as well.
There was a problem hiding this comment.
gonna do that in a follow-up.
This comment has been minimized.
This comment has been minimized.
Test results for "tests 1"10 flaky37781 passed, 655 skipped Merge workflow run. |
Closes #11164