mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
fix: use LazyArg for puppeteer utilities (#9575)
This PR fixes the following edge case: - `const oldPromise = world.puppeteerUtil`. - setContext occurs but context is immediately destroyed, i.e. `world.#puppeteerUtil === oldPromise` is not resolved. - clearContext occurs due to destruction, i.e. `world.#puppeteerUtil` is replaced (`world.#puppeteerUtil !== oldPromise`). - `oldPromise` never resolves.
This commit is contained in:
@@ -16,6 +16,7 @@
|
||||
|
||||
import expect from 'expect';
|
||||
import {PUPPETEER_WORLD} from 'puppeteer-core/internal/common/IsolatedWorlds.js';
|
||||
import {LazyArg} from 'puppeteer-core/internal/common/LazyArg.js';
|
||||
import {
|
||||
getTestState,
|
||||
setupTestBrowserHooks,
|
||||
@@ -45,7 +46,9 @@ describe('PuppeteerUtil tests', function () {
|
||||
({createFunction}, fnString) => {
|
||||
return createFunction(fnString)(4);
|
||||
},
|
||||
await world.puppeteerUtil,
|
||||
LazyArg.create(() => {
|
||||
return world.puppeteerUtil;
|
||||
}),
|
||||
(() => {
|
||||
return 4;
|
||||
}).toString()
|
||||
|
||||
Reference in New Issue
Block a user