michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Test that the fix for bug 687710 isn't too aggressive -- shentries which are michael@0: // cousins should be able to share bfcache entries. michael@0: michael@0: let stateBackup = ss.getBrowserState(); michael@0: michael@0: let state = {entries:[ michael@0: { michael@0: docIdentifier: 1, michael@0: url: "http://example.com?1", michael@0: children: [{ docIdentifier: 10, michael@0: url: "http://example.com?10" }] michael@0: }, michael@0: { michael@0: docIdentifier: 1, michael@0: url: "http://example.com?1#a", michael@0: children: [{ docIdentifier: 10, michael@0: url: "http://example.com?10#aa" }] michael@0: } michael@0: ]}; michael@0: michael@0: function test() michael@0: { michael@0: waitForExplicitFinish(); michael@0: michael@0: registerCleanupFunction(function () { michael@0: ss.setBrowserState(stateBackup); michael@0: }); michael@0: michael@0: let tab = gBrowser.addTab("about:blank"); michael@0: waitForTabState(tab, state, function () { michael@0: let history = tab.linkedBrowser.webNavigation.sessionHistory; michael@0: michael@0: is(history.count, 2, "history.count"); michael@0: for (let i = 0; i < history.count; i++) { michael@0: for (let j = 0; j < history.count; j++) { michael@0: compareEntries(i, j, history); michael@0: } michael@0: } michael@0: michael@0: finish(); michael@0: }); michael@0: } michael@0: michael@0: function compareEntries(i, j, history) michael@0: { michael@0: let e1 = history.getEntryAtIndex(i, false) michael@0: .QueryInterface(Ci.nsISHEntry) michael@0: .QueryInterface(Ci.nsISHContainer); michael@0: michael@0: let e2 = history.getEntryAtIndex(j, false) michael@0: .QueryInterface(Ci.nsISHEntry) michael@0: .QueryInterface(Ci.nsISHContainer); michael@0: michael@0: ok(e1.sharesDocumentWith(e2), michael@0: i + ' should share doc with ' + j); michael@0: is(e1.childCount, e2.childCount, michael@0: 'Child count mismatch (' + i + ', ' + j + ')'); michael@0: michael@0: for (let c = 0; c < e1.childCount; c++) { michael@0: let c1 = e1.GetChildAt(c); michael@0: let c2 = e2.GetChildAt(c); michael@0: michael@0: ok(c1.sharesDocumentWith(c2), michael@0: 'Cousins should share documents. (' + i + ', ' + j + ', ' + c + ')'); michael@0: } michael@0: }