5 if (window
.testRunner
) {
6 testRunner
.dumpAsText();
7 testRunner
.waitUntilDone();
10 const OPEN_FILE_WITHOUT_GESTURE
= 1;
11 window
.testStage
= INITIAL
;
12 window
.clickReceived
= false;
13 window
.clickFired
= false;
15 function checkResult(continueFunc
) {
19 // When the file select dialog shows up, it's a model window which receives
20 // all UI events sent to window, so the click event can not be received by body.
21 // If we received the click event, it means the file dialog was not opened.
22 if (testStage
== OPEN_FILE_WITHOUT_GESTURE
)
23 document
.getElementById("open_without_gesture").innerHTML
= "PASSED";
24 clickReceived
= false;
30 function openFileDialogWithoutUserGesture() {
31 // Tries to call <input type=file>.click to open the file dialog without a user gesture.
32 document
.getElementById('f').click();
33 // Fires a click event.
34 setTimeout(function() {
35 eventSender
.mouseMoveTo(10, 100);
36 eventSender
.mouseDown();
37 eventSender
.mouseUp();
39 testStage
= OPEN_FILE_WITHOUT_GESTURE
;
40 // Waits for opening the file dialog and checks whether the click event can still be received by document.
41 setTimeout("checkResult(function() { testRunner.notifyDone(); })", 500);
45 function startTest() {
46 if (!window
.testRunner
)
48 document
.body
.addEventListener("click", function() { window
.clickReceived
= true }, true);
49 setTimeout(openFileDialogWithoutUserGesture
, 1);
53 <body style=
"margin:0px; padding:0px" onload=
"startTest();">
55 <input type=
"file" name=
"file" id=
"f">
57 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>
58 Test opening file dialog without user gesture is
<span id=
"open_without_gesture">FAILED
</span><br>