Skip to content

Commit b9ccc5b

Browse files
authored
chore(bidi): hardcode "default" id for persistent context (#35303)
1 parent fbffb81 commit b9ccc5b

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

packages/playwright-core/src/server/bidi/bidiBrowser.ts

+4-7
Original file line numberDiff line numberDiff line change
@@ -98,13 +98,9 @@ export class BidiBrowser extends Browser {
9898
});
9999

100100
if (options.persistent) {
101-
const { userContexts } = await browser._browserSession.send('browser.getUserContexts', {});
102-
if (!userContexts.length)
103-
throw new Error('Cannot dermine default context id, no contexts found.');
104101
const context = new BidiBrowserContext(browser, undefined, options.persistent);
105-
context._defaultUserContext = userContexts[0].userContext;
106102
browser._defaultContext = context;
107-
await (browser._defaultContext as BidiBrowserContext)._initialize();
103+
await context._initialize();
108104
// Create default page as we cannot get access to the existing one.
109105
const page = await browser._defaultContext.doCreateNewPage();
110106
await page.waitForInitializedOrError();
@@ -209,7 +205,6 @@ export class BidiBrowser extends Browser {
209205
export class BidiBrowserContext extends BrowserContext {
210206
declare readonly _browser: BidiBrowser;
211207
private _initScriptIds: bidi.Script.PreloadScript[] = [];
212-
_defaultUserContext: bidi.Browser.UserContext | undefined;
213208

214209
constructor(browser: BidiBrowser, browserContextId: string | undefined, options: types.BrowserContextOptions) {
215210
super(browser, options, browserContextId);
@@ -376,7 +371,9 @@ export class BidiBrowserContext extends BrowserContext {
376371
private _userContextId(): bidi.Browser.UserContext {
377372
if (this._browserContextId)
378373
return this._browserContextId;
379-
return this._defaultUserContext!;
374+
// Default context always has same id, see
375+
// https://w3c.github.io/webdriver-bidi/#default-user-context
376+
return 'default';
380377
}
381378
}
382379

0 commit comments

Comments
 (0)