forked from WebKit/WebKit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathworker-user-gesture.html
42 lines (38 loc) · 1.33 KB
/
worker-user-gesture.html
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
<!DOCTYPE html>
<html>
<head>
<script src="../resources/js-test.js"></script>
<script>
description("Passes a User Gesture through postMessage() to a worker context; press any key, click, or tap to continue.");
window.jsTestIsAsync = true;
function runTest() {
const mc = new MessageChannel();
const w = new Worker("worker-user-gesture.js");
w.postMessage('hello worker');
w.onmessage = event => {
if (window.internals) {
if (internals.isProcessingUserGesture())
testPassed('User Gesture was propagated through postMessage and back.');
else
testFailed('User Gesture was not propagated through postMessage and back.')
finishJSTest();
return;
}
navigator.clipboard.writeText(event.data).then(() => {
testPassed('User Gesture was propagated through postMessage and back.')
}).catch(e => {
testFailed('User Gesture was not propagated through postMessage and back.')
}).finally(finishJSTest);
};
}
window.addEventListener('load', event => {
if (window.internals)
internals.withUserGesture(runTest);
else
['keypress', 'click', 'touchend'].forEach(eventName => window.addEventListener(eventName, runTest, {once: true}));
});
</script>
</head>
<body>
</body>
</html>