Change log level: info -> debug
[framework/web/webkit-efl.git] / LayoutTests / editing / pasteboard / data-transfer-items-drag-drop-entry.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     directory: false,
14     size: 2593 },
15   { path: 'resources/drop-file-svg.svg',
16     directory: false,
17     size: 109 },
18   { path: 'resources/copy-backslash-euc.html',
19     directory: false,
20     size: 478 },
21   { path: 'resources/test_directory',
22     directory: true,
23     size: 0 }
24 ];
25
26 function log(text)
27 {
28     var console = document.getElementById('console');
29     console.appendChild(document.createTextNode(text));
30     console.appendChild(document.createElement('br'));
31 }
32
33 function test(expect, actual)
34 {
35     log((expect == actual ? 'PASS' : 'FAIL') + ': "' + expect + '" == "' + actual + '"');
36 }
37
38 function startTest()
39 {
40     var destination = document.getElementById('destination');
41     destination.addEventListener('dragover', handleDragOver, false);
42     destination.addEventListener('drop', handleDrop, false);
43
44     if (!window.testRunner)
45         return;
46     testRunner.waitUntilDone();
47     testRunner.dumpAsText();
48
49     var files = [];
50     for (var i = 0; i < testFiles.length; ++i) {
51       log('Dragging file: ' + testFiles[i].path);
52       files.push(testFiles[i].path);
53     }
54
55     // Perform drag-and-drop with the testFiles.
56     eventSender.beginDragWithFiles(files);
57     eventSender.leapForward(100);
58     eventSender.mouseMoveTo(destination.offsetLeft + 10, destination.offsetTop + destination.offsetHeight / 2);
59     eventSender.mouseUp();
60 }
61
62 function handleDragOver(e)
63 {
64     e.stopPropagation();
65     e.preventDefault();
66 }
67
68 function handleDrop(e)
69 {
70     e.stopPropagation();
71     e.preventDefault();
72
73     log('Verifying contents of DataTransferItems...');
74     var items = e.dataTransfer.items;
75     var files = [];
76     test(testFiles.length, items.length);
77     for (var i = 0; i < items.length; ++i) {
78         // The items should be in the same order as we added.
79         var expected = testFiles[i];
80         var file = items[i].getAsFile();
81         files.push(file);
82
83         test('file', items[i].kind);
84         var entry = items[i].webkitGetAsEntry();
85         log('entry: ' + entry.fullPath + (entry.isDirectory ? ' [dir]' : ' [file]'));
86
87         var components = expected.path.split('/');
88         var name = components[components.length - 1];
89         test('/' + name, entry.fullPath);
90         test(expected.directory, entry.isDirectory);
91
92         with ({last: i + 1 == items.length, expected: expected}) {
93             entry.getMetadata(function(metadata) {
94                 if (!expected.directory)
95                     test(expected.size, metadata.size);
96                 if (last && window.testRunner)
97                     testRunner.notifyDone();
98             });
99         }
100     }
101 }
102
103 startTest();
104
105 </script>
106 </body>
107 </html>