Use testRunner instead of layoutTestController in fast/doctypes, dom, dynamic, encodi...
[WebKit-https.git] / LayoutTests / fast / events / drag-selects-image.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script>
5     function log(str)
6     {
7         var result = document.getElementById('result');
8         result.appendChild(document.createTextNode(str));
9         result.appendChild(document.createElement('br'));
10     }
11     function dragNowhere(element)
12     {
13         eventSender.mouseMoveTo(element.offsetLeft + element.offsetWidth / 2,
14                                 element.offsetTop + element.offsetHeight / 2);
15         eventSender.mouseDown();
16         eventSender.leapForward(100);
17         eventSender.mouseMoveTo(element.offsetLeft + 1, element.offsetHeight + 1);
18         eventSender.mouseUp();
19     }
20     window.onload = function()
21     {
22         if (!window.testRunner)
23             return;
24         testRunner.dumpAsText();
25
26         log('Starting test...');
27         log(window.getSelection().rangeCount + ' range(s) selected');
28         log('Dragging image in non-editable area...');
29         dragNowhere(document.getElementById('imageOne'));
30         log(window.getSelection().rangeCount + ' range(s) selected');
31         log('Dragging image in editable area...');
32         dragNowhere(document.getElementById('imageTwo'));
33         log(window.getSelection().rangeCount + ' range(s) selected');
34         if (window.getSelection().rangeCount && window.getSelection().containsNode(document.getElementById('imageTwo')))
35           log('imageTwo is selected');
36     }
37 </script>
38 </head>
39 <body>
40 <div>
41 <h3>Non-editable area</h3>
42 <img id="imageOne" src="resources/abe.png">
43 </div>
44 <div contenteditable="true">
45 <h3>Editable area</h3>
46 <img id="imageTwo" src="resources/onload-image.png">
47 </div>
48 <p>This tests that images are properly left selected or unselected when an image drag is started.
49 Only the image in the editable area should be selected when an image drag is started.
50 <div id="result">
51 </div>
52 </body>
53 </html>