OLD | NEW |
1 <!DOCTYPE html> | 1 <!DOCTYPE html> |
2 <html> | 2 <html> |
3 <head> | 3 <head> |
4 <script src="../../../resources/js-test.js"></script> | 4 <script src="../../../resources/js-test.js"></script> |
| 5 <script src="resources/file-drag-common.js"></script> |
5 </head> | 6 </head> |
6 <body> | 7 <body> |
7 <input type="file" name="file" id="file"> | 8 <input type="file" name="file" id="file"> |
8 | 9 |
9 <script> | 10 <script> |
10 description("This tests the value attribute in file input forms"); | 11 description("This tests the value attribute in file input forms"); |
11 | 12 |
12 if (window.testRunner) { | 13 if (window.testRunner) { |
13 var file = document.getElementById("file"); | 14 var file = document.getElementById("file"); |
14 dragFilesOntoInput(file, ["foo.txt"]); | 15 dragFilesOntoInput(file, ["foo.txt"]); |
15 | 16 |
16 shouldBeEqualToString("file.value", "C:\\fakepath\\foo.txt"); | 17 shouldBeEqualToString("file.value", "C:\\fakepath\\foo.txt"); |
17 shouldBe("file.files.length", "1"); | 18 shouldBe("file.files.length", "1"); |
18 | 19 |
19 shouldThrow("file.value = 'foo'"); | 20 shouldThrow("file.value = 'foo'"); |
20 shouldBeEqualToString("file.value", "C:\\fakepath\\foo.txt"); | 21 shouldBeEqualToString("file.value", "C:\\fakepath\\foo.txt"); |
21 shouldBe("file.files.length", "1"); | 22 shouldBe("file.files.length", "1"); |
22 | 23 |
23 file.value = ""; | 24 file.value = ""; |
24 shouldBeEqualToString("file.value", ""); | 25 shouldBeEqualToString("file.value", ""); |
25 shouldBe("file.files.length", "0"); | 26 shouldBe("file.files.length", "0"); |
26 } | 27 } |
27 | |
28 function moveMouseToCenterOfElement(element) { | |
29 var centerX = element.offsetLeft + element.offsetWidth / 2; | |
30 var centerY = element.offsetTop + element.offsetHeight / 2; | |
31 eventSender.mouseMoveTo(centerX, centerY); | |
32 } | |
33 | |
34 function dragFilesOntoInput(input, files) { | |
35 eventSender.beginDragWithFiles(files); | |
36 moveMouseToCenterOfElement(input); | |
37 eventSender.mouseUp(); | |
38 } | |
39 </script> | 28 </script> |
40 </body> | 29 </body> |
41 </html> | 30 </html> |
OLD | NEW |