summaryrefslogtreecommitdiffstats
path: root/browser/components/contextualidentity/test/browser/head.js
blob: b5bf451d2537d65a787c0058b44493b0821c7cb4 (plain)
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
async function openTabMenuFor(tab) {
  let tabMenu = tab.ownerDocument.getElementById("tabContextMenu");

  let tabMenuShown = BrowserTestUtils.waitForEvent(tabMenu, "popupshown");
  EventUtils.synthesizeMouseAtCenter(
    tab,
    { type: "contextmenu" },
    tab.ownerGlobal
  );
  await tabMenuShown;

  return tabMenu;
}

async function openReopenMenuForTab(tab) {
  await openTabMenuFor(tab);

  let reopenItem = tab.ownerDocument.getElementById(
    "context_reopenInContainer"
  );
  ok(!reopenItem.hidden, "Reopen in Container item should be shown");

  const menuPopup = reopenItem.menupopup;
  const menuPopupPromise = BrowserTestUtils.waitForEvent(
    menuPopup,
    "popupshown"
  );
  info(`About to open a popup`);
  reopenItem.openMenu(true);
  info(`Waiting for the menu popup promise`);
  await menuPopupPromise;
  info(`Awaited menu popup promise`);
  return menuPopup;
}

function openTabInContainer(gBrowser, url, reopenMenu, id) {
  let tabPromise = BrowserTestUtils.waitForNewTab(gBrowser, url, true);
  let menuitem = reopenMenu.querySelector(
    `menuitem[data-usercontextid="${id}"]`
  );
  info(`about to activate item`);
  reopenMenu.activateItem(menuitem);
  return tabPromise;
}

function loadTestSubscript(filePath) {
  Services.scriptloader.loadSubScript(new URL(filePath, gTestPath).href, this);
}