summaryrefslogtreecommitdiffstats
path: root/layout/xul/test/browser_bug703210.js
blob: cf5a0850a3739e871ec7e3a8777c3a27df793fc6 (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
49
50
51
52
53
54
add_task(async function () {
  const url =
    "data:text/html," +
    "<html onmousemove='event.stopPropagation()'" +
    " onmouseenter='event.stopPropagation()' onmouseleave='event.stopPropagation()'" +
    " onmouseover='event.stopPropagation()' onmouseout='event.stopPropagation()'>" +
    '<p id="p1" title="tooltip is here">This paragraph has a tooltip.</p>' +
    '<p id="p2">This paragraph doesn\'t have tooltip.</p></html>';

  let tab = await BrowserTestUtils.openNewForegroundTab(gBrowser, url);
  let browser = gBrowser.selectedBrowser;

  await SpecialPowers.pushPrefEnv({ set: [["ui.tooltip.delay_ms", 0]] });

  let popupShownPromise = BrowserTestUtils.waitForEvent(
    document,
    "popupshown",
    false,
    event => {
      is(event.originalTarget.localName, "tooltip", "tooltip is showing");
      return true;
    }
  );
  let popupHiddenPromise = BrowserTestUtils.waitForEvent(
    document,
    "popuphidden",
    false,
    event => {
      is(event.originalTarget.localName, "tooltip", "tooltip is hidden");
      return true;
    }
  );

  // Send a mousemove at a known position to start the test.
  await BrowserTestUtils.synthesizeMouseAtCenter(
    "#p2",
    { type: "mousemove" },
    browser
  );
  await BrowserTestUtils.synthesizeMouseAtCenter(
    "#p1",
    { type: "mousemove" },
    browser
  );
  await popupShownPromise;
  await BrowserTestUtils.synthesizeMouseAtCenter(
    "#p2",
    { type: "mousemove" },
    browser
  );
  await popupHiddenPromise;

  gBrowser.removeCurrentTab();
});