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.

     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   });
    60 }

mercurial