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
|
"use strict";
const PATH = getRootDirectory(gTestPath).replace(
"chrome://mochitests/content",
"https://example.com"
);
const TEST_PAGE = PATH + "file_triggeringprincipal_oa.html";
const DUMMY_PAGE = PATH + "empty_file.html";
add_task(
async function test_principal_right_click_open_link_in_new_private_win() {
await BrowserTestUtils.withNewTab(TEST_PAGE, async function (browser) {
let promiseNewWindow = BrowserTestUtils.waitForNewWindow({
url: DUMMY_PAGE,
});
// simulate right-click open link in new private window
BrowserTestUtils.waitForEvent(document, "popupshown", false, event => {
document.getElementById("context-openlinkprivate").doCommand();
event.target.hidePopup();
return true;
});
BrowserTestUtils.synthesizeMouseAtCenter(
"#checkPrincipalOA",
{ type: "contextmenu", button: 2 },
gBrowser.selectedBrowser
);
let privateWin = await promiseNewWindow;
await SpecialPowers.spawn(
privateWin.gBrowser.selectedBrowser,
[{ DUMMY_PAGE, TEST_PAGE }],
// eslint-disable-next-line no-shadow
async function ({ DUMMY_PAGE, TEST_PAGE }) {
// eslint-disable-line
let channel = content.docShell.currentDocumentChannel;
is(
channel.URI.spec,
DUMMY_PAGE,
"sanity check to ensure we check principal for right URI"
);
let triggeringPrincipal = channel.loadInfo.triggeringPrincipal;
ok(
triggeringPrincipal.isContentPrincipal,
"sanity check to ensure principal is a contentPrincipal"
);
is(
triggeringPrincipal.spec,
TEST_PAGE,
"test page must be the triggering page"
);
is(
triggeringPrincipal.originAttributes.privateBrowsingId,
1,
"must have correct privateBrowsingId"
);
}
);
await BrowserTestUtils.closeWindow(privateWin);
});
}
);
|