зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1375546 - Fix sessions.getRecentlyClosed to consider the current tab history index, r=mikedeboer,mixedpuppy
If the back button is used to navigate a tab backwards in its history, and then the tab is closed, the current implementation of sessions.getRecentlyClosed does not take this into account and just uses the last item in the tab history for the values returned for the tab. This patch fixes this by using the values for the current position of the tab in its history. MozReview-Commit-ID: LcgtA5FqVWi --HG-- extra : rebase_source : 3b8cd840fd30305471feec643f77d57378bd40d7
This commit is contained in:
Родитель
d86c9b8d16
Коммит
597114a565
|
@ -665,7 +665,10 @@ class Tab extends TabBase {
|
|||
|
||||
if (extension.tabManager.hasTabPermission(tabData)) {
|
||||
let entries = tabData.state ? tabData.state.entries : tabData.entries;
|
||||
let entry = entries[entries.length - 1];
|
||||
let lastTabIndex = tabData.state ? tabData.state.index : tabData.index;
|
||||
// We need to take lastTabIndex - 1 because the index in the tab data is
|
||||
// 1-based rather than 0-based.
|
||||
let entry = entries[lastTabIndex - 1];
|
||||
result.url = entry.url;
|
||||
result.title = entry.title;
|
||||
if (tabData.image) {
|
||||
|
|
|
@ -38,8 +38,19 @@ add_task(async function test_sessions_get_recently_closed_tabs() {
|
|||
});
|
||||
|
||||
let win = await BrowserTestUtils.openNewBrowserWindow();
|
||||
await BrowserTestUtils.loadURI(win.gBrowser.selectedBrowser, "about:mozilla");
|
||||
await BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
|
||||
let tabBrowser = win.gBrowser.selectedBrowser;
|
||||
for (let url of ["about:robots", "about:mozilla", "about:config"]) {
|
||||
await BrowserTestUtils.loadURI(tabBrowser, url);
|
||||
await BrowserTestUtils.browserLoaded(tabBrowser, false, url);
|
||||
}
|
||||
|
||||
// Ensure that getRecentlyClosed returns correct results after the back
|
||||
// button has been used.
|
||||
let goBackPromise = BrowserTestUtils.waitForLocationChange(
|
||||
win.gBrowser, "about:mozilla");
|
||||
tabBrowser.goBack();
|
||||
await goBackPromise;
|
||||
|
||||
let expectedTabs = [];
|
||||
let tab = win.gBrowser.selectedTab;
|
||||
// Because there is debounce logic in ContentLinkHandler.jsm to reduce the
|
||||
|
|
Загрузка…
Ссылка в новой задаче