summaryrefslogtreecommitdiffstats
path: root/dom/tests/mochitest/gamepad/mock_gamepad.js
blob: 778035ef10ea7e5fef0d5aa893e0fd2b58534017 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
/* Any copyright is dedicated to the Public Domain.
 * http://creativecommons.org/publicdomain/zero/1.0/ */

var GamepadService;

async function setGamepadPreferenceAndCreateIframe(iframeSrc) {
  await SpecialPowers.pushPrefEnv({
    set: [["dom.gamepad.test.enabled", true]],
  });

  let iframe = document.createElement("iframe");
  iframe.src = iframeSrc;
  document.body.appendChild(iframe);
}

function runGamepadTest(callback) {
  GamepadService = navigator.requestGamepadServiceTest();
  callback();
}