summaryrefslogtreecommitdiffstats
path: root/browser/components/privatebrowsing/test/browser/browser_privatebrowsing_theming.js
blob: 18b398e961504f06ed423ad0623f12721db86f07 (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
45
46
/* This Source Code Form is subject to the terms of the Mozilla Public
 * License, v. 2.0. If a copy of the MPL was not distributed with this
 * file, You can obtain one at http://mozilla.org/MPL/2.0/. */

// This test makes sure that privatebrowsingmode attribute of the window is correctly
// adjusted based on whether the window is a private window.

var windowsToClose = [];
function testOnWindow(options, callback) {
  var win = OpenBrowserWindow(options);
  win.addEventListener(
    "load",
    function () {
      windowsToClose.push(win);
      executeSoon(() => callback(win));
    },
    { once: true }
  );
}

registerCleanupFunction(function () {
  windowsToClose.forEach(function (win) {
    win.close();
  });
});

function test() {
  // initialization
  waitForExplicitFinish();

  ok(
    !document.documentElement.hasAttribute("privatebrowsingmode"),
    "privatebrowsingmode should not be present in normal mode"
  );

  // open a private window
  testOnWindow({ private: true }, function (win) {
    is(
      win.document.documentElement.getAttribute("privatebrowsingmode"),
      "temporary",
      'privatebrowsingmode should be "temporary" inside the private browsing mode'
    );

    finish();
  });
}