tor-browser

The Tor Browser
git clone https://git.dasho.dev/tor-browser.git
Log | Files | Refs | README | LICENSE

browser_687710_2.js (2072B)


      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 var stateBackup = ss.getBrowserState();
      8 
      9 var state = {
     10  entries: [
     11    {
     12      docIdentifier: 1,
     13      url: "http://example.com?1",
     14      triggeringPrincipal_base64,
     15      children: [
     16        {
     17          docIdentifier: 10,
     18          url: "http://example.com?10",
     19          triggeringPrincipal_base64,
     20        },
     21      ],
     22    },
     23    {
     24      docIdentifier: 1,
     25      url: "http://example.com?1#a",
     26      triggeringPrincipal_base64,
     27      children: [
     28        {
     29          docIdentifier: 10,
     30          url: "http://example.com?10#aa",
     31          triggeringPrincipal_base64,
     32        },
     33      ],
     34    },
     35  ],
     36 };
     37 
     38 add_task(async function test() {
     39  let tab = BrowserTestUtils.addTab(gBrowser, "about:blank");
     40 
     41  // addTab sends a message to the child to load about:blank, which sends a
     42  // message to the parent to add the SH entry.
     43  // promiseTabState modifies the SH syncronously, so ensure it is settled.
     44  await BrowserTestUtils.browserLoaded(tab.linkedBrowser, {
     45    wantLoad: "about:blank",
     46  });
     47 
     48  await promiseTabState(tab, state);
     49 
     50  function compareEntries(i, j, history) {
     51    let e1 = history.getEntryAtIndex(i);
     52    let e2 = history.getEntryAtIndex(j);
     53 
     54    ok(e1.sharesDocumentWith(e2), `${i} should share doc with ${j}`);
     55    is(e1.childCount, e2.childCount, `Child count mismatch (${i}, ${j})`);
     56 
     57    for (let c = 0; c < e1.childCount; c++) {
     58      let c1 = e1.GetChildAt(c);
     59      let c2 = e2.GetChildAt(c);
     60 
     61      ok(
     62        c1.sharesDocumentWith(c2),
     63        `Cousins should share documents. (${i}, ${j}, ${c})`
     64      );
     65    }
     66  }
     67 
     68  let history = tab.linkedBrowser.browsingContext.sessionHistory;
     69 
     70  is(history.count, 2, "history.count");
     71  for (let i = 0; i < history.count; i++) {
     72    for (let j = 0; j < history.count; j++) {
     73      compareEntries(i, j, history);
     74    }
     75  }
     76 
     77  ss.setBrowserState(stateBackup);
     78 });