summaryrefslogtreecommitdiffstats
path: root/toolkit/modules/tests/browser/browser_Finder_pointer_events_none.js
blob: fe772edceff5e5a338c10876d5294e25b247b13f (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
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

add_task(async function test_offscreen_text() {
  const URI = '<body><div style="pointer-events:none">find this</div></body>';
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url: "data:text/html;charset=utf-8," + encodeURIComponent(URI),
    },
    async function(browser) {
      let finder = browser.finder;
      let listener = {
        onFindResult() {
          ok(false, "callback wasn't replaced");
        },
      };
      finder.addResultListener(listener);

      function waitForFind() {
        return new Promise(resolve => {
          listener.onFindResult = resolve;
        });
      }

      // Find the target text.
      let promiseFind = waitForFind();
      finder.fastFind("find this", false, false);
      let findResult = await promiseFind;
      is(
        findResult.result,
        Ci.nsITypeAheadFind.FIND_FOUND,
        "Found target text."
      );

      finder.removeResultListener(listener);
    }
  );
});