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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
|
/* Any copyright is dedicated to the Public Domain.
http://creativecommons.org/publicdomain/zero/1.0/ */
"use strict";
add_task(async function test_no_notification_when_pb_autostart() {
let observedLastPBContext = false;
let observerExited = {
observe() {
observedLastPBContext = true;
},
};
Services.obs.addObserver(observerExited, "last-pb-context-exited");
await SpecialPowers.pushPrefEnv({
set: [["browser.privatebrowsing.autostart", true]],
});
let win = await BrowserTestUtils.openNewBrowserWindow();
let browser = win.gBrowser.selectedTab.linkedBrowser;
ok(browser.browsingContext.usePrivateBrowsing, "should use private browsing");
await BrowserTestUtils.closeWindow(win);
await SpecialPowers.popPrefEnv();
Services.obs.removeObserver(observerExited, "last-pb-context-exited");
ok(!observedLastPBContext, "No last-pb-context-exited notification seen");
});
add_task(async function test_notification_when_about_preferences() {
let observedLastPBContext = false;
let observerExited = {
observe() {
observedLastPBContext = true;
},
};
Services.obs.addObserver(observerExited, "last-pb-context-exited");
let win = await BrowserTestUtils.openNewBrowserWindow({ private: true });
let browser = win.gBrowser.selectedTab.linkedBrowser;
ok(browser.browsingContext.usePrivateBrowsing, "should use private browsing");
ok(browser.browsingContext.isContent, "should be content browsing context");
let tab = await BrowserTestUtils.addTab(win.gBrowser, "about:preferences");
ok(
tab.linkedBrowser.browsingContext.usePrivateBrowsing,
"should use private browsing"
);
ok(
tab.linkedBrowser.browsingContext.isContent,
"should be content browsing context"
);
let tabClose = BrowserTestUtils.waitForTabClosing(win.gBrowser.selectedTab);
BrowserTestUtils.removeTab(win.gBrowser.selectedTab);
await tabClose;
ok(!observedLastPBContext, "No last-pb-context-exited notification seen");
await BrowserTestUtils.closeWindow(win);
Services.obs.removeObserver(observerExited, "last-pb-context-exited");
ok(observedLastPBContext, "No last-pb-context-exited notification seen");
});
|