Skip to content

Playwright is a framework for Web Testing and Automation. It allows testing Chromium, Firefox and WebKit with a single API.

browser(firefox): fix racy browser.newPage() method (#15251)

Andrey Lushnikov458c9b2207e7
diff --git a/browser_patches/firefox-beta/BUILD_NUMBER b/browser_patches/firefox-beta/BUILD_NUMBER
index 4aa31a868c..e8eaba0037 100644
--- a/browser_patches/firefox-beta/BUILD_NUMBER
+++ b/browser_patches/firefox-beta/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1331
-Changed: [email protected] Wed Jun 29 23:40:49 MSK 2022
+1332
+Changed: [email protected] Thu Jun 30 02:06:47 MSK 2022
diff --git a/browser_patches/firefox-beta/juggler/TargetRegistry.js b/browser_patches/firefox-beta/juggler/TargetRegistry.js
index 0ec90afd1b..b222ba98bb 100644
--- a/browser_patches/firefox-beta/juggler/TargetRegistry.js
+++ b/browser_patches/firefox-beta/juggler/TargetRegistry.js
@@ -323,7 +323,11 @@ class TargetRegistry {
if (window.gBrowser.browsers.length !== 1)
throw new Error(`Unexpected number of tabs in the new window: ${window.gBrowser.browsers.length}`);
const browser = window.gBrowser.browsers[0];
- const target = this._browserToTarget.get(browser);
+ let target = this._browserToTarget.get(browser);
+ while (!target) {
+ await helper.awaitEvent(this, TargetRegistry.Events.TargetCreated);
+ target = this._browserToTarget.get(browser);
+ }
browser.focus();
if (browserContext.settings.timezoneId) {
if (await target.hasFailedToOverrideTimezone())
diff --git a/browser_patches/firefox/BUILD_NUMBER b/browser_patches/firefox/BUILD_NUMBER
index 8a2f94ecf7..76efacde24 100644
--- a/browser_patches/firefox/BUILD_NUMBER
+++ b/browser_patches/firefox/BUILD_NUMBER
@@ -1,2 +1,2 @@
-1330
-Changed: [email protected] Wed Jun 29 23:40:12 MSK 2022
+1331
+Changed: [email protected] Thu Jun 30 02:09:30 MSK 2022
diff --git a/browser_patches/firefox/juggler/TargetRegistry.js b/browser_patches/firefox/juggler/TargetRegistry.js
index 0ec90afd1b..b222ba98bb 100644
--- a/browser_patches/firefox/juggler/TargetRegistry.js
+++ b/browser_patches/firefox/juggler/TargetRegistry.js
@@ -323,7 +323,11 @@ class TargetRegistry {
if (window.gBrowser.browsers.length !== 1)
throw new Error(`Unexpected number of tabs in the new window: ${window.gBrowser.browsers.length}`);
const browser = window.gBrowser.browsers[0];
- const target = this._browserToTarget.get(browser);
+ let target = this._browserToTarget.get(browser);
+ while (!target) {
+ await helper.awaitEvent(this, TargetRegistry.Events.TargetCreated);
+ target = this._browserToTarget.get(browser);
+ }
browser.focus();
if (browserContext.settings.timezoneId) {
if (await target.hasFailedToOverrideTimezone())