blob: f7477d1eccf816e507c401c26d9deaf360f33699 (
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
|
'use strict';
let fakeHidService = undefined;
function hid_test(func, name, properties) {
promise_test(async (test) => {
assert_implements(navigator.hid, 'missing navigator.hid');
if (fakeHidService === undefined) {
// Try loading a polyfill for the fake hid service.
if (isChromiumBased) {
const fakes = await import('/resources/chromium/fake-hid.js');
fakeHidService = fakes.fakeHidService;
}
}
assert_implements(
fakeHidService, 'missing fakeHidService after initialization');
fakeHidService.start();
try {
await func(test, fakeHidService);
} finally {
fakeHidService.stop();
fakeHidService.reset();
}
}, name, properties);
}
function trustedClick() {
return new Promise(resolve => {
let button = document.createElement('button');
button.textContent = 'click to continue test';
button.style.display = 'block';
button.style.fontSize = '20px';
button.style.padding = '10px';
button.onclick = () => {
document.body.removeChild(button);
resolve();
};
document.body.appendChild(button);
test_driver.click(button);
});
}
|