Missing cursor/caret showing in search field on google.com
[WebKit-https.git] / LayoutTests / editing / selection / context-menu-text-selection.html
1 <body onload="load()">
2 <p>This test checks that triggering the context menu selects/doesn't select as platform-appropriate.</p>
3 <div id="text">Lorem ipsum</div>
4 <div id="resultmac">RUNNING</div>
5 <div id="resultwin">RUNNING</div>
6 <div id="resultunix">RUNNING</div>
7 </body>
8 <script>
9 function test(platform, selectionExpected, result)
10 {
11     // clear selection
12     window.getSelection().removeAllRanges();
13
14     internals.settings.setEditingBehavior(platform);
15
16     var text = document.getElementById("text");
17
18     var x = text.offsetParent.offsetLeft + text.offsetLeft + 4;
19     var y = text.offsetParent.offsetTop + text.offsetTop + text.offsetHeight / 2;
20
21     eventSender.mouseMoveTo(x, y);
22     eventSender.contextClick();
23     // esc key to kill the context menu
24     eventSender.keyDown(String.fromCharCode(0x001B), null);
25
26     var resultElement = document.getElementById(result);
27     var selectionType = window.getSelection().type;
28     if (selectionExpected) {
29         if (selectionType == "Range")
30             resultElement.innerHTML = "SUCCESS";
31         else
32             resultElement.innerHTML = "FAILURE: There should be a selection.";
33     } else {
34         if (selectionType == "Range")
35             resultElement.innerHTML = "FAILURE: There shouldn't be a selection.";
36         else
37             resultElement.innerHTML = "SUCCESS";
38     }
39 }
40
41 function load()
42 {
43     if (!window.eventSender || !window.testRunner || !window.internals)
44         return;
45
46     testRunner.dumpAsText();
47
48     test('mac', true, 'resultmac');
49     test('win', false, 'resultwin');
50     test('unix', false, 'resultunix');
51 }
52 </script>