summaryrefslogtreecommitdiffstats
path: root/layout/base/tests/browser_bug617076.js
blob: c76cbd41d384b863a27baca54b5303fb8fa5408e (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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
/**
 * 1. load about:addons in a new tab and select that tab
 * 2. insert a button with tooltiptext
 * 3. create a new blank tab and select that tab
 * 4. select the about:addons tab and hover the inserted button
 * 5. remove the about:addons tab
 * 6. remove the blank tab
 *
 * the test succeeds if it doesn't trigger any assertions
 */

add_task(async function test() {
  // Open the test tab
  let testTab = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "about:addons"
  );

  // insert button into test page content
  await SpecialPowers.spawn(gBrowser.selectedBrowser, [], async function () {
    let doc = content.document;
    let e = doc.createXULElement("button");
    e.setAttribute("label", "hello");
    e.setAttribute("tooltiptext", "world");
    e.setAttribute("id", "test-button");
    doc.documentElement.insertBefore(e, doc.documentElement.firstChild);
  });

  // open a second tab and select it
  let tab2 = await BrowserTestUtils.openNewForegroundTab(
    gBrowser,
    "about:blank",
    true
  );
  gBrowser.selectedTab = tab2;

  // Select the testTab then perform mouse events on inserted button
  gBrowser.selectedTab = testTab;
  let browser = gBrowser.selectedBrowser;
  EventUtils.disableNonTestMouseEvents(true);
  try {
    await BrowserTestUtils.synthesizeMouse(
      "#test-button",
      1,
      1,
      { type: "mouseover" },
      browser
    );
    await BrowserTestUtils.synthesizeMouse(
      "#test-button",
      2,
      6,
      { type: "mousemove" },
      browser
    );
    await BrowserTestUtils.synthesizeMouse(
      "#test-button",
      2,
      4,
      { type: "mousemove" },
      browser
    );
  } finally {
    EventUtils.disableNonTestMouseEvents(false);
  }

  // cleanup
  BrowserTestUtils.removeTab(testTab);
  BrowserTestUtils.removeTab(tab2);
  ok(true, "pass if no assertions");
});