tor-browser

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

browser_bug1299667.js (2387B)


      1 /* Any copyright is dedicated to the Public Domain.
      2   http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 add_task(async function () {
      5  // eslint-disable-next-line @microsoft/sdl/no-insecure-url
      6  await BrowserTestUtils.openNewForegroundTab(gBrowser, "http://example.com");
      7 
      8  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
      9    content.document.notifyUserGestureActivation();
     10    content.history.pushState({}, "2", "2.html");
     11  });
     12 
     13  await TestUtils.topicObserved("sessionstore-state-write-complete");
     14 
     15  // Wait for the session data to be flushed before continuing the test
     16  await new Promise(resolve =>
     17    SessionStore.getSessionHistory(gBrowser.selectedTab, resolve)
     18  );
     19 
     20  let backButton = document.getElementById("back-button");
     21  let contextMenu = document.getElementById("backForwardMenu");
     22 
     23  info("waiting for the history menu to open");
     24 
     25  let popupShownPromise = BrowserTestUtils.waitForEvent(
     26    contextMenu,
     27    "popupshown"
     28  );
     29  EventUtils.synthesizeMouseAtCenter(backButton, {
     30    type: "contextmenu",
     31    button: 2,
     32  });
     33  let event = await popupShownPromise;
     34 
     35  ok(true, "history menu opened");
     36 
     37  // Wait for the session data to be flushed before continuing the test
     38  await new Promise(resolve =>
     39    SessionStore.getSessionHistory(gBrowser.selectedTab, resolve)
     40  );
     41 
     42  is(event.target.children.length, 2, "Two history items");
     43 
     44  let node = event.target.firstElementChild;
     45  // eslint-disable-next-line @microsoft/sdl/no-insecure-url
     46  is(node.getAttribute("uri"), "http://example.com/2.html", "first item uri");
     47  is(node.getAttribute("index"), "1", "first item index");
     48  is(node.getAttribute("historyindex"), "0", "first item historyindex");
     49 
     50  node = event.target.lastElementChild;
     51  // eslint-disable-next-line @microsoft/sdl/no-insecure-url
     52  is(node.getAttribute("uri"), "http://example.com/", "second item uri");
     53  is(node.getAttribute("index"), "0", "second item index");
     54  is(node.getAttribute("historyindex"), "-1", "second item historyindex");
     55 
     56  let popupHiddenPromise = BrowserTestUtils.waitForEvent(
     57    contextMenu,
     58    "popuphidden"
     59  );
     60  event.target.hidePopup();
     61  await popupHiddenPromise;
     62  info("Hidden popup");
     63 
     64  let onClose = BrowserTestUtils.waitForEvent(
     65    gBrowser.tabContainer,
     66    "TabClose"
     67  );
     68  BrowserTestUtils.removeTab(gBrowser.selectedTab);
     69  await onClose;
     70  info("Tab closed");
     71 });