summaryrefslogtreecommitdiffstats
path: root/toolkit/mozapps/webextensions/test/xpinstall/browser_bug638292.js
blob: 0d96e7cbe65c1ebb748eb5986857e1326457afe0 (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
// ----------------------------------------------------------------------------
// Test whether an InstallTrigger.enabled is working
add_task(function * ()
{
  let testtab = yield BrowserTestUtils.openNewForegroundTab(gBrowser, TESTROOT + "bug638292.html");

  function* verify(link, button)
  {
    info("Clicking " + link);

    let waitForNewTabPromise = BrowserTestUtils.waitForNewTab(gBrowser);

    yield BrowserTestUtils.synthesizeMouseAtCenter("#" + link, { button: button },
                                                   gBrowser.selectedBrowser);

    let newtab = yield waitForNewTabPromise;

    yield BrowserTestUtils.browserLoaded(newtab.linkedBrowser);

    let result = yield ContentTask.spawn(newtab.linkedBrowser, { }, function* () {
      return (content.document.getElementById("enabled").textContent == "true");
    });

    ok(result, "installTrigger for " + link + " should have been enabled");

    // Focus the old tab (link3 is opened in the background)
    if (link != "link3") {
      yield BrowserTestUtils.switchTab(gBrowser, testtab);
    }
    gBrowser.removeTab(newtab);
  }

  yield* verify("link1", 0);
  yield* verify("link2", 0);
  yield* verify("link3", 1);

  gBrowser.removeCurrentTab();
});