Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / forms / file / selected-files-from-history-state.html
blobc1119c58e10243502480f570d78c0dc3920f74e9
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../../resources/js-test.js"></script>
5 <script>
6 window.jsTestIsAsync = true;
7 function onLoad() {
8 setTimeout(runTest, 0);
11 function runTest() {
12 if (!window.internals) {
13 testFailed('This test requires window.internals.');
14 return;
17 var onChangeFired = 0;
18 var input1 = document.getElementById('fileinput1');
19 input1.onchange = function() {
20 ++onChangeFired;
22 var input2 = document.getElementById('fileinput2');
23 input2.onchange = function() {
24 ++onChangeFired;
27 eventSender.beginDragWithFiles(['testpath1/testfile1.txt']);
28 var centerX = input1.offsetLeft + input1.offsetWidth / 2;
29 var centerY = input1.offsetTop + input1.offsetHeight / 2;
30 eventSender.mouseMoveTo(centerX, centerY);
31 eventSender.mouseUp();
33 eventSender.beginDragWithFiles(['testpath2/testfile2.txt']);
34 centerX = input2.offsetLeft + input2.offsetWidth / 2;
35 centerY = input2.offsetTop + input2.offsetHeight / 2;
36 eventSender.mouseMoveTo(centerX, centerY);
37 eventSender.mouseUp();
39 if (onChangeFired != 2) {
40 testFailed('onchange fired unexpected times: ' + onChangeFired);
43 var files = internals.getReferencedFilePaths();
44 files.sort();
45 if (files.length == 2 &&
46 files[0].indexOf('testfile1.txt') != -1 &&
47 files[0].indexOf('testpath1') != -1 &&
48 files[1].indexOf('testfile2.txt') != -1 &&
49 files[1].indexOf('testpath2') != -1) {
50 testPassed('');
51 } else {
52 testFailed('Unexpected files: ' + files);
54 finishJSTest();
56 </script>
57 </head>
58 <body onload="onLoad();">
59 <p id="description">Tests that selected files in file input elements are correctly retrieved by FormController::getReferencedFilePaths.</p>
60 <div id="container">
61 <form id="form1">
62 <input id="fileinput1" type="file" />
63 </form>
64 <form id="form2">
65 <input id="fileinput2" type="file" />
66 </form>
67 </div>
68 <div id="console"></div>
69 </body>
70 </html>