fix(library): indexedDB shouldn't stumble over `null` in Firefox (#35308)

This commit is contained in:
Simon Knott 2025-03-21 10:24:28 +01:00 committed by GitHub
parent b83e0af11a
commit 53ed2f601b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 4 additions and 4 deletions

View File

@ -36,8 +36,8 @@ export async function collect(serializers: ReturnType<typeof source>, isFirefox:
function isPlainObject(v: any) { function isPlainObject(v: any) {
const ctor = v?.constructor; const ctor = v?.constructor;
if (isFirefox) { if (isFirefox) {
const constructorImpl = ctor?.toString(); const constructorImpl = ctor?.toString() as string | undefined;
if (constructorImpl.startsWith('function Object() {') && constructorImpl.includes('[native code]')) if (constructorImpl?.startsWith('function Object() {') && constructorImpl?.includes('[native code]'))
return true; return true;
} }

View File

@ -95,7 +95,7 @@ it('should round-trip through the file', async ({ contextFactory }, testInfo) =>
const transaction = openRequest.result.transaction(['store', 'store2'], 'readwrite'); const transaction = openRequest.result.transaction(['store', 'store2'], 'readwrite');
transaction transaction
.objectStore('store') .objectStore('store')
.put({ name: 'foo', date: new Date(0) }); .put({ name: 'foo', date: new Date(0), null: null });
transaction transaction
.objectStore('store2') .objectStore('store2')
.put('bar', 'foo'); .put('bar', 'foo');
@ -138,7 +138,7 @@ it('should round-trip through the file', async ({ contextFactory }, testInfo) =>
openRequest.addEventListener('error', () => reject(openRequest.error)); openRequest.addEventListener('error', () => reject(openRequest.error));
})); }));
expect(idbValues).toEqual([ expect(idbValues).toEqual([
{ name: 'foo', date: new Date(0) }, { name: 'foo', date: new Date(0), null: null },
'bar' 'bar'
]); ]);
await context2.close(); await context2.close();