Bug 1338312 - browser.sessions.getRecentlyClosed returns incorrect information for tabs in closed windows, r=aswan

MozReview-Commit-ID: FrUhiR9Q9aV

--HG--
extra : rebase_source : 10eabf425631f2d39eecc595b57fb7966eb168fd
This commit is contained in:
Bob Silverberg 2017-02-14 15:23:46 -05:00
Родитель f604ffe72d
Коммит 8eebddf88e
2 изменённых файлов: 36 добавлений и 2 удалений

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

@ -544,8 +544,9 @@ class Tab extends TabBase {
if (extension.tabManager.hasTabPermission(tabData)) {
let entries = tabData.state ? tabData.state.entries : tabData.entries;
result.url = entries[0].url;
result.title = entries[0].title;
let entry = entries[entries.length - 1];
result.url = entry.url;
result.title = entry.title;
if (tabData.image) {
result.favIconUrl = tabData.image;
}

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

@ -95,3 +95,36 @@ add_task(function* test_sessions_get_recently_closed() {
yield extension.unload();
});
add_task(function* test_sessions_get_recently_closed_navigated() {
function background() {
browser.sessions.getRecentlyClosed({maxResults: 1}).then(recentlyClosed => {
let tab = recentlyClosed[0].window.tabs[0];
browser.test.assertEq("http://example.com/", tab.url,
"Tab in closed window has the expected url.");
browser.test.assertTrue(tab.title.includes("mochitest index"),
"Tab in closed window has the expected title.");
browser.test.notifyPass("getRecentlyClosed with navigation");
});
}
let extension = ExtensionTestUtils.loadExtension({
manifest: {
permissions: ["sessions", "tabs"],
},
background,
});
// Test with a window with navigation history.
let win = yield BrowserTestUtils.openNewBrowserWindow();
for (let url of ["about:robots", "about:mozilla", "http://example.com/"]) {
yield BrowserTestUtils.loadURI(win.gBrowser.selectedBrowser, url);
yield BrowserTestUtils.browserLoaded(win.gBrowser.selectedBrowser);
}
yield BrowserTestUtils.closeWindow(win);
yield extension.startup();
yield extension.awaitFinish();
yield extension.unload();
});