Skip to content

Commit

Permalink
fix firefox bug
Browse files Browse the repository at this point in the history
  • Loading branch information
Skn0tt committed Feb 5, 2025
1 parent a1f4cb8 commit 3da33e0
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion packages/playwright-core/src/server/storageScript.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,11 +33,24 @@ export async function collect(serializers: ReturnType<typeof source>): Promise<S
});
}

function isPlainObject(v: any) {
const ctor = v?.constructor;
if (ctor === Object)
return true;

// firefox bug. apparently, plain objects returned from IndexedDB don't have the right constructor.
const constructorImpl = ctor?.toString();
if (constructorImpl.startsWith('function Object() {') && constructorImpl.includes('[native code]'))
return true;

return false;
}

function trySerialize(value: any): { trivial?: any, encoded?: any } {
let trivial = true;
const encoded = serializers.serializeAsCallArgument(value, v => {
const isTrivial = (
v?.constructor === Object
isPlainObject(v)
|| Array.isArray(v)
|| typeof v === 'string'
|| typeof v === 'number'
Expand Down

0 comments on commit 3da33e0

Please sign in to comment.