diff --git a/src/common/EvalTypes.ts b/src/common/EvalTypes.ts index 200cf701..b400f44b 100644 --- a/src/common/EvalTypes.ts +++ b/src/common/EvalTypes.ts @@ -54,7 +54,7 @@ export type Serializable = /** * @public */ -export type JSONArray = Serializable[]; +export type JSONArray = readonly Serializable[]; /** * @public diff --git a/test/frame.spec.ts b/test/frame.spec.ts index 269da7d7..f1310f69 100644 --- a/test/frame.spec.ts +++ b/test/frame.spec.ts @@ -79,6 +79,17 @@ describe('Frame specs', function () { 'Execution context is not available in detached frame' ); }); + + it('allows readonly array to be an argument', async () => { + const { page, server } = getTestState(); + await page.goto(server.EMPTY_PAGE); + const mainFrame = page.mainFrame(); + + // This test checks if Frame.evaluate allows a readonly array to be an argument. + // See https://github.com/puppeteer/puppeteer/issues/6953. + const readonlyArray: readonly string[] = ['a', 'b', 'c']; + mainFrame.evaluate((arr) => arr, readonlyArray); + }); }); describe('Frame Management', function () {