Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(173)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/selectstart-by-arrow-keys-prevent-default.html

Issue 2100243002: Remove non-standardize key code names from event_sender. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Fix inspector tests that were missed by sed Created 4 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <p>This test ensures selectstart event fires when selection is created by arrow key and script can prevent the selection change.</p> 4 <p>This test ensures selectstart event fires when selection is created by arrow key and script can prevent the selection change.</p>
5 If running this test manually, click on the div ("Hello World") and try to selec t the text using arrow keys.<br> 5 If running this test manually, click on the div ("Hello World") and try to selec t the text using arrow keys.<br>
6 Expected result: SelectStart event will fire when user starts extending the sele ction, but due to script preventDefault it prevents the selection change.<br> 6 Expected result: SelectStart event will fire when user starts extending the sele ction, but due to script preventDefault it prevents the selection change.<br>
7 <div contenteditable>Hello World</div> 7 <div contenteditable>Hello World</div>
8 <script> 8 <script>
9 9
10 10
11 var selectStartCount = 0; 11 var selectStartCount = 0;
12 var div = document.getElementsByTagName('div')[0]; 12 var div = document.getElementsByTagName('div')[0];
13 div.addEventListener('selectstart', function (event) { event.preventDefault(); s electStartCount++; }); 13 div.addEventListener('selectstart', function (event) { event.preventDefault(); s electStartCount++; });
14 div.focus(); 14 div.focus();
15 window.getSelection().collapse(div.firstChild, 1); 15 window.getSelection().collapse(div.firstChild, 1);
16 16
17 if (window.testRunner) { 17 if (window.testRunner) {
18 testRunner.dumpAsText(); 18 testRunner.dumpAsText();
19 eventSender.keyDown("rightArrow", ["shiftKey"]); 19 eventSender.keyDown("ArrowRight", ["shiftKey"]);
20 logResult("Check Right arrow + Shift", 1); 20 logResult("Check Right arrow + Shift", 1);
21 21
22 eventSender.keyDown("rightArrow", ["shiftKey"], ["ctrlKey"]); 22 eventSender.keyDown("ArrowRight", ["shiftKey"], ["ctrlKey"]);
23 logResult("Check Right arrow + Shift + Control", 2); 23 logResult("Check Right arrow + Shift + Control", 2);
24 24
25 eventSender.keyDown("end", ["shiftKey"]); 25 eventSender.keyDown("End", ["shiftKey"]);
26 logResult("Check End + Shift", 3); 26 logResult("Check End + Shift", 3);
27 } 27 }
28 28
29 function logResult(title, expectedCount) { 29 function logResult(title, expectedCount) {
30 var range = window.getSelection().getRangeAt(0); 30 var range = window.getSelection().getRangeAt(0);
31 document.write(title + ': '); 31 document.write(title + ': ');
32 if (selectStartCount != expectedCount) 32 if (selectStartCount != expectedCount)
33 document.write('FAIL - expected ' + expectedCount + ' events but got ' + selectStartCount + ' events'); 33 document.write('FAIL - expected ' + expectedCount + ' events but got ' + selectStartCount + ' events');
34 else if (range.startOffset != 1 || range.endOffset != 1) 34 else if (range.startOffset != 1 || range.endOffset != 1)
35 document.write('FAIL - selection changed'); 35 document.write('FAIL - selection changed');
36 else 36 else
37 document.write('PASS'); 37 document.write('PASS');
38 document.write('<br>'); 38 document.write('<br>');
39 } 39 }
40 40
41 </script> 41 </script>
42 </body> 42 </body>
43 </html> 43 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698