Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(types): allow evaluate functions to take a readonly array as an argument #7072

Merged
merged 5 commits into from Sep 11, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
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