|
1 /* Any copyright is dedicated to the Public Domain. |
|
2 http://creativecommons.org/publicdomain/zero/1.0/ */ |
|
3 |
|
4 // Test that the fix for bug 687710 isn't too aggressive -- shentries which are |
|
5 // cousins should be able to share bfcache entries. |
|
6 |
|
7 let stateBackup = ss.getBrowserState(); |
|
8 |
|
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 ]}; |
|
23 |
|
24 function test() |
|
25 { |
|
26 waitForExplicitFinish(); |
|
27 |
|
28 registerCleanupFunction(function () { |
|
29 ss.setBrowserState(stateBackup); |
|
30 }); |
|
31 |
|
32 let tab = gBrowser.addTab("about:blank"); |
|
33 waitForTabState(tab, state, function () { |
|
34 let history = tab.linkedBrowser.webNavigation.sessionHistory; |
|
35 |
|
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 } |
|
42 |
|
43 finish(); |
|
44 }); |
|
45 } |
|
46 |
|
47 function compareEntries(i, j, history) |
|
48 { |
|
49 let e1 = history.getEntryAtIndex(i, false) |
|
50 .QueryInterface(Ci.nsISHEntry) |
|
51 .QueryInterface(Ci.nsISHContainer); |
|
52 |
|
53 let e2 = history.getEntryAtIndex(j, false) |
|
54 .QueryInterface(Ci.nsISHEntry) |
|
55 .QueryInterface(Ci.nsISHContainer); |
|
56 |
|
57 ok(e1.sharesDocumentWith(e2), |
|
58 i + ' should share doc with ' + j); |
|
59 is(e1.childCount, e2.childCount, |
|
60 'Child count mismatch (' + i + ', ' + j + ')'); |
|
61 |
|
62 for (let c = 0; c < e1.childCount; c++) { |
|
63 let c1 = e1.GetChildAt(c); |
|
64 let c2 = e2.GetChildAt(c); |
|
65 |
|
66 ok(c1.sharesDocumentWith(c2), |
|
67 'Cousins should share documents. (' + i + ', ' + j + ', ' + c + ')'); |
|
68 } |
|
69 } |