1 /* Any copyright is dedicated to the Public Domain.
2 http://creativecommons.org/publicdomain/zero/1.0/ */
7 * When LoadEntry() is called on a browser that has multiple duplicate history
8 * entries, history.index can end up out of range (>= history.count).
11 const URL = "http://mochi.test:8888/browser/docshell/test/browser/file_bug670318.html";
14 waitForExplicitFinish();
16 let count = 0, historyListenerRemoved = false;
19 OnHistoryNewEntry: function (aNewURI) {
20 if (aNewURI.spec == URL && 5 == ++count) {
21 browser.addEventListener("load", function onLoad() {
22 browser.removeEventListener("load", onLoad, true);
24 ok(history.index < history.count, "history.index is valid");
28 history.removeSHistoryListener(listener);
29 historyListenerRemoved = true;
31 executeSoon(function () BrowserReload());
37 OnHistoryReload: function () true,
38 OnHistoryGoBack: function () true,
39 OnHistoryGoForward: function () true,
40 OnHistoryGotoIndex: function () true,
41 OnHistoryPurge: function () true,
42 OnHistoryReplaceEntry: function () true,
44 QueryInterface: XPCOMUtils.generateQI([Ci.nsISHistoryListener,
45 Ci.nsISupportsWeakReference])
48 let tab = gBrowser.loadOneTab(URL, {inBackground: false});
49 let browser = tab.linkedBrowser;
50 let history = browser.sessionHistory;
52 history.addSHistoryListener(listener);
54 registerCleanupFunction(function () {
55 gBrowser.removeTab(tab);
57 if (!historyListenerRemoved)
58 history.removeSHistoryListener(listener);