<attachment>s should be created when dropping files onto contentEditable areas
[WebKit-https.git] / LayoutTests / editing / pasteboard / drag-files-to-editable-element.html
1 <html>
2 <head>
3 <script src="../../resources/js-test-pre.js"></script>
4 </head>
5 <body>
6 <p id="description"></p>
7 <div id="console"></div>
8 <div id="editable" contentEditable=true style="width:200px; height:200px"></div>
9 <script>
10 description('If we drag files onto an editable area, then attachments should be inserted into the editable area.');
11
12 var editable = document.getElementById("editable");
13 if (window.eventSender) {
14     dragFilesOntoEditable(['foo', 'bar', 'baz']);
15     var resultChildren = editable.children;
16     var fileNames = "";
17     for (var i = 0; i < resultChildren.length; i++) {
18         var attachment = resultChildren[i];
19         shouldBeEqualToString('attachment.nodeName', 'ATTACHMENT');
20         fileNames += attachment.file.name + " ";
21     }
22     shouldBeEqualToString('fileNames', 'foo bar baz ');
23     editable.innerHTML = '';
24 }
25
26 function moveMouseToCenterOfElement(element)
27 {
28     var centerX = element.offsetLeft + element.offsetWidth / 2;
29     var centerY = element.offsetTop + element.offsetHeight / 2;
30     eventSender.mouseMoveTo(centerX, centerY);
31 }
32
33 function dragFilesOntoEditable(files)
34 {
35     eventSender.beginDragWithFiles(files);
36     moveMouseToCenterOfElement(editable);
37     eventSender.mouseUp();
38 }
39
40 var successfullyParsed = true;
41 </script>
42 <script src="../../resources/js-test-post.js"></script>
43 </body>
44 </html>