summaryrefslogtreecommitdiffstats
path: root/toolkit/components/extensions/test/xpcshell/test_ext_background_private_browsing.js
blob: 9ce80f3fda38e2ad187542d335aefc8aac6d59b1 (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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
/* -*- Mode: indent-tabs-mode: nil; js-indent-level: 2 -*- */
/* vim: set sts=2 sw=2 et tw=80: */
"use strict";

add_task(async function test_background_incognito() {
  info(
    "Test background page incognito value with permanent private browsing enabled"
  );

  Services.prefs.setBoolPref("browser.privatebrowsing.autostart", true);
  registerCleanupFunction(() => {
    Services.prefs.clearUserPref("browser.privatebrowsing.autostart");
  });

  let extension = ExtensionTestUtils.loadExtension({
    incognitoOverride: "spanning",
    async background() {
      browser.test.assertEq(
        window,
        browser.extension.getBackgroundPage(),
        "Caller should be able to access itself as a background page"
      );
      browser.test.assertEq(
        window,
        await browser.runtime.getBackgroundPage(),
        "Caller should be able to access itself as a background page"
      );

      browser.test.assertEq(
        browser.extension.inIncognitoContext,
        true,
        "inIncognitoContext is true for permanent private browsing"
      );

      browser.test.notifyPass("incognito");
    },
  });

  await extension.startup();

  await extension.awaitFinish("incognito");

  await extension.unload();
});