docshell/test/browser/browser_bug670318.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

michael@0 1 /* Any copyright is dedicated to the Public Domain.
michael@0 2 http://creativecommons.org/publicdomain/zero/1.0/ */
michael@0 3
michael@0 4 /**
michael@0 5 * Test for Bug 670318
michael@0 6 *
michael@0 7 * When LoadEntry() is called on a browser that has multiple duplicate history
michael@0 8 * entries, history.index can end up out of range (>= history.count).
michael@0 9 */
michael@0 10
michael@0 11 const URL = "http://mochi.test:8888/browser/docshell/test/browser/file_bug670318.html";
michael@0 12
michael@0 13 function test() {
michael@0 14 waitForExplicitFinish();
michael@0 15
michael@0 16 let count = 0, historyListenerRemoved = false;
michael@0 17
michael@0 18 let listener = {
michael@0 19 OnHistoryNewEntry: function (aNewURI) {
michael@0 20 if (aNewURI.spec == URL && 5 == ++count) {
michael@0 21 browser.addEventListener("load", function onLoad() {
michael@0 22 browser.removeEventListener("load", onLoad, true);
michael@0 23
michael@0 24 ok(history.index < history.count, "history.index is valid");
michael@0 25 finish();
michael@0 26 }, true);
michael@0 27
michael@0 28 history.removeSHistoryListener(listener);
michael@0 29 historyListenerRemoved = true;
michael@0 30
michael@0 31 executeSoon(function () BrowserReload());
michael@0 32 }
michael@0 33
michael@0 34 return true;
michael@0 35 },
michael@0 36
michael@0 37 OnHistoryReload: function () true,
michael@0 38 OnHistoryGoBack: function () true,
michael@0 39 OnHistoryGoForward: function () true,
michael@0 40 OnHistoryGotoIndex: function () true,
michael@0 41 OnHistoryPurge: function () true,
michael@0 42 OnHistoryReplaceEntry: function () true,
michael@0 43
michael@0 44 QueryInterface: XPCOMUtils.generateQI([Ci.nsISHistoryListener,
michael@0 45 Ci.nsISupportsWeakReference])
michael@0 46 };
michael@0 47
michael@0 48 let tab = gBrowser.loadOneTab(URL, {inBackground: false});
michael@0 49 let browser = tab.linkedBrowser;
michael@0 50 let history = browser.sessionHistory;
michael@0 51
michael@0 52 history.addSHistoryListener(listener);
michael@0 53
michael@0 54 registerCleanupFunction(function () {
michael@0 55 gBrowser.removeTab(tab);
michael@0 56
michael@0 57 if (!historyListenerRemoved)
michael@0 58 history.removeSHistoryListener(listener);
michael@0 59 });
michael@0 60 }

mercurial