summaryrefslogtreecommitdiffstats
path: root/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_noSessionRestoreMenuOption.js
blob: 17ea34d1aac3c023862d3b26329971473ff8ef83 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
"use strict";

/**
 * Tests that if we open a tab within a private browsing window, and then
 * close that private browsing window, that subsequent private browsing
 * windows do not allow the command for restoring the last session.
 */
add_task(async function test_no_session_restore_menu_option() {
  let win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
  ok(true, "The first private window got loaded");
  BrowserTestUtils.addTab(win.gBrowser, "about:mozilla");
  await BrowserTestUtils.closeWindow(win);

  win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
  let srCommand = win.document.getElementById("Browser:RestoreLastSession");
  ok(srCommand, "The Session Restore command should exist");
  is(
    PrivateBrowsingUtils.isWindowPrivate(win),
    true,
    "PrivateBrowsingUtils should report the correct per-window private browsing status"
  );
  is(
    srCommand.hasAttribute("disabled"),
    true,
    "The Session Restore command should be disabled in private browsing mode"
  );

  await BrowserTestUtils.closeWindow(win);
});