Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / fast / events / selectstart-by-drag.html
blobede669d1abe5447f5e9b2cc1c34f9e2342d9f010
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <p>This test ensures selectstart is fired exactly once when selecting text by a mouse drag.
5 </p><span style='font-size: 50px; padding: 10px;' contenteditable>hello
6 </span><pre><script>
8 var span = document.getElementsByTagName('span')[0];
9 span.focus();
11 var selectStartCount = 0;
12 span.addEventListener('selectstart', function (event) { selectStartCount++; });
14 function expect(title, expectedCount, expectedType) {
15 document.write(title + ': ');
16 var actualSelectionType = window.getSelection().isCollapsed ? 'caret' : 'range';
18 if (selectStartCount != expectedCount)
19 document.writeln('FAIL - expected ' + expectedCount + ' events but got ' + selectStartCount + ' events');
20 else if (actualSelectionType != expectedType)
21 document.writeln('FAIL - expected selection to be ' + expectedType + ' but was ' + actualSelectionType);
22 else
23 document.writeln('PASS');
26 if (window.testRunner && !window.eventSender)
27 document.write('This test requires eventSender');
28 else if (window.testRunner) {
29 testRunner.dumpAsText();
31 var y = span.offsetTop + span.offsetHeight / 2;
33 function leapForwardAndMove(x) {
34 eventSender.leapForward(200);
35 eventSender.mouseMoveTo(span.offsetLeft + x, y);
38 expect('Initial state', 0, 'caret');
39 eventSender.dragMode = false;
40 eventSender.mouseMoveTo(span.offsetLeft + 5, y);
41 eventSender.mouseDown();
42 expect('Mouse down', 1, 'caret');
44 leapForwardAndMove(5);
45 expect('Moving slightly to the right', 1, 'caret');
47 leapForwardAndMove(-5);
48 expect('Moving slightly to the left', 1, 'caret');
50 leapForwardAndMove(span.offsetWidth / 2);
51 expect('Moving to the right', 1, 'range');
53 leapForwardAndMove(span.offsetWidth);
54 expect('Moving further to the right', 1, 'range');
56 leapForwardAndMove(0);
57 expect('Moving back to the left', 1, 'caret');
59 leapForwardAndMove(span.offsetWidth);
60 expect('Moving to the right again', 1, 'range');
62 eventSender.mouseUp();
63 window.getSelection().collapse(span, 0);
64 eventSender.leapForward(1000);
66 eventSender.mouseMoveTo(span.offsetLeft + span.offsetWidth - 5, y);
67 eventSender.mouseDown();
68 expect('Mouse down on the right', 2, 'caret');
70 leapForwardAndMove(span.offsetWidth / 2);
71 expect('Moving to the left', 2, 'range');
73 eventSender.mouseUp();
75 document.writeln('Done.');
76 span.parentNode.removeChild(span);
79 </script></pre>
80 </body>
81 </html>