Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.
TypeScript automationchromechromiume2e-testingelectronend-to-end-testingfirefoxjavascriptplaywrighttesttest-automationtestingtesting-toolswebwebkit
chore(bidi): rename BidiPage._realmToContext (#39285)
Holger Benl19ae3eb59828
diff --git a/packages/playwright-core/src/server/bidi/bidiBrowser.ts b/packages/playwright-core/src/server/bidi/bidiBrowser.tsindex 071db4381b..f1d806332f 100644--- a/packages/playwright-core/src/server/bidi/bidiBrowser.ts+++ b/packages/playwright-core/src/server/bidi/bidiBrowser.ts@@ -464,7 +464,7 @@ export class BidiBrowserContext extends BrowserContext {userContexts: [this._userContextId()],}));promises.push(...this._bidiPages().map(page => {- const realms = [...page._realmToContext].filter(([realm, context]) => context.world === 'main').map(([realm, context]) => realm);+ const realms = [...page._contextIdToContext].filter(([realm, context]) => context.world === 'main').map(([realm, context]) => realm);return Promise.all(realms.map(realm => {return page._session.send('script.callFunction', {functionDeclaration,diff --git a/packages/playwright-core/src/server/bidi/bidiPage.ts b/packages/playwright-core/src/server/bidi/bidiPage.tsindex 990c41fc2e..237650d4b7 100644--- a/packages/playwright-core/src/server/bidi/bidiPage.ts+++ b/packages/playwright-core/src/server/bidi/bidiPage.ts@@ -46,7 +46,7 @@ export class BidiPage implements PageDelegate {readonly _page: Page;readonly _session: BidiSession;readonly _opener: BidiPage | null;- readonly _realmToContext: Map<string, dom.FrameExecutionContext>;+ readonly _contextIdToContext: Map<string, dom.FrameExecutionContext>;private _realmToWorkerContext = new Map<string, js.ExecutionContext>();private _sessionListeners: RegisteredListener[] = [];readonly _browserContext: BidiBrowserContext;@@ -61,7 +61,7 @@ export class BidiPage implements PageDelegate {this.rawKeyboard = new RawKeyboardImpl(bidiSession);this.rawMouse = new RawMouseImpl(bidiSession);this.rawTouchscreen = new RawTouchscreenImpl(bidiSession);- this._realmToContext = new Map();+ this._contextIdToContext = new Map();this._page = new Page(this, browserContext);this._browserContext = browserContext;this._networkManager = new BidiNetworkManager(this._session, this._page);@@ -114,9 +114,9 @@ export class BidiPage implements PageDelegate {}private _removeContextsForFrame(frame: frames.Frame, notifyFrame: boolean) {- for (const [contextId, context] of this._realmToContext) {+ for (const [contextId, context] of this._contextIdToContext) {if (context.frame === frame) {- this._realmToContext.delete(contextId);+ this._contextIdToContext.delete(contextId);if (notifyFrame)frame._contextDestroyed(context);}@@ -132,7 +132,7 @@ export class BidiPage implements PageDelegate {this._page.addWorker(realmInfo.realm, worker);return;}- if (this._realmToContext.has(realmInfo.realm))+ if (this._contextIdToContext.has(realmInfo.realm))return;if (realmInfo.type !== 'window')return;@@ -152,7 +152,7 @@ export class BidiPage implements PageDelegate {const delegate = new BidiExecutionContext(this._session, realmInfo);const context = new dom.FrameExecutionContext(delegate, frame, worldName);frame._contextCreated(worldName, context);- this._realmToContext.set(realmInfo.realm, context);+ this._contextIdToContext.set(realmInfo.realm, context);}private async _touchUtilityWorld(context: bidi.BrowsingContext.BrowsingContext) {@@ -172,9 +172,9 @@ export class BidiPage implements PageDelegate {}_onRealmDestroyed(params: bidi.Script.RealmDestroyedParameters): boolean {- const context = this._realmToContext.get(params.realm);+ const context = this._contextIdToContext.get(params.realm);if (context) {- this._realmToContext.delete(params.realm);+ this._contextIdToContext.delete(params.realm);context.frame._contextDestroyed(context);return true;}@@ -286,7 +286,7 @@ export class BidiPage implements PageDelegate {if (params.type !== 'console')return;const entry: bidi.Log.ConsoleLogEntry = params as bidi.Log.ConsoleLogEntry;- const context = this._realmToContext.get(params.source.realm) ?? this._realmToWorkerContext.get(params.source.realm);+ const context = this._contextIdToContext.get(params.source.realm) ?? this._realmToWorkerContext.get(params.source.realm);if (!context)return;@@ -425,7 +425,7 @@ export class BidiPage implements PageDelegate {const pageOrError = await this._page.waitForInitializedOrError();if (pageOrError instanceof Error)return;- const context = this._realmToContext.get(event.source.realm);+ const context = this._contextIdToContext.get(event.source.realm);if (!context)return;if (event.data.type !== 'string')diff --git a/tests/bidi/expectations/moz-firefox-nightly-page.txt b/tests/bidi/expectations/moz-firefox-nightly-page.txtindex 354aff25a2..751f1cd01f 100644--- a/tests/bidi/expectations/moz-firefox-nightly-page.txt+++ b/tests/bidi/expectations/moz-firefox-nightly-page.txt@@ -12,8 +12,6 @@ page/elementhandle-scroll-into-view.spec.ts › should wait for nested display:npage/elementhandle-scroll-into-view.spec.ts › should work @smoke [fail]page/expect-misc.spec.ts › strict mode violation error format [fail]page/frame-evaluate.spec.ts › should allow cross-frame element handles [fail]-page/frame-evaluate.spec.ts › should dispose context on cross-origin navigation [fail]-page/frame-evaluate.spec.ts › should dispose context on navigation [fail]page/frame-evaluate.spec.ts › should not allow cross-frame element handles when frames do not script each other [fail]page/frame-goto.spec.ts › should continue after client redirect [flaky]page/frame-hierarchy.spec.ts › should support framesets [fail]