summaryrefslogtreecommitdiffstats
path: root/docshell/test/unit/test_privacy_transition.js
blob: ae1bf712848af65eb8045532a25489e4928a5cc3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
var gNotifications = 0;

var observer = {
  QueryInterface: ChromeUtils.generateQI([
    "nsIPrivacyTransitionObserver",
    "nsISupportsWeakReference",
  ]),

  privateModeChanged(enabled) {
    gNotifications++;
  },
};

function run_test() {
  let windowlessBrowser = Services.appShell.createWindowlessBrowser(true);
  windowlessBrowser.docShell.addWeakPrivacyTransitionObserver(observer);
  windowlessBrowser.docShell.setOriginAttributes({ privateBrowsingId: 1 });
  windowlessBrowser.docShell.setOriginAttributes({ privateBrowsingId: 0 });
  windowlessBrowser.close();
  Assert.equal(gNotifications, 2);
}