Bug 670318 - Google+ home page creates multiple SHEntries, and if you go back to the first one, you can no longer go forward; r=smaug

This commit is contained in:
Tim Taubert 2011-08-01 23:45:45 +02:00
parent ef48533bbc
commit 6f626c2d9a
4 changed files with 87 additions and 0 deletions

View File

@ -1284,6 +1284,9 @@ nsSHistory::RemoveDuplicate(PRInt32 aIndex, PRBool aKeepNext)
if (mIndex > aIndex) {
mIndex = mIndex - 1;
}
if (mRequestedIndex > aIndex) {
mRequestedIndex = mRequestedIndex - 1;
}
--mLength;
return PR_TRUE;
}

View File

@ -62,6 +62,8 @@ _BROWSER_TEST_FILES = \
browser_bug655270.js \
file_bug655270.html \
favicon_bug655270.ico \
browser_bug670318.js \
file_bug670318.html \
$(NULL)
libs:: $(_BROWSER_TEST_FILES)

View File

@ -0,0 +1,59 @@
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
/**
* Test for Bug 670318
*
* When LoadEntry() is called on a browser that has multiple duplicate history
* entries, history.index can end up out of range (>= history.count).
*/
const URL = "http://mochi.test:8888/browser/docshell/test/browser/file_bug670318.html";
function test() {
waitForExplicitFinish();
let count = 0, historyListenerRemoved = false;
let listener = {
OnHistoryNewEntry: function (aNewURI) {
if (aNewURI.spec == URL && 5 == ++count) {
browser.addEventListener("load", function onLoad() {
browser.removeEventListener("load", onLoad, true);
ok(history.index < history.count, "history.index is valid");
finish();
}, true);
history.removeSHistoryListener(listener);
historyListenerRemoved = true;
executeSoon(function () BrowserReload());
}
return true;
},
OnHistoryReload: function () true,
OnHistoryGoBack: function () true,
OnHistoryGoForward: function () true,
OnHistoryGotoIndex: function () true,
OnHistoryPurge: function () true,
QueryInterface: XPCOMUtils.generateQI([Ci.nsISHistoryListener,
Ci.nsISupportsWeakReference])
};
let tab = gBrowser.loadOneTab(URL, {inBackground: false});
let browser = tab.linkedBrowser;
let history = browser.sessionHistory;
history.addSHistoryListener(listener);
registerCleanupFunction(function () {
gBrowser.removeTab(tab);
if (!historyListenerRemoved)
history.removeSHistoryListener(listener);
});
}

View File

@ -0,0 +1,23 @@
<html><head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<script>
function load() {
function next() {
if (count < 5)
iframe.src = 'data:text/html,iframe ' + (++count);
}
var count = 0;
var iframe = document.createElement('iframe');
iframe.onload = function () { setTimeout(next, 0) };
document.body.appendChild(iframe);
setTimeout(next, 0);
}
</script>
</head>
<body onload="load()">
Testcase
</body>
</html>