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

It looks like the tabopen callback is async, so we must
make sure it is called when opening new pages.
This commit is contained in:
Andrey Lushnikov 2022-06-30 11:07:38 -07:00 committed by GitHub
parent 35720e2fcd
commit 458c9b2207
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 14 additions and 6 deletions

View file

@ -1,2 +1,2 @@
1331
Changed: lushnikov@chromium.org Wed Jun 29 23:40:49 MSK 2022
1332
Changed: lushnikov@chromium.org Thu Jun 30 02:06:47 MSK 2022

View file

@ -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())

View file

@ -1,2 +1,2 @@
1330
Changed: lushnikov@chromium.org Wed Jun 29 23:40:12 MSK 2022
1331
Changed: lushnikov@chromium.org Thu Jun 30 02:09:30 MSK 2022

View file

@ -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())