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:
parent
35720e2fcd
commit
458c9b2207
|
|
@ -1,2 +1,2 @@
|
||||||
1331
|
1332
|
||||||
Changed: lushnikov@chromium.org Wed Jun 29 23:40:49 MSK 2022
|
Changed: lushnikov@chromium.org Thu Jun 30 02:06:47 MSK 2022
|
||||||
|
|
|
||||||
|
|
@ -323,7 +323,11 @@ class TargetRegistry {
|
||||||
if (window.gBrowser.browsers.length !== 1)
|
if (window.gBrowser.browsers.length !== 1)
|
||||||
throw new Error(`Unexpected number of tabs in the new window: ${window.gBrowser.browsers.length}`);
|
throw new Error(`Unexpected number of tabs in the new window: ${window.gBrowser.browsers.length}`);
|
||||||
const browser = window.gBrowser.browsers[0];
|
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();
|
browser.focus();
|
||||||
if (browserContext.settings.timezoneId) {
|
if (browserContext.settings.timezoneId) {
|
||||||
if (await target.hasFailedToOverrideTimezone())
|
if (await target.hasFailedToOverrideTimezone())
|
||||||
|
|
|
||||||
|
|
@ -1,2 +1,2 @@
|
||||||
1330
|
1331
|
||||||
Changed: lushnikov@chromium.org Wed Jun 29 23:40:12 MSK 2022
|
Changed: lushnikov@chromium.org Thu Jun 30 02:09:30 MSK 2022
|
||||||
|
|
|
||||||
|
|
@ -323,7 +323,11 @@ class TargetRegistry {
|
||||||
if (window.gBrowser.browsers.length !== 1)
|
if (window.gBrowser.browsers.length !== 1)
|
||||||
throw new Error(`Unexpected number of tabs in the new window: ${window.gBrowser.browsers.length}`);
|
throw new Error(`Unexpected number of tabs in the new window: ${window.gBrowser.browsers.length}`);
|
||||||
const browser = window.gBrowser.browsers[0];
|
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();
|
browser.focus();
|
||||||
if (browserContext.settings.timezoneId) {
|
if (browserContext.settings.timezoneId) {
|
||||||
if (await target.hasFailedToOverrideTimezone())
|
if (await target.hasFailedToOverrideTimezone())
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue