mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-25 05:41:12 +00:00
Bug 1726240 - [devtools] Wait for target switching in RDM navigation helpers r=Honza
Wait for target available to be fully processed by responsive UI in tests Differential Revision: https://phabricator.services.mozilla.com/D123326
This commit is contained in:
parent
eb00182e36
commit
077a35b79f
@ -607,9 +607,15 @@ function waitForViewportScroll(ui) {
|
||||
}
|
||||
|
||||
async function load(browser, url) {
|
||||
const loaded = BrowserTestUtils.browserLoaded(browser, false, null, false);
|
||||
const onBrowserLoaded = BrowserTestUtils.browserLoaded(
|
||||
browser,
|
||||
false,
|
||||
null,
|
||||
false
|
||||
);
|
||||
const onTargetSwitch = waitForTargetSwitch(browser);
|
||||
BrowserTestUtils.loadURI(browser, url);
|
||||
await loaded;
|
||||
await Promise.all([onBrowserLoaded, onTargetSwitch]);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -622,15 +628,32 @@ async function reloadViewport(ui) {
|
||||
}
|
||||
|
||||
function back(browser) {
|
||||
const shown = waitForPageShow(browser);
|
||||
const promises = [waitForTargetSwitch(browser), waitForPageShow(browser)];
|
||||
browser.goBack();
|
||||
return shown;
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
function forward(browser) {
|
||||
const shown = waitForPageShow(browser);
|
||||
const promises = [waitForTargetSwitch(browser), waitForPageShow(browser)];
|
||||
browser.goForward();
|
||||
return shown;
|
||||
return Promise.all(promises);
|
||||
}
|
||||
|
||||
async function waitForTargetSwitch(browser) {
|
||||
const targetSwitchDisabled = !isServerTargetSwitchingEnabled();
|
||||
if (targetSwitchDisabled) {
|
||||
// If server-side target switching is disabled assume no target switch.
|
||||
return;
|
||||
}
|
||||
|
||||
const tab = gBrowser.getTabForBrowser(browser);
|
||||
const ui = ResponsiveUIManager.getResponsiveUIForTab(tab);
|
||||
if (!ui) {
|
||||
return;
|
||||
}
|
||||
|
||||
info("Waiting for Responsive UI target switch");
|
||||
await ui.once("responsive-ui-target-switch-done");
|
||||
}
|
||||
|
||||
function addDeviceForTest(device) {
|
||||
|
@ -1049,6 +1049,7 @@ class ResponsiveUI {
|
||||
}
|
||||
|
||||
await this.restoreActorState(isTargetSwitching);
|
||||
this.emitForTests("responsive-ui-target-switch-done");
|
||||
}
|
||||
}
|
||||
// This just needed to setup watching for network resources,
|
||||
|
@ -642,7 +642,7 @@ function isFissionEnabled() {
|
||||
}
|
||||
|
||||
function isServerTargetSwitchingEnabled() {
|
||||
return Services.prefs.getBoolPref("devtools.target-switching.server.enabled");
|
||||
return Services.prefs.getBoolPref(TARGET_SWITCHING_PREF);
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
Reference in New Issue
Block a user