summaryrefslogtreecommitdiffstats
path: root/docshell/test/unit/test_privacy_transition.js
blob: 3fe9ad116d3da49d3cd8a4c1c6b2db6cd19551d0 (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() {
    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);
}