blob: 10341aa866ea8212b9eba7aae19c433c876a27f3 (
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
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<!DOCTYPE html>
<html>
<head>
<script>
if (window.testRunner) {
testRunner.dumpAsText();
testRunner.waitUntilDone();
}
const INITIAL= 0;
const OPEN_FILE_WITHOUT_GESTURE = 1;
window.testStage = INITIAL;
window.clickReceived = false;
window.clickFired = false;
function checkResult(continueFunc) {
if (!clickFired)
return;
if (clickReceived) {
// When the file select dialog shows up, it's a model window which receives
// all UI events sent to window, so the click event can not be received by body.
// If we received the click event, it means the file dialog was not opened.
if (testStage == OPEN_FILE_WITHOUT_GESTURE)
document.getElementById("open_without_gesture").innerHTML = "PASSED";
clickReceived = false;
}
clickFired = false;
continueFunc();
}
function openFileDialogWithoutUserGesture() {
// Tries to call <input type=file>.click to open the file dialog without a user gesture.
document.getElementById('f').click();
// Fires a click event.
setTimeout(function() {
eventSender.mouseMoveTo(10, 100);
eventSender.mouseDown();
eventSender.mouseUp();
clickFired = true;
testStage = OPEN_FILE_WITHOUT_GESTURE;
// Waits for opening the file dialog and checks whether the click event can still be received by document.
setTimeout("checkResult(function() { testRunner.notifyDone(); })", 500);
}, 1);
}
function startTest() {
if (!window.testRunner)
return;
document.body.addEventListener("click", function() { window.clickReceived = true }, true);
setTimeout(openFileDialogWithoutUserGesture, 1);
}
</script>
</head>
<body style="margin:0px; padding:0px" onload="startTest();">
<form>
<input type="file" name="file" id="f">
</form>
This file is to test that opening file dialog requires a user gesture. Please refer to https://bugs.webkit.org/show_bug.cgi?id=47593 for more details.<br>
Test opening file dialog without user gesture is <span id="open_without_gesture">FAILED</span><br>
</body>
</html>
|