Change log level: info -> debug
[framework/web/webkit-efl.git] / LayoutTests / editing / pasteboard / data-transfer-items-drag-drop-file.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <div>This tests the basic functionality and properties of DataTransferItems for files with drag and drop. This test requires DRT.</div>
5
6 <div id="destination" style="min-height:100px; border: solid 1px black">Drop files here if you test this manually</div>
7
8 <div id="console"></div>
9
10 <script>
11 var testFiles = [
12   { path: 'resources/mozilla.gif',
13     type: 'image/gif',
14     size: 2593 },
15   { path: 'resources/drop-file-svg.svg',
16     type: 'image/svg+xml',
17     size: 109 },
18   { path: 'resources/copy-backslash-euc.html',
19     type: 'text/html',
20     size: 478 }
21 ];
22
23 function log(text)
24 {
25     var console = document.getElementById('console');
26     console.appendChild(document.createTextNode(text));
27     console.appendChild(document.createElement('br'));
28 }
29
30 function test(expect, actual)
31 {
32     log((expect == actual ? 'PASS' : 'FAIL') + ': "' + expect + '" == "' + actual + '"');
33 }
34
35 function startTest()
36 {
37     var destination = document.getElementById('destination');
38     destination.addEventListener('dragover', handleDragOver, false);
39     destination.addEventListener('drop', handleDrop, false);
40
41     if (!window.testRunner)
42         return;
43     testRunner.waitUntilDone();
44     testRunner.dumpAsText();
45
46     var files = [];
47     for (var i = 0; i < testFiles.length; ++i) {
48       log('Dragging file: ' + testFiles[i].path);
49       files.push(testFiles[i].path);
50     }
51
52     // Perform drag-and-drop with the testFiles.
53     eventSender.beginDragWithFiles(files);
54     eventSender.leapForward(500);
55     eventSender.mouseMoveTo(destination.offsetLeft + 10, destination.offsetTop + destination.offsetHeight / 2);
56     eventSender.mouseUp();
57 }
58
59 function handleDragOver(e)
60 {
61     e.stopPropagation();
62     e.preventDefault();
63 }
64
65 function handleDrop(e)
66 {
67     e.stopPropagation();
68     e.preventDefault();
69
70     log('Verifying contents of DataTransferItems...');
71     var items = e.dataTransfer.items;
72     var files = [];
73     test(testFiles.length, items.length);
74     for (var i = 0; i < items.length; ++i) {
75         // The items should be in the same order as we added.
76         var expected = testFiles[i];
77
78         var file = items[i].getAsFile();
79         files.push(file);
80
81         test('file', items[i].kind);
82         test(expected.type, items[i].type);
83         test(expected.type, file.type);
84         test(expected.size, file.size);
85
86         var components = expected.path.split('/');
87         var name = components[components.length - 1];
88         test(name, file.name);
89     }
90
91     testRunner.notifyDone();
92 }
93
94 startTest();
95
96 </script>
97 </body>
98 </html>