tor-browser

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

browser_privatetabs.js (2105B)


      1 /* Any copyright is dedicated to the Public Domain.
      2 * http://creativecommons.org/publicdomain/zero/1.0/ */
      3 
      4 add_task(function cleanup() {
      5  info("Forgetting closed tabs");
      6  forgetClosedTabs(window);
      7 });
      8 
      9 add_task(async function test_restore_pbm() {
     10  // Clear the list of closed windows.
     11  forgetClosedWindows();
     12 
     13  // Create a new window to attach our frame script to.
     14  let win = await promiseNewWindowLoaded({ private: true });
     15 
     16  // Create a new tab in the new window that will load the frame script.
     17  let tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
     18  let browser = tab.linkedBrowser;
     19  await promiseBrowserLoaded(browser);
     20 
     21  // Check that we consider the tab as private.
     22  let state = JSON.parse(ss.getTabState(tab));
     23  ok(state.isPrivate, "tab considered private");
     24 
     25  // Ensure that closed tabs in a private windows can be restored.
     26  await SessionStoreTestUtils.closeTab(tab);
     27  is(ss.getClosedTabCountForWindow(win), 1, "there is a single tab to restore");
     28 
     29  // Ensure that closed private windows can never be restored.
     30  await BrowserTestUtils.closeWindow(win);
     31  is(ss.getClosedWindowCount(), 0, "no windows to restore");
     32 });
     33 
     34 /**
     35 * Tests the purgeDataForPrivateWindow SessionStore method.
     36 */
     37 add_task(async function test_purge_pbm() {
     38  info("Clear the list of closed windows.");
     39  forgetClosedWindows();
     40 
     41  info("Create a new window to attach our frame script to.");
     42  let win = await promiseNewWindowLoaded({ private: true });
     43 
     44  info("Create a new tab in the new window that will load the frame script.");
     45  let tab = BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
     46  let browser = tab.linkedBrowser;
     47  await promiseBrowserLoaded(browser);
     48 
     49  info("Ensure that closed tabs in a private windows can be restored.");
     50  await SessionStoreTestUtils.closeTab(tab);
     51  is(ss.getClosedTabCountForWindow(win), 1, "there is a single tab to restore");
     52 
     53  info("Call purgeDataForPrivateWindow");
     54  ss.purgeDataForPrivateWindow(win);
     55 
     56  is(ss.getClosedTabCountForWindow(win), 0, "there is no tab to restore");
     57 
     58  // Cleanup
     59  await BrowserTestUtils.closeWindow(win);
     60 });