1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/components/sessionstore/test/browser_687710_2.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,69 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +// Test that the fix for bug 687710 isn't too aggressive -- shentries which are 1.8 +// cousins should be able to share bfcache entries. 1.9 + 1.10 +let stateBackup = ss.getBrowserState(); 1.11 + 1.12 +let state = {entries:[ 1.13 + { 1.14 + docIdentifier: 1, 1.15 + url: "http://example.com?1", 1.16 + children: [{ docIdentifier: 10, 1.17 + url: "http://example.com?10" }] 1.18 + }, 1.19 + { 1.20 + docIdentifier: 1, 1.21 + url: "http://example.com?1#a", 1.22 + children: [{ docIdentifier: 10, 1.23 + url: "http://example.com?10#aa" }] 1.24 + } 1.25 +]}; 1.26 + 1.27 +function test() 1.28 +{ 1.29 + waitForExplicitFinish(); 1.30 + 1.31 + registerCleanupFunction(function () { 1.32 + ss.setBrowserState(stateBackup); 1.33 + }); 1.34 + 1.35 + let tab = gBrowser.addTab("about:blank"); 1.36 + waitForTabState(tab, state, function () { 1.37 + let history = tab.linkedBrowser.webNavigation.sessionHistory; 1.38 + 1.39 + is(history.count, 2, "history.count"); 1.40 + for (let i = 0; i < history.count; i++) { 1.41 + for (let j = 0; j < history.count; j++) { 1.42 + compareEntries(i, j, history); 1.43 + } 1.44 + } 1.45 + 1.46 + finish(); 1.47 + }); 1.48 +} 1.49 + 1.50 +function compareEntries(i, j, history) 1.51 +{ 1.52 + let e1 = history.getEntryAtIndex(i, false) 1.53 + .QueryInterface(Ci.nsISHEntry) 1.54 + .QueryInterface(Ci.nsISHContainer); 1.55 + 1.56 + let e2 = history.getEntryAtIndex(j, false) 1.57 + .QueryInterface(Ci.nsISHEntry) 1.58 + .QueryInterface(Ci.nsISHContainer); 1.59 + 1.60 + ok(e1.sharesDocumentWith(e2), 1.61 + i + ' should share doc with ' + j); 1.62 + is(e1.childCount, e2.childCount, 1.63 + 'Child count mismatch (' + i + ', ' + j + ')'); 1.64 + 1.65 + for (let c = 0; c < e1.childCount; c++) { 1.66 + let c1 = e1.GetChildAt(c); 1.67 + let c2 = e2.GetChildAt(c); 1.68 + 1.69 + ok(c1.sharesDocumentWith(c2), 1.70 + 'Cousins should share documents. (' + i + ', ' + j + ', ' + c + ')'); 1.71 + } 1.72 +}