Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(193)

Side by Side Diff: LayoutTests/fast/forms/file/input-file-write-files.html

Issue 148983008: Reduce test code duplication in fast/forms/file (Closed) Base URL: https://chromium.googlesource.com/chromium/blink.git@master
Patch Set: Created 6 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
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="file1" id="file1"> 8 <input type="file" name="file1" id="file1">
8 <input type="file" name="file2" id="file2"> 9 <input type="file" name="file2" id="file2">
9 <script> 10 <script>
10 description("This tests the files attribute in file input forms"); 11 description("This tests the files attribute in file input forms");
11 12
12 if (window.testRunner) { 13 if (window.testRunner) {
13 var file1 = document.getElementById("file1"); 14 var file1 = document.getElementById("file1");
14 var file2 = document.getElementById("file2"); 15 var file2 = document.getElementById("file2");
15 dragFilesOntoInput(file1, ["foo.txt"]); 16 dragFilesOntoInput(file1, ["foo.txt"]);
16 dragFilesOntoInput(file2, ["bar.txt"]); 17 dragFilesOntoInput(file2, ["bar.txt"]);
17 18
18 file1.files = "foo"; 19 file1.files = "foo";
19 shouldBe("file1.files.length", "1"); 20 shouldBe("file1.files.length", "1");
20 shouldBeEqualToString("file1.files.item(0).name", "foo.txt"); 21 shouldBeEqualToString("file1.files.item(0).name", "foo.txt");
21 22
22 file1.files = null; 23 file1.files = null;
23 shouldBe("file1.files.length", "1"); 24 shouldBe("file1.files.length", "1");
24 shouldBeEqualToString("file1.files.item(0).name", "foo.txt"); 25 shouldBeEqualToString("file1.files.item(0).name", "foo.txt");
25 26
26 // From current W3C spec, files attribute should be read only, 27 // From current W3C spec, files attribute should be read only,
27 // but WebKit implement it to be writable intentionally. 28 // but WebKit implement it to be writable intentionally.
28 // See: https://bugs.webkit.org/show_bug.cgi?id=87154#c15 29 // See: https://bugs.webkit.org/show_bug.cgi?id=87154#c15
29 file1.files = file2.files; 30 file1.files = file2.files;
30 shouldBe("file1.files.length", "1"); 31 shouldBe("file1.files.length", "1");
31 shouldBeEqualToString("file1.files.item(0).name", "bar.txt"); 32 shouldBeEqualToString("file1.files.item(0).name", "bar.txt");
32 } 33 }
33
34 function moveMouseToCenterOfElement(element) {
35 var centerX = element.offsetLeft + element.offsetWidth / 2;
36 var centerY = element.offsetTop + element.offsetHeight / 2;
37 eventSender.mouseMoveTo(centerX, centerY);
38 }
39
40 function dragFilesOntoInput(input, files) {
41 eventSender.beginDragWithFiles(files);
42 moveMouseToCenterOfElement(input);
43 eventSender.mouseUp();
44 }
45 </script> 34 </script>
46 </body> 35 </body>
47 </html> 36 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698