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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
|
/* Any copyright is dedicated to the Public Domain.
* http://creativecommons.org/publicdomain/zero/1.0/ */
// Verify that LAST_PRIVATE_CONTEXT_EXIT fires when closing the last opened private window
"use strict";
const NON_PRIVATE_TEST_URI =
"data:text/html;charset=utf8,<!DOCTYPE html>Not private";
const PRIVATE_TEST_URI = `data:text/html;charset=utf8,<!DOCTYPE html>Test in private windows`;
add_task(async function () {
await pushPref("devtools.browsertoolbox.scope", "everything");
const { commands } = await initMultiProcessResourceCommand();
const { resourceCommand } = commands;
const availableResources = [];
await resourceCommand.watchResources(
[resourceCommand.TYPES.LAST_PRIVATE_CONTEXT_EXIT],
{
onAvailable(resources) {
availableResources.push(resources);
},
}
);
is(
availableResources.length,
0,
"We do not get any LAST_PRIVATE_CONTEXT_EXIT after initialization"
);
await addTab(NON_PRIVATE_TEST_URI);
info("Open a new private window and select the new tab opened in it");
const privateWindow = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
ok(PrivateBrowsingUtils.isWindowPrivate(privateWindow), "window is private");
const privateBrowser = privateWindow.gBrowser;
privateBrowser.selectedTab = BrowserTestUtils.addTab(
privateBrowser,
PRIVATE_TEST_URI
);
info("private tab opened");
ok(
PrivateBrowsingUtils.isBrowserPrivate(privateBrowser.selectedBrowser),
"tab window is private"
);
info("Open a second tab in the private window");
await addTab(PRIVATE_TEST_URI, { window: privateWindow });
// Let a chance to an unexpected async event to be fired
await wait(1000);
is(
availableResources.length,
0,
"We do not get any LAST_PRIVATE_CONTEXT_EXIT when opening a private window"
);
info("Open a second private browsing window");
const secondPrivateWindow = await BrowserTestUtils.openNewBrowserWindow({
private: true,
});
info("Close the second private window");
secondPrivateWindow.BrowserTryToCloseWindow();
// Let a chance to an unexpected async event to be fired
await wait(1000);
is(
availableResources.length,
0,
"We do not get any LAST_PRIVATE_CONTEXT_EXIT when closing the second private window only"
);
info(
"close the private window and check if LAST_PRIVATE_CONTEXT_EXIT resource is sent"
);
privateWindow.BrowserTryToCloseWindow();
info("Wait for LAST_PRIVATE_CONTEXT_EXIT");
await waitFor(() => availableResources.length == 1);
is(
availableResources.length,
1,
"We get one LAST_PRIVATE_CONTEXT_EXIT when closing the last opened private window"
);
await commands.destroy();
});
|