Bug 1715012 - [devtools] Use gBrowser.reloadTab in navigateTo when the provided URL is the same as the current one. r=ochameau.

In Bug 1710582, `refreshTab` switched to use `navigateTo` in order to handle target switching.
The catch is that `navigateTo` uses `BrowserTestUtils.loadURI`, which triggers a slightly
different behavior than `gBrowser.reloadTab` (for example, it does not keep the scroll position).
In this patch, we modify `navigateTo` so it uses `reloadTab` if the URL provided for
the navigation is the same as the current one.

Differential Revision: https://phabricator.services.mozilla.com/D117018
This commit is contained in:
Nicolas Chevobbe 2021-06-07 16:12:45 +00:00
Родитель 91720f0159
Коммит 412f5b015d
1 изменённых файлов: 8 добавлений и 1 удалений

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

@ -499,7 +499,14 @@ async function navigateTo(uri, { isErrorPage = false } = {}) {
},
isErrorPage
);
BrowserTestUtils.loadURI(browser, uri);
// if we're navigating to the same page we're already on, use reloadTab instead as the
// behavior slightly differs from loadURI (e.g. scroll position isn't keps with the latter).
if (uri === browser.currentURI.spec) {
gBrowser.reloadTab(gBrowser.selectedTab);
} else {
BrowserTestUtils.loadURI(browser, uri);
}
info(`Waiting for page to be loaded…`);
await onBrowserLoaded;