Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / clear-edit-drag-state.html
bloba62536cd6b997c85161cccb930cf03f50234d6f4
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <style type="text/css">
5 span, div { display: block; }
6 span {
7 background: green;
8 padding: 10px;
10 div {
11 background: red;
12 padding: 50px;
14 </style>
15 </head>
16 <body>
17 <p>This test ensures we clear the drag state at the end of each drag. To test manually, drag the green box below twice.
18 You should observe the same list of events in the same order twice.</p>
19 <div contenteditable>
20 <span>Drag me down twice!</span>
21 </div>
22 <pre id="log">
23 </pre>
24 <script>
26 function log(event) {
27 document.getElementById('log').textContent += event.target.localName + ':' + this.localName + ':' + event.type + '\n';
30 function setLog(log) {
31 var value = document.getElementById('log').textContent;
32 document.getElementById('log').textContent = log;
33 return value;
36 var div = document.querySelector('div');
37 div.addEventListener('dragover', function (event) { event.preventDefault(); });
38 div.addEventListener('dragenter', log);
39 div.addEventListener('dragleave', log);
41 var span = document.querySelector('span');
42 span.addEventListener('dragenter', log);
43 span.addEventListener('dragleave', log);
45 function dragSpan() {
46 var x = span.offsetLeft + span.offsetWidth / 2;
47 eventSender.mouseMoveTo(x, span.offsetTop + span.offsetHeight / 2);
48 eventSender.mouseDown();
49 eventSender.mouseMoveTo(x, span.offsetTop + 2 * span.offsetHeight / 3);
50 eventSender.leapForward(200);
51 eventSender.mouseMoveTo(x, span.offsetTop + 3 * span.offsetHeight / 2);
52 eventSender.leapForward(200);
53 eventSender.mouseUp();
56 if (window.eventSender) {
57 testRunner.dumpAsText();
58 getSelection().selectAllChildren(span);
59 dragSpan();
60 var firstLog = setLog('');
61 dragSpan();
62 var secondLog = setLog('PASS');
63 if (firstLog != secondLog)
64 setLog('FAIL:\nFirst drag:\n' + firstLog + '\nSecond drag:\n' + secondLog);
67 </script>
68 </body>
69 </html>