Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

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

Simon Knott53ed2f601b87
diff --git a/packages/playwright-core/src/server/storageScript.ts b/packages/playwright-core/src/server/storageScript.ts
index 6ed162587b..c306b11ed5 100644
--- a/packages/playwright-core/src/server/storageScript.ts
+++ b/packages/playwright-core/src/server/storageScript.ts
@@ -36,8 +36,8 @@ export async function collect(serializers: ReturnType<typeof source>, isFirefox:
function isPlainObject(v: any) {
const ctor = v?.constructor;
if (isFirefox) {
- const constructorImpl = ctor?.toString();
- if (constructorImpl.startsWith('function Object() {') && constructorImpl.includes('[native code]'))
+ const constructorImpl = ctor?.toString() as string | undefined;
+ if (constructorImpl?.startsWith('function Object() {') && constructorImpl?.includes('[native code]'))
return true;
}
diff --git a/tests/library/browsercontext-storage-state.spec.ts b/tests/library/browsercontext-storage-state.spec.ts
index abb8b368da..ec8afa8e91 100644
--- a/tests/library/browsercontext-storage-state.spec.ts
+++ b/tests/library/browsercontext-storage-state.spec.ts
@@ -95,7 +95,7 @@ it('should round-trip through the file', async ({ contextFactory }, testInfo) =>
const transaction = openRequest.result.transaction(['store', 'store2'], 'readwrite');
transaction
.objectStore('store')
- .put({ name: 'foo', date: new Date(0) });
+ .put({ name: 'foo', date: new Date(0), null: null });
transaction
.objectStore('store2')
.put('bar', 'foo');
@@ -138,7 +138,7 @@ it('should round-trip through the file', async ({ contextFactory }, testInfo) =>
openRequest.addEventListener('error', () => reject(openRequest.error));
}));
expect(idbValues).toEqual([
- { name: 'foo', date: new Date(0) },
+ { name: 'foo', date: new Date(0), null: null },
'bar'
]);
await context2.close();