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.

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

mercurial