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

This commit is contained in:
Albert Nigmatzianov 2021-09-11 23:31:08 +02:00 committed by GitHub
parent 723052d5bb
commit 491614c7f8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 12 additions and 1 deletions

View File

@ -54,7 +54,7 @@ export type Serializable =
/** /**
* @public * @public
*/ */
export type JSONArray = Serializable[]; export type JSONArray = readonly Serializable[];
/** /**
* @public * @public

View File

@ -79,6 +79,17 @@ describe('Frame specs', function () {
'Execution context is not available in detached frame' '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 () { describe('Frame Management', function () {