Additional selection tests and interpolation fix
[WebKit-https.git] / LayoutTests / fast / events / touch / ios / long-press-then-drag-right-to-change-selected-text.html
1 <!DOCTYPE html>
2
3 <html>
4 <head>
5     <script src="resources/basic-gestures.js"></script>
6     <script>
7         if (window.testRunner) {
8             testRunner.dumpAsText();
9             testRunner.waitUntilDone();
10         }
11     
12         function runTest()
13         {
14             if (!testRunner.runUIScript)
15                 return;
16
17             var output = '';
18             var target = document.getElementById('target');
19             
20             if (testRunner.runUIScript) {
21                 testRunner.runUIScript(pressAtPoint(110, 104), function(result) {
22                     if (document.getSelection().toString() == "magna")
23                         output += 'PASS: Correct Selection';
24                     else
25                         output += 'FAIL: failed to select a word as a result of a long press';
26                     output += '<br>';
27
28                     testRunner.runUIScript(dragFromPointToPoint(139,120,224,120), function(result) {
29                         if (document.getSelection().toString() == "magna aliqua.")
30                             output += 'PASS: Correct Selection';
31                         else
32                             output += 'FAIL: failed to select additional line after a drag.' + document.getSelection().toString()
33                         output += '<br>';
34                                           
35                         testRunner.runUIScript(dragFromPointToPoint(224,120,255,120), function(result) {
36                             if (document.getSelection().toString() == "magna aliqua. Ut ")
37                                 output += 'PASS: Correct Selection';
38                             else
39                                 output += 'FAIL: failed to select additional line after a drag.' + document.getSelection().toString()+'/end'
40                             output += '<br>';
41
42                             testRunner.runUIScript(dragFromPointToPoint(255,120,224,120), function(result) {
43                                 if (document.getSelection().toString() == "magna aliqua.")
44                                     output += 'PASS: Correct Selection';
45                                 else
46                                     output += 'FAIL: failed to deselect line after a drag.' + document.getSelection().toString()
47                                 output += '<br>';
48
49                                 testRunner.runUIScript(dragFromPointToPoint(224,120,139,120), function(result) {
50                                     if (document.getSelection().toString() == "magna")
51                                         output += 'PASS: Correct Selection';
52                                     else
53                                         output += 'FAIL: failed to deselect line after a drag.' + document.getSelection().toString()
54                                     output += '<br>';
55                             
56                                     testRunner.runUIScript(dragFromPointToPoint(139,120,40,120), function(result) {
57                                         if (document.getSelection().toString() == "m")
58                                             output += 'PASS: Correct Selection';
59                                         else
60                                             output += 'FAIL: failed to reduce selection to a single character by dragging up.'
61                                         output += '<br>';
62                                         output += result;
63                                         document.getElementById('target').innerHTML = output;
64                                         testRunner.notifyDone();
65                                     });
66                                 });
67                             });
68                         });
69                     });
70                 });
71             }
72         }
73
74         window.addEventListener('load', runTest, false);
75     </script>
76     <style>
77         #target {
78             height: 400px;
79             width: 300px;
80             background-color: silver;
81             font-family: monospace;
82             font-size: 18px;
83         }
84     </style>
85 </head>
86 <body>
87 <div id="target">
88     <p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.</p>
89
90     This test requires UIScriptController to run.
91 </div>
92 </body>
93 </html>