зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1616113 - Better detect target switching in navigateTo. r=nchevobbe
The existing check comparing toolbox's targets is racy. The target may be updated late, after we compare them in this test. Comparing PIDs looks safer as they should be updated almost immediately. Differential Revision: https://phabricator.services.mozilla.com/D63176 --HG-- extra : moz-landing-system : lando
This commit is contained in:
Родитель
0e86789568
Коммит
1c8e2951b0
|
@ -266,7 +266,6 @@ var refreshTab = async function(tab = gBrowser.selectedTab) {
|
|||
async function navigateTo(uri, { isErrorPage = false } = {}) {
|
||||
const target = await TargetFactory.forTab(gBrowser.selectedTab);
|
||||
const toolbox = gDevTools.getToolbox(target);
|
||||
const currentToolboxTarget = toolbox.target;
|
||||
|
||||
// If we're switching origins, we need to wait for the 'switched-target'
|
||||
// event to make sure everything is ready.
|
||||
|
@ -287,6 +286,7 @@ async function navigateTo(uri, { isErrorPage = false } = {}) {
|
|||
|
||||
info(`Load document "${uri}"`);
|
||||
const browser = gBrowser.selectedBrowser;
|
||||
const currentPID = browser.browsingContext.currentWindowGlobal.osPid;
|
||||
const onBrowserLoaded = BrowserTestUtils.browserLoaded(
|
||||
browser,
|
||||
false,
|
||||
|
@ -299,13 +299,33 @@ async function navigateTo(uri, { isErrorPage = false } = {}) {
|
|||
await onBrowserLoaded;
|
||||
info(`→ page loaded`);
|
||||
|
||||
// Compare the PIDs (and not the toolbox's targets) as PIDs are updated also immediately,
|
||||
// while target may be updated slightly later.
|
||||
const switchedToAnotherProcess =
|
||||
currentPID !== browser.browsingContext.currentWindowGlobal.osPid;
|
||||
|
||||
// If we switched to another process and the target switching pref is false,
|
||||
// the toolbox will close and reopen.
|
||||
// For now, this helper doesn't support this case
|
||||
if (
|
||||
switchedToAnotherProcess &&
|
||||
!Services.prefs.getBoolPref("devtools.target-switching.enabled", false)
|
||||
) {
|
||||
ok(
|
||||
false,
|
||||
`navigateTo(${uri}) navigated to another process, but the target-switching preference is false`
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
if (onPanelReloaded) {
|
||||
info(`Waiting for ${toolbox.currentToolId} to be reloaded…`);
|
||||
await onPanelReloaded();
|
||||
info(`→ panel reloaded`);
|
||||
}
|
||||
|
||||
if (toolbox.target !== currentToolboxTarget) {
|
||||
// If the tab navigated to another process, expect a target switching
|
||||
if (switchedToAnotherProcess) {
|
||||
info(`Waiting for target switch…`);
|
||||
await onTargetSwitched;
|
||||
info(`→ switched-target emitted`);
|
||||
|
|
Загрузка…
Ссылка в новой задаче