Skip to content

Commit

Permalink
fix: wait for context should respect already existing contexts (#2998)
Browse files Browse the repository at this point in the history
This should address Puppeteer test failures:
https://github.com/GoogleChromeLabs/chromium-bidi/actions/runs/12827546451/job/35769733285?pr=2993

Tested manually. 1000 times run Puppeteer test "[locator.spec] Locator
Locator.prototype.filter should resolve as soon as the predicate
matches" with and without the change. Problem is gone.
  • Loading branch information
sadym-chromium authored Jan 17, 2025
1 parent d7ed911 commit f6cb8ec
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/bidiMapper/modules/context/BrowsingContextStorage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,10 @@ export class BrowsingContextStorage {
waitForContext(
browsingContextId: BrowsingContext.BrowsingContext,
): Promise<BrowsingContextImpl> {
if (this.#contexts.has(browsingContextId)) {
return Promise.resolve(this.getContext(browsingContextId));
}

return new Promise((resolve) => {
const listener = (event: {browsingContext: BrowsingContextImpl}) => {
if (event.browsingContext.id === browsingContextId) {
Expand Down

0 comments on commit f6cb8ec

Please sign in to comment.