Editing tests should use testRunner instead of layoutTestController
[WebKit-https.git] / LayoutTests / editing / selection / resources / caret-edge-shared.js
1
2 function runTest() {
3     var div = document.getElementsByTagName('div')[0];
4
5     if (!window.testRunner)
6         return;
7
8     if (clickOn == 'left')
9         x = 5;
10     else
11         x = div.offsetWidth - 5;
12
13     eventSender.mouseMoveTo(div.offsetLeft + x, div.offsetTop + div.offsetHeight / 2);
14     eventSender.leapForward(200);
15     eventSender.mouseDown();
16     eventSender.leapForward(200);
17     eventSender.mouseUp();
18     verify();
19 }
20
21 function verify() {
22     var div = document.getElementsByTagName('div')[0];
23
24     if (!window.getSelection().isCollapsed)
25         return log('FAIL: selection not collapsed');
26
27     var range = window.getSelection().getRangeAt(0);
28     if (range.startContainer != div.firstChild)
29         return log('FAIL: wrong container');
30     if (range.startOffset != expectedOffset)
31         return log('FAIL: wrong offset ' + range.startOffset + ', expected ' + expectedOffset);
32
33     return log('PASS');
34 }
35
36 function log(message) {
37     document.body.appendChild(document.createTextNode(message));
38     document.body.appendChild(document.createElement('br'));
39 }