fix: destroy puppeteer utility on context destruction (#10672)
This commit is contained in:
parent
21461b02c6
commit
8b8770c004
@ -54,6 +54,7 @@ export class Browser extends BrowserBase {
|
|||||||
'browsingContext',
|
'browsingContext',
|
||||||
'network',
|
'network',
|
||||||
'log',
|
'log',
|
||||||
|
'script',
|
||||||
];
|
];
|
||||||
static readonly subscribeCdpEvents: Bidi.Cdp.EventNames[] = [
|
static readonly subscribeCdpEvents: Bidi.Cdp.EventNames[] = [
|
||||||
// Coverage
|
// Coverage
|
||||||
|
@ -7,6 +7,7 @@ import {scriptInjector} from '../ScriptInjector.js';
|
|||||||
import {EvaluateFunc, HandleFor} from '../types.js';
|
import {EvaluateFunc, HandleFor} from '../types.js';
|
||||||
import {
|
import {
|
||||||
PuppeteerURL,
|
PuppeteerURL,
|
||||||
|
debugError,
|
||||||
getSourcePuppeteerURLIfAvailable,
|
getSourcePuppeteerURLIfAvailable,
|
||||||
isString,
|
isString,
|
||||||
} from '../util.js';
|
} from '../util.js';
|
||||||
@ -46,6 +47,22 @@ export class Realm extends EventEmitter {
|
|||||||
|
|
||||||
setFrame(frame: Frame): void {
|
setFrame(frame: Frame): void {
|
||||||
this.#frame = frame;
|
this.#frame = frame;
|
||||||
|
|
||||||
|
// TODO(jrandolf): We should try to find a less brute-force way of doing
|
||||||
|
// this.
|
||||||
|
this.connection.on(
|
||||||
|
Bidi.ChromiumBidi.Script.EventNames.RealmDestroyed,
|
||||||
|
async () => {
|
||||||
|
const promise = this.internalPuppeteerUtil;
|
||||||
|
this.internalPuppeteerUtil = undefined;
|
||||||
|
try {
|
||||||
|
const util = await promise;
|
||||||
|
await util?.dispose();
|
||||||
|
} catch (error) {
|
||||||
|
debugError(error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected internalPuppeteerUtil?: Promise<JSHandle<PuppeteerUtil>>;
|
protected internalPuppeteerUtil?: Promise<JSHandle<PuppeteerUtil>>;
|
||||||
|
@ -60,7 +60,6 @@ export interface SandboxChart {
|
|||||||
* @internal
|
* @internal
|
||||||
*/
|
*/
|
||||||
export class Sandbox implements RealmBase {
|
export class Sandbox implements RealmBase {
|
||||||
#document?: ElementHandle<Document>;
|
|
||||||
#realm: Realm;
|
#realm: Realm;
|
||||||
|
|
||||||
#timeoutSettings: TimeoutSettings;
|
#timeoutSettings: TimeoutSettings;
|
||||||
@ -76,13 +75,11 @@ export class Sandbox implements RealmBase {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async document(): Promise<ElementHandle<Document>> {
|
async document(): Promise<ElementHandle<Document>> {
|
||||||
if (this.#document) {
|
// TODO(jrandolf): We should try to cache this because we need to dispose
|
||||||
return this.#document;
|
// this when it's unused.
|
||||||
}
|
return await this.#realm.evaluateHandle(() => {
|
||||||
this.#document = await this.#realm.evaluateHandle(() => {
|
|
||||||
return document;
|
return document;
|
||||||
});
|
});
|
||||||
return this.#document;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
async $<Selector extends string>(
|
async $<Selector extends string>(
|
||||||
|
@ -341,12 +341,48 @@
|
|||||||
"parameters": ["webDriverBiDi"],
|
"parameters": ["webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["PASS"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[browser.spec] Browser specs Browser.target should return browser target",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[browsercontext.spec] BrowserContext should close all belonging targets once closing context",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[browsercontext.spec] BrowserContext should create new incognito context",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[browsercontext.spec] BrowserContext should have default context",
|
"testIdPattern": "[browsercontext.spec] BrowserContext should have default context",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
"parameters": ["webDriverBiDi"],
|
"parameters": ["webDriverBiDi"],
|
||||||
"expectations": ["PASS"]
|
"expectations": ["PASS"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[browsercontext.spec] BrowserContext should timeout waiting for a non-existent target",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[browsercontext.spec] BrowserContext should wait for a target",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[browsercontext.spec] BrowserContext window.open should use parent tab context",
|
||||||
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
"parameters": ["webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[CDPSession.spec] Target.createCDPSession *",
|
"testIdPattern": "[CDPSession.spec] Target.createCDPSession *",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
@ -3899,6 +3935,12 @@
|
|||||||
"parameters": ["cdp", "chrome", "new-headless"],
|
"parameters": ["cdp", "chrome", "new-headless"],
|
||||||
"expectations": ["FAIL", "PASS"]
|
"expectations": ["FAIL", "PASS"]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"testIdPattern": "[click.spec] Page.click should click the button after navigation",
|
||||||
|
"platforms": ["darwin"],
|
||||||
|
"parameters": ["chrome", "headless", "webDriverBiDi"],
|
||||||
|
"expectations": ["PASS"]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"testIdPattern": "[click.spec] Page.click should click the button with fixed position inside an iframe",
|
"testIdPattern": "[click.spec] Page.click should click the button with fixed position inside an iframe",
|
||||||
"platforms": ["darwin", "linux", "win32"],
|
"platforms": ["darwin", "linux", "win32"],
|
||||||
|
Loading…
Reference in New Issue
Block a user