chore: support launchPersistentContext with bidi (#32641)
This commit is contained in:
parent
6dbde62a6b
commit
2a347b5494
|
|
@ -94,6 +94,14 @@ export class BidiBrowser extends Browser {
|
|||
'script',
|
||||
],
|
||||
});
|
||||
|
||||
if (options.persistent) {
|
||||
browser._defaultContext = new BidiBrowserContext(browser, undefined, options.persistent);
|
||||
await (browser._defaultContext as BidiBrowserContext)._initialize();
|
||||
// Create default page as we cannot get access to the existing one.
|
||||
const pageDelegate = await browser._defaultContext.newPageDelegate();
|
||||
await pageDelegate.pageOrError();
|
||||
}
|
||||
return browser;
|
||||
}
|
||||
|
||||
|
|
@ -294,10 +302,11 @@ export class BidiBrowserContext extends BrowserContext {
|
|||
}
|
||||
|
||||
async doClose(reason: string | undefined) {
|
||||
// TODO: implement for persistent context
|
||||
if (!this._browserContextId)
|
||||
if (!this._browserContextId) {
|
||||
// Closing persistent context should close the browser.
|
||||
await this._browser.close({ reason });
|
||||
return;
|
||||
|
||||
}
|
||||
await this._browser._browserSession.send('browser.removeUserContext', {
|
||||
userContext: this._browserContextId
|
||||
});
|
||||
|
|
|
|||
|
|
@ -76,12 +76,6 @@ export class BidiFirefox extends BrowserType {
|
|||
firefoxArguments.push('--foreground');
|
||||
firefoxArguments.push(`--profile`, userDataDir);
|
||||
firefoxArguments.push(...args);
|
||||
// TODO: make ephemeral context work without this argument.
|
||||
firefoxArguments.push('about:blank');
|
||||
// if (isPersistent)
|
||||
// firefoxArguments.push('about:blank');
|
||||
// else
|
||||
// firefoxArguments.push('-silent');
|
||||
return firefoxArguments;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue