Skip to content

Commit

Permalink
fix(types): allow evaluate functions to take a readonly array as an a…
Browse files Browse the repository at this point in the history
…rgument (#7072)
  • Loading branch information
n10v committed Sep 11, 2021
1 parent 723052d commit 491614c
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/common/EvalTypes.ts
Expand Up @@ -54,7 +54,7 @@ export type Serializable =
/**
* @public
*/
export type JSONArray = Serializable[];
export type JSONArray = readonly Serializable[];

/**
* @public
Expand Down
11 changes: 11 additions & 0 deletions test/frame.spec.ts
Expand Up @@ -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 () {
Expand Down

0 comments on commit 491614c

Please sign in to comment.