Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / selection / context-menu-text-selection.html
blob86f4a899713ef6df405e3d567a899def4f3e687b
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 <div id="resultandroid">RUNNING</div>
8 </body>
9 <script>
10 function test(platform, selectionExpected, result)
12 // clear selection
13 window.getSelection().removeAllRanges();
15 internals.settings.setEditingBehavior(platform);
17 var text = document.getElementById("text");
19 var x = text.offsetParent.offsetLeft + text.offsetLeft + 4;
20 var y = text.offsetParent.offsetTop + text.offsetTop + text.offsetHeight / 2;
22 eventSender.mouseMoveTo(x, y);
23 eventSender.contextClick();
24 // esc key to kill the context menu
25 eventSender.keyDown("escape", null);
27 var resultElement = document.getElementById(result);
28 var selectionType = window.getSelection().type;
29 if (selectionExpected) {
30 if (selectionType == "Range")
31 resultElement.innerHTML = "SUCCESS";
32 else
33 resultElement.innerHTML = "FAILURE: There should be a selection.";
34 } else {
35 if (selectionType == "Range")
36 resultElement.innerHTML = "FAILURE: There shouldn't be a selection.";
37 else
38 resultElement.innerHTML = "SUCCESS";
42 function load()
44 if (!window.eventSender || !window.testRunner || !window.internals)
45 return;
47 testRunner.dumpAsText();
49 test('mac', true, 'resultmac');
50 test('win', false, 'resultwin');
51 test('unix', false, 'resultunix');
52 test('android', false, 'resultandroid');
54 </script>