Bumping manifests a=b2g-bump
[gecko.git] / docshell / test / browser / browser_bug670318.js
blob1ca2077365b48b705c537af1051fcdd2c9ca5b2f
1 /* Any copyright is dedicated to the Public Domain.
2    http://creativecommons.org/publicdomain/zero/1.0/ */
4 /**
5  * Test for Bug 670318
6  *
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).
9  */
11 const URL = "http://mochi.test:8888/browser/docshell/test/browser/file_bug670318.html";
13 function test() {
14   waitForExplicitFinish();
16   let count = 0, historyListenerRemoved = false;
18   let listener = {
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");
25           finish();
26         }, true);
28         history.removeSHistoryListener(listener);
29         historyListenerRemoved = true;
31         executeSoon(function () BrowserReload());
32       }
34       return true;
35     },
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])
46   };
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);
59   });