OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <script src="../../../resources/js-test.js"></script> | 2 <script src="../../../resources/js-test.js"></script> |
| 3 <script src="resources/file-drag-common.js"></script> |
3 <form method="GET" onsubmit="finish(false)"> | 4 <form method="GET" onsubmit="finish(false)"> |
4 <input type="file" oninvalid="finish(true)" required> | 5 <input type="file" oninvalid="finish(true)" required> |
5 <input type="submit"> | 6 <input type="submit"> |
6 </form> | 7 </form> |
7 <pre id="console"></pre> | 8 <pre id="console"></pre> |
8 <script> | 9 <script> |
9 description("This tests that a file input cleared of its (required) value doesn'
t validate."); | 10 description("This tests that a file input cleared of its (required) value doesn'
t validate."); |
10 | 11 |
11 var invalid = false; | 12 var invalid = false; |
12 function finish(pass) | 13 function finish(pass) |
13 { | 14 { |
14 invalid = pass; | 15 invalid = pass; |
15 shouldBeTrue("invalid"); | 16 shouldBeTrue("invalid"); |
16 finishJSTest(); | 17 finishJSTest(); |
17 } | 18 } |
18 | 19 |
19 function moveMouseToCenterOfElement(element) { | |
20 var centerX = element.offsetLeft + element.offsetWidth / 2; | |
21 var centerY = element.offsetTop + element.offsetHeight / 2; | |
22 eventSender.mouseMoveTo(centerX, centerY); | |
23 } | |
24 | |
25 function dragFilesOntoInput(input, files) { | |
26 eventSender.beginDragWithFiles(files); | |
27 moveMouseToCenterOfElement(input); | |
28 eventSender.mouseUp(); | |
29 } | |
30 | |
31 function startTest() | 20 function startTest() |
32 { | 21 { |
33 dragFilesOntoInput(document.forms[0].querySelector("[type=file]"), ['file-in
put-empty-validation.html']); | 22 dragFilesOntoInput(document.forms[0].querySelector("[type=file]"), ['file-in
put-empty-validation.html']); |
34 document.forms[0].querySelector("[type=file]").value = ""; | 23 document.forms[0].querySelector("[type=file]").value = ""; |
35 document.forms[0].querySelector("[type=submit]").click(); | 24 document.forms[0].querySelector("[type=submit]").click(); |
36 } | 25 } |
37 | 26 |
38 if (window.eventSender) { | 27 if (window.eventSender) { |
39 window.jsTestIsAsync = true; | 28 window.jsTestIsAsync = true; |
40 testRunner.dumpAsText(); | 29 testRunner.dumpAsText(); |
41 window.onload = startTest; | 30 window.onload = startTest; |
42 } | 31 } |
43 </script> | 32 </script> |
OLD | NEW |