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
|
"use strict";
const example_base =
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
"http://example.com/browser/browser/base/content/test/tabs/";
add_task(async function test_contextmenu_openlink_after_tabnavigated() {
let url = example_base + "test_bug1358314.html";
const tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
const contextMenu = document.getElementById("contentAreaContextMenu");
let awaitPopupShown = BrowserTestUtils.waitForEvent(
contextMenu,
"popupshown"
);
await BrowserTestUtils.synthesizeMouse(
"a",
0,
0,
{
type: "contextmenu",
button: 2,
},
gBrowser.selectedBrowser
);
await awaitPopupShown;
info("Popup Shown");
info("Navigate the tab with the opened context menu");
BrowserTestUtils.loadURIString(gBrowser.selectedBrowser, "about:blank");
await BrowserTestUtils.browserLoaded(gBrowser.selectedBrowser);
let awaitNewTabOpen = BrowserTestUtils.waitForNewTab(
gBrowser,
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
"http://example.com/",
true
);
info("Click the 'open link in new tab' menu item");
let openLinkMenuItem = contextMenu.querySelector("#context-openlinkintab");
contextMenu.activateItem(openLinkMenuItem);
info("Wait for the new tab to be opened");
const newTab = await awaitNewTabOpen;
// Close the contextMenu popup if it has not been closed yet.
contextMenu.hidePopup();
is(
newTab.linkedBrowser.currentURI.spec,
// eslint-disable-next-line @microsoft/sdl/no-insecure-url
"http://example.com/",
"Got the expected URL loaded in the new tab"
);
BrowserTestUtils.removeTab(newTab);
BrowserTestUtils.removeTab(tab);
});
|