Bug 1710582 - [devtools] Make refreshTab test helper wait for target switching. r=nchevobbe

navigateTo contains all the logic to wait for panel updates on reload,
as well as wait for the process of the new target.

Differential Revision: https://phabricator.services.mozilla.com/D114828
This commit is contained in:
Alexandre Poirot 2021-06-01 11:40:31 +00:00
Родитель a4b5e6b006
Коммит 21aafa8249
2 изменённых файлов: 14 добавлений и 4 удалений

Просмотреть файл

@ -54,7 +54,7 @@ const DESCRIPTION = {
};
this.test = makeMemoryTest(TEST_URL, async function({ tab, panel }) {
const front = panel.panelWin.gStore.getState().front;
let front = panel.panelWin.gStore.getState().front;
const startWindows = await getWindowsInSnapshot(front);
dumpn(
@ -65,6 +65,9 @@ this.test = makeMemoryTest(TEST_URL, async function({ tab, panel }) {
await refreshTab();
// Update the front as we may have switched to a new target and a new memory front
front = panel.panelWin.gStore.getState().front;
const endWindows = await getWindowsInSnapshot(front);
is(endWindows.length, 1);

Просмотреть файл

@ -429,9 +429,16 @@ var removeTab = async function(tab) {
*/
var refreshTab = async function(tab = gBrowser.selectedTab) {
info("Refreshing tab.");
const finished = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
gBrowser.reloadTab(tab);
await finished;
// Use navigateTo if there is a toolbox opened, and wait for panels to update after reload.
// Otherwise only wait for the tab's document to be loaded.
const isKnownTab = TabDescriptorFactory.isKnownTab(tab);
if (isKnownTab) {
await navigateTo(tab.linkedBrowser.currentURI.spec);
} else {
const finished = BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
gBrowser.reloadTab(tab);
await finished;
}
info("Tab finished refreshing.");
};