Bug 1160556 - Recollect session history data when the page title changes r=Gijs

This commit is contained in:
Tim Taubert 2015-05-05 16:00:12 +02:00
parent 0604dd048f
commit f2eaecef00
4 changed files with 48 additions and 0 deletions

View File

@ -265,6 +265,9 @@ let SessionHistoryListener = {
if (!SessionHistory.isEmpty(docShell)) {
this.collect();
}
// Listen for page title changes.
addEventListener("DOMTitleChanged", this);
},
uninit: function () {
@ -280,6 +283,10 @@ let SessionHistoryListener = {
}
},
handleEvent(event) {
this.collect();
},
onFrameTreeCollected: function () {
this.collect();
},

View File

@ -88,6 +88,7 @@ skip-if = buildapp == 'mulet'
[browser_history_persist.js]
[browser_label_and_icon.js]
[browser_merge_closed_tabs.js]
[browser_page_title.js]
[browser_pageStyle.js]
[browser_privatetabs.js]
[browser_replace_load.js]

View File

@ -0,0 +1,38 @@
"use strict";
const URL = "data:text/html,<title>initial title</title>";
add_task(function* () {
// Create a new tab.
let tab = gBrowser.addTab(URL);
yield promiseBrowserLoaded(tab.linkedBrowser);
// Remove the tab.
yield promiseRemoveTab(tab);
// Check the title.
let [{state: {entries}}] = JSON.parse(ss.getClosedTabData(window));
is(entries[0].title, "initial title", "correct title");
});
add_task(function* () {
// Create a new tab.
let tab = gBrowser.addTab(URL);
let browser = tab.linkedBrowser;
yield promiseBrowserLoaded(browser);
// Flush to ensure we collected the initial title.
TabState.flush(browser);
// Set a new title.
yield ContentTask.spawn(browser, null, function* () {
content.document.title = "new title";
});
// Remove the tab.
yield promiseRemoveTab(tab);
// Check the title.
let [{state: {entries}}] = JSON.parse(ss.getClosedTabData(window));
is(entries[0].title, "new title", "correct title");
});

View File

@ -528,6 +528,8 @@ for (let name of FORM_HELPERS) {
this[name] = (browser, data) => sendMessage(browser, msg, data);
}
// Removes the given tab immediately and returns a promise that resolves when
// all pending status updates (messages) of the closing tab have been received.
function promiseRemoveTab(tab) {
return BrowserTestUtils.removeTab(tab);
}