Bug 447951 - Gmail displays wrong/previous URL on session restore after heavy usage (50 hash changes). r=dietrich

This commit is contained in:
Simon Bünzli 2009-02-19 14:09:54 +01:00
Родитель b6c2a8283b
Коммит 87b9fb5cdb
4 изменённых файлов: 98 добавлений и 1 удалений

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

@ -200,6 +200,10 @@ SessionStoreService.prototype = {
// observe prefs changes so we can modify stored data to match
this._prefBranch.addObserver("sessionstore.max_tabs_undo", this, true);
// this pref is only read at startup, so no need to observe it
this._sessionhistory_max_entries =
this._prefBranch.getIntPref("sessionhistory.max_entries");
// get file references
var dirService = Cc["@mozilla.org/file/directory_service;1"].
@ -1007,8 +1011,11 @@ SessionStoreService.prototype = {
}
catch (ex) { } // this could happen if we catch a tab during (de)initialization
// XXXzeniko anchor navigation doesn't reset __SS_data, so we could reuse
// data even when we shouldn't (e.g. Back, different anchor)
if (history && browser.parentNode.__SS_data &&
browser.parentNode.__SS_data.entries[history.index] && !aFullData) {
browser.parentNode.__SS_data.entries[history.index] &&
history.index < this._sessionhistory_max_entries - 1 && !aFullData) {
tabData = browser.parentNode.__SS_data;
tabData.index = history.index + 1;
}

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

@ -58,6 +58,8 @@ _BROWSER_TEST_FILES = \
browser_393716.js \
browser_408470.js \
browser_408470_sample.html \
browser_447951.js \
browser_447951_sample.html \
browser_448741.js \
browser_454908.js \
browser_454908_sample.html \

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

@ -0,0 +1,84 @@
/* ***** BEGIN LICENSE BLOCK *****
* Version: MPL 1.1/GPL 2.0/LGPL 2.1
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
* http://www.mozilla.org/MPL/
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
* for the specific language governing rights and limitations under the
* License.
*
* The Original Code is sessionstore test code.
*
* The Initial Developer of the Original Code is
* Simon Bünzli <zeniko@gmail.com>.
* Portions created by the Initial Developer are Copyright (C) 2008
* the Initial Developer. All Rights Reserved.
*
* Contributor(s):
*
* Alternatively, the contents of this file may be used under the terms of
* either the GNU General Public License Version 2 or later (the "GPL"), or
* the GNU Lesser General Public License Version 2.1 or later (the "LGPL"),
* in which case the provisions of the GPL or the LGPL are applicable instead
* of those above. If you wish to allow use of your version of this file only
* under the terms of either the GPL or the LGPL, and not to allow others to
* use your version of this file under the terms of the MPL, indicate your
* decision by deleting the provisions above and replace them with the notice
* and other provisions required by the GPL or the LGPL. If you do not delete
* the provisions above, a recipient may use your version of this file under
* the terms of any one of the MPL, the GPL or the LGPL.
*
* ***** END LICENSE BLOCK ***** */
function test() {
/** Test for Bug 447951 **/
// test setup
let ss = Cc["@mozilla.org/browser/sessionstore;1"].getService(Ci.nsISessionStore);
waitForExplicitFinish();
const baseURL = "http://localhost:8888/browser/" +
"browser/components/sessionstore/test/browser/browser_447951_sample.html#";
let tab = gBrowser.addTab();
tab.linkedBrowser.addEventListener("load", function(aEvent) {
this.removeEventListener("load", arguments.callee, true);
let tabState = { entries: [] };
let max_entries = gPrefService.getIntPref("browser.sessionhistory.max_entries");
for (let i = 0; i < max_entries; i++)
tabState.entries.push({ url: baseURL + i });
ss.setTabState(tab, JSON.stringify(tabState));
tab.addEventListener("SSTabRestored", function(aEvent) {
this.removeEventListener("SSTabRestored", arguments.callee, false);
tabState = eval("(" + ss.getTabState(tab) + ")");
is(tabState.entries.length, max_entries, "session history filled to the limit");
is(tabState.entries[0].url, baseURL + 0, "... but not more");
// visit yet another anchor (appending it to session history)
let doc = tab.linkedBrowser.contentDocument;
let event = doc.createEvent("MouseEvents");
event.initMouseEvent("click", true, true, doc.defaultView, 1,
0, 0, 0, 0, false, false, false, false, 0, null);
doc.querySelector("a").dispatchEvent(event);
executeSoon(function() {
tabState = eval("(" + ss.getTabState(tab) + ")");
is(tab.linkedBrowser.currentURI.spec, baseURL + "end",
"the new anchor was loaded");
is(tabState.entries[tabState.entries.length - 1].url, baseURL + "end",
"... and ignored");
is(tabState.entries[0].url, baseURL + 1,
"... and the first item was removed");
// clean up
gBrowser.removeTab(tab);
finish();
});
}, false);
}, true);
}

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

@ -0,0 +1,4 @@
<!DOCTYPE html>
<title>Testcase for bug 447951</title>
<a href="#end">click me</a>