mirror of
https://gitlab.winehq.org/wine/wine-gecko.git
synced 2024-09-13 09:24:08 -07:00
Bug 961016 - Fix icon and label for pending tabs with async restore r=billm,dao
From 6028548aa44e6d289c0fb5e756a4004451ea882b Mon Sep 17 00:00:00 2001
This commit is contained in:
parent
f41c504216
commit
c328b3d5fc
@ -2960,7 +2960,7 @@
|
||||
switch (aMessage.name) {
|
||||
case "DOMTitleChanged": {
|
||||
let tab = this._getTabForBrowser(browser);
|
||||
if (!tab)
|
||||
if (!tab || tab.hasAttribute("pending"))
|
||||
return;
|
||||
let titleChanged = this.setTabTitle(tab);
|
||||
if (titleChanged && !tab.selected && !tab.hasAttribute("busy"))
|
||||
@ -3203,6 +3203,9 @@
|
||||
return;
|
||||
|
||||
var tab = this._getTabForContentWindow(contentWin);
|
||||
if (tab.hasAttribute("pending"))
|
||||
return;
|
||||
|
||||
var titleChanged = this.setTabTitle(tab);
|
||||
if (titleChanged && !tab.selected && !tab.hasAttribute("busy"))
|
||||
tab.setAttribute("titlechanged", "true");
|
||||
|
@ -142,7 +142,6 @@ ContentRestoreInternal.prototype = {
|
||||
SessionHistory.restore(this.docShell, tabData);
|
||||
|
||||
// Add a listener to watch for reloads.
|
||||
let webNavigation = this.docShell.QueryInterface(Ci.nsIWebNavigation);
|
||||
let listener = new HistoryListener(this.docShell, reloadCallback);
|
||||
webNavigation.sessionHistory.addSHistoryListener(listener);
|
||||
this._historyListener = listener;
|
||||
|
@ -629,6 +629,30 @@ let SessionStoreInternal = {
|
||||
if (this.isCurrentEpoch(browser, aMessage.data.epoch)) {
|
||||
// Notify the tabbrowser that the tab chrome has been restored.
|
||||
let tab = this._getTabForBrowser(browser);
|
||||
let tabData = browser.__SS_data;
|
||||
|
||||
// wall-paper fix for bug 439675: make sure that the URL to be loaded
|
||||
// is always visible in the address bar
|
||||
let activePageData = tabData.entries[tabData.index - 1] || null;
|
||||
let uri = activePageData ? activePageData.url || null : null;
|
||||
browser.userTypedValue = uri;
|
||||
|
||||
// If the page has a title, set it.
|
||||
if (activePageData) {
|
||||
if (activePageData.title) {
|
||||
tab.label = activePageData.title;
|
||||
tab.crop = "end";
|
||||
} else if (activePageData.url != "about:blank") {
|
||||
tab.label = activePageData.url;
|
||||
tab.crop = "center";
|
||||
}
|
||||
}
|
||||
|
||||
// Restore the tab icon.
|
||||
if ("image" in tabData) {
|
||||
win.gBrowser.setIcon(tab, tabData.image);
|
||||
}
|
||||
|
||||
let event = win.document.createEvent("Events");
|
||||
event.initEvent("SSTabRestoring", true, false);
|
||||
tab.dispatchEvent(event);
|
||||
@ -2722,33 +2746,11 @@ let SessionStoreInternal = {
|
||||
browser.messageManager.sendAsyncMessage("SessionStore:restoreHistory",
|
||||
{tabData: tabData, epoch: epoch});
|
||||
|
||||
// wall-paper fix for bug 439675: make sure that the URL to be loaded
|
||||
// is always visible in the address bar
|
||||
let activePageData = tabData.entries[activeIndex] || null;
|
||||
let uri = activePageData ? activePageData.url || null : null;
|
||||
browser.userTypedValue = uri;
|
||||
|
||||
// If the page has a title, set it.
|
||||
if (activePageData) {
|
||||
if (activePageData.title) {
|
||||
tab.label = activePageData.title;
|
||||
tab.crop = "end";
|
||||
} else if (activePageData.url != "about:blank") {
|
||||
tab.label = activePageData.url;
|
||||
tab.crop = "center";
|
||||
}
|
||||
}
|
||||
|
||||
// Restore tab attributes.
|
||||
if ("attributes" in tabData) {
|
||||
TabAttributes.set(tab, tabData.attributes);
|
||||
}
|
||||
|
||||
// Restore the tab icon.
|
||||
if ("image" in tabData) {
|
||||
tabbrowser.setIcon(tab, tabData.image);
|
||||
}
|
||||
|
||||
// This could cause us to ignore MAX_CONCURRENT_TAB_RESTORES a bit, but
|
||||
// it ensures each window will have its selected tab loaded.
|
||||
if (aRestoreImmediately || tabbrowser.selectedBrowser == browser) {
|
||||
|
@ -62,6 +62,7 @@ support-files =
|
||||
[browser_formdata_xpath.js]
|
||||
[browser_frametree.js]
|
||||
[browser_global_store.js]
|
||||
[browser_label_and_icon.js]
|
||||
[browser_merge_closed_tabs.js]
|
||||
[browser_pageshow.js]
|
||||
[browser_pageStyle.js]
|
||||
|
@ -0,0 +1,55 @@
|
||||
/* Any copyright is dedicated to the Public Domain.
|
||||
* http://creativecommons.org/publicdomain/zero/1.0/ */
|
||||
|
||||
"use strict";
|
||||
|
||||
/**
|
||||
* Make sure that tabs are restored on demand as otherwise the tab will start
|
||||
* loading immediately and we can't check its icon and label.
|
||||
*/
|
||||
add_task(function setup() {
|
||||
Services.prefs.setBoolPref("browser.sessionstore.restore_on_demand", true);
|
||||
|
||||
registerCleanupFunction(() => {
|
||||
Services.prefs.clearUserPref("browser.sessionstore.restore_on_demand");
|
||||
});
|
||||
});
|
||||
|
||||
/**
|
||||
* Ensure that a pending tab has label and icon correctly set.
|
||||
*/
|
||||
add_task(function test_label_and_icon() {
|
||||
// Create a new tab.
|
||||
let tab = gBrowser.addTab("about:robots");
|
||||
let browser = tab.linkedBrowser;
|
||||
yield promiseBrowserLoaded(browser);
|
||||
|
||||
// Retrieve the tab state.
|
||||
SyncHandlers.get(browser).flush();
|
||||
let state = ss.getTabState(tab);
|
||||
gBrowser.removeTab(tab);
|
||||
browser = null;
|
||||
|
||||
// Open a new tab to restore into.
|
||||
let tab = gBrowser.addTab("about:blank");
|
||||
ss.setTabState(tab, state);
|
||||
yield promiseTabRestoring(tab);
|
||||
|
||||
// Check that label and icon are set for the restoring tab.
|
||||
ok(gBrowser.getIcon(tab).startsWith("data:image/png;"), "icon is set");
|
||||
is(tab.label, "Gort! Klaatu barada nikto!", "label is set");
|
||||
|
||||
// Cleanup.
|
||||
gBrowser.removeTab(tab);
|
||||
});
|
||||
|
||||
function promiseTabRestoring(tab) {
|
||||
let deferred = Promise.defer();
|
||||
|
||||
tab.addEventListener("SSTabRestoring", function onRestoring() {
|
||||
tab.removeEventListener("SSTabRestoring", onRestoring);
|
||||
deferred.resolve();
|
||||
});
|
||||
|
||||
return deferred.promise;
|
||||
}
|
Loading…
Reference in New Issue
Block a user