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

"use strict";

Services.scriptloader.loadSubScript(
  "chrome://mochitests/content/browser/gfx/layers/apz/test/mochitest/apz_test_native_event_utils.js",
  this
);

add_task(async () => {
  await BrowserTestUtils.withNewTab(
    {
      gBrowser,
      url: TEST_PAGE,
    },
    async browser => {
      let pipWin = await triggerPictureInPicture(browser, "with-controls");

      let receivedSwipeGestureEvents = false;
      pipWin.addEventListener("MozSwipeGestureMayStart", () => {
        receivedSwipeGestureEvents = true;
      });

      const wheelEventPromise = BrowserTestUtils.waitForEvent(pipWin, "wheel");

      // Try swiping left to right.
      await panLeftToRightBegin(pipWin, 100, 100, 100);
      await panLeftToRightEnd(pipWin, 100, 100, 100);

      // Wait a wheel event and a couple of frames to give a chance to receive
      // the MozSwipeGestureMayStart event.
      await wheelEventPromise;
      await new Promise(resolve => requestAnimationFrame(resolve));
      await new Promise(resolve => requestAnimationFrame(resolve));

      Assert.ok(
        !receivedSwipeGestureEvents,
        "No swipe gesture events observed"
      );

      let pipClosed = BrowserTestUtils.domWindowClosed(pipWin);
      pipWin.close();
      await pipClosed;
    }
  );
});