395e02d193bb911bfbff8004ff700858f06c8317
[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 the filenames 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 result = editable.innerHTML.replace(/file.*?LayoutTests/g, "LayoutTests");
16     shouldBeEqualToString('result', '<div>LayoutTests/editing/pasteboard/foo</div><div>LayoutTests/editing/pasteboard/bar</div><div>LayoutTests/editing/pasteboard/baz</div>');
17     editable.innerHTML = '';
18 }
19
20 function moveMouseToCenterOfElement(element)
21 {
22     var centerX = element.offsetLeft + element.offsetWidth / 2;
23     var centerY = element.offsetTop + element.offsetHeight / 2;
24     eventSender.mouseMoveTo(centerX, centerY);
25 }
26
27 function dragFilesOntoEditable(files)
28 {
29     eventSender.beginDragWithFiles(files);
30     moveMouseToCenterOfElement(editable);
31     eventSender.mouseUp();
32 }
33
34 var successfullyParsed = true;
35 </script>
36 <script src="../../resources/js-test-post.js"></script>
37 </body>
38 </html>