browser/components/sessionstore/test/browser_687710_2.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 // Test that the fix for bug 687710 isn't too aggressive -- shentries which are
     5 // cousins should be able to share bfcache entries.
     7 let stateBackup = ss.getBrowserState();
     9 let state = {entries:[
    10   {
    11     docIdentifier: 1,
    12     url: "http://example.com?1",
    13     children: [{ docIdentifier: 10,
    14                  url: "http://example.com?10" }]
    15   },
    16   {
    17     docIdentifier: 1,
    18     url: "http://example.com?1#a",
    19     children: [{ docIdentifier: 10,
    20                  url: "http://example.com?10#aa" }]
    21   }
    22 ]};
    24 function test()
    25 {
    26   waitForExplicitFinish();
    28   registerCleanupFunction(function () {
    29     ss.setBrowserState(stateBackup);
    30   });
    32   let tab = gBrowser.addTab("about:blank");
    33   waitForTabState(tab, state, function () {
    34     let history = tab.linkedBrowser.webNavigation.sessionHistory;
    36     is(history.count, 2, "history.count");
    37     for (let i = 0; i < history.count; i++) {
    38       for (let j = 0; j < history.count; j++) {
    39         compareEntries(i, j, history);
    40       }
    41     }
    43     finish();
    44   });
    45 }
    47 function compareEntries(i, j, history)
    48 {
    49   let e1 = history.getEntryAtIndex(i, false)
    50                   .QueryInterface(Ci.nsISHEntry)
    51                   .QueryInterface(Ci.nsISHContainer);
    53   let e2 = history.getEntryAtIndex(j, false)
    54                   .QueryInterface(Ci.nsISHEntry)
    55                   .QueryInterface(Ci.nsISHContainer);
    57   ok(e1.sharesDocumentWith(e2),
    58      i + ' should share doc with ' + j);
    59   is(e1.childCount, e2.childCount,
    60      'Child count mismatch (' + i + ', ' + j + ')');
    62   for (let c = 0; c < e1.childCount; c++) {
    63     let c1 = e1.GetChildAt(c);
    64     let c2 = e2.GetChildAt(c);
    66     ok(c1.sharesDocumentWith(c2),
    67        'Cousins should share documents. (' + i + ', ' + j + ', ' + c + ')');
    68   }
    69 }

mercurial