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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-execcommand.html

Issue 2151353002: [InputEvent] Replace |EditAction| with |InputType| (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@inputevent-text-styling
Patch Set: Replaced |EditAction| with |InputType| 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
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-keyboard.html » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <head> 3 <head>
4 <title>InputEvent: execCommand test</title> 4 <title>InputEvent: execCommand test</title>
5 <script src="../../../resources/testharness.js"></script> 5 <script src="../../../resources/testharness.js"></script>
6 <script src="../../../resources/testharnessreport.js"></script> 6 <script src="../../../resources/testharnessreport.js"></script>
7 </head> 7 </head>
8 <body> 8 <body>
9 <p id="txt" contenteditable></p> 9 <p id="txt" contenteditable></p>
10 <script> 10 <script>
11 test(function() { 11 test(function() {
12 var lastBeforeInputType = ''; 12 var lastBeforeInputType = '';
13 var lastInputType = ''; 13 var lastInputType = '';
14 var txt = document.getElementById('txt'); 14 var txt = document.getElementById('txt');
15 txt.addEventListener('beforeinput', function(event) { 15 txt.addEventListener('beforeinput', function(event) {
16 assert_true(event instanceof InputEvent); 16 assert_true(event instanceof InputEvent);
17 assert_false(event.isComposing); 17 assert_false(event.isComposing);
18 lastBeforeInputType = event.inputType; 18 lastBeforeInputType = event.inputType;
19 }); 19 });
20 txt.addEventListener('input', function(event) { 20 txt.addEventListener('input', function(event) {
21 assert_true(event instanceof InputEvent); 21 assert_true(event instanceof InputEvent);
22 assert_false(event.isComposing); 22 assert_false(event.isComposing);
23 lastInputType = event.inputType; 23 lastInputType = event.inputType;
24 }); 24 });
25 if (!window.eventSender) { 25 if (!window.eventSender) {
26 document.write('This test requires eventSender'); 26 document.write('This test requires eventSender');
27 } else { 27 } else {
28 var kNoInputEventFired = 'noInputEventFired'; 28 const NO_INPUT_EVENT_FIRED = 'NO_INPUT_EVENT_FIRED';
29 function testExecCommandInputType(command, args, inputType) { 29 function testExecCommandInputType(command, args, inputType) {
30 lastBeforeInputType = kNoInputEventFired; 30 lastBeforeInputType = NO_INPUT_EVENT_FIRED;
31 lastInputType = kNoInputEventFired; 31 lastInputType = NO_INPUT_EVENT_FIRED;
32 document.execCommand(command, false, args); 32 document.execCommand(command, false, args);
33 assert_equals(lastBeforeInputType, kNoInputEventFired, `execCommand( ${command}, false, ${args}) shouldn't fire beforeinput`); 33 assert_equals(lastBeforeInputType, NO_INPUT_EVENT_FIRED, `execComman d(${command}, false, ${args}) shouldn't fire beforeinput`);
34 assert_equals(lastInputType, inputType, `execCommand(${command}, fal se, ${args}) should produce inputType: ${inputType}`); 34 assert_equals(lastInputType, inputType, `execCommand(${command}, fal se, ${args}) should produce inputType: ${inputType}`);
35 } 35 }
36 36
37 txt.focus(); 37 txt.focus();
38 // InsertText 38 // InsertText
39 testExecCommandInputType('insertText', 'a', 'insertText'); 39 testExecCommandInputType('insertText', 'a', 'insertText');
40 testExecCommandInputType('insertText', 'bc', 'insertText'); 40 testExecCommandInputType('insertText', 'bc', 'insertText');
41 assert_equals(txt.innerHTML, 'abc'); 41 assert_equals(txt.innerHTML, 'abc');
42 testExecCommandInputType('insertOrderedList', null, 'insertOrderedList') ;
43 assert_equals(txt.innerHTML, '<ol><li>abc<br></li></ol>');
44 testExecCommandInputType('insertUnorderedList', null, 'insertUnorderedLi st');
45 assert_equals(txt.innerHTML, '<ul><li>abc<br></li></ul>');
46 testExecCommandInputType('insertLineBreak', null, 'insertLineBreak');
47 testExecCommandInputType('insertParagraph', null, 'insertParagraph');
42 48
43 // Styling 49 // Styling
50 txt.innerHTML = 'abc';
44 var selection = window.getSelection(); 51 var selection = window.getSelection();
45 selection.collapse(txt, 0); 52 selection.collapse(txt, 0);
46 selection.extend(txt, 1); 53 selection.extend(txt, 1);
47 testExecCommandInputType('bold', null, 'bold'); 54 testExecCommandInputType('bold', null, 'bold');
48 assert_equals(txt.innerHTML, '<b>abc</b>'); 55 assert_equals(txt.innerHTML, '<b>abc</b>');
49 testExecCommandInputType('italic', null, 'italic'); 56 testExecCommandInputType('italic', null, 'italic');
50 assert_equals(txt.innerHTML, '<b><i>abc</i></b>'); 57 assert_equals(txt.innerHTML, '<b><i>abc</i></b>');
51 testExecCommandInputType('underline', null, 'underline'); 58 testExecCommandInputType('underline', null, 'underline');
52 assert_equals(txt.innerHTML, '<b><i><u>abc</u></i></b>'); 59 assert_equals(txt.innerHTML, '<b><i><u>abc</u></i></b>');
53 testExecCommandInputType('strikeThrough', null, 'strikeThrough'); 60 testExecCommandInputType('strikeThrough', null, 'strikeThrough');
54 assert_equals(txt.innerHTML, '<b><i><u><strike>abc</strike></u></i></b>' ); 61 assert_equals(txt.innerHTML, '<b><i><u><strike>abc</strike></u></i></b>' );
55 testExecCommandInputType('superscript', null, 'superscript'); 62 testExecCommandInputType('superscript', null, 'superscript');
56 assert_equals(txt.innerHTML, '<b><i><u><strike><sup>abc</sup></strike></ u></i></b>'); 63 assert_equals(txt.innerHTML, '<b><i><u><strike><sup>abc</sup></strike></ u></i></b>');
57 testExecCommandInputType('subscript', null, 'subscript'); 64 testExecCommandInputType('subscript', null, 'subscript');
58 assert_equals(txt.innerHTML, '<b><i><u><strike><sub>abc</sub></strike></ u></i></b>'); 65 assert_equals(txt.innerHTML, '<b><i><u><strike><sub>abc</sub></strike></ u></i></b>');
59 66
67 // Formating
68 txt.innerHTML = 'abc';
69 testExecCommandInputType('justifyCenter', null, 'justifyCenter');
70 assert_equals(txt.innerHTML, '<div style="text-align: center;">abc</div> ');
71 testExecCommandInputType('justifyFull', null, 'justifyFull');
72 assert_equals(txt.innerHTML, '<div style="text-align: justify;">abc</div >');
73 testExecCommandInputType('justifyRight', null, 'justifyRight');
74 assert_equals(txt.innerHTML, '<div style="text-align: right;">abc</div>' );
75 testExecCommandInputType('justifyLeft', null, 'justifyLeft');
76 assert_equals(txt.innerHTML, '<div style="text-align: left;">abc</div>') ;
77 selection.collapse(txt, 0);
78 selection.extend(txt, 1);
79 testExecCommandInputType('removeFormat', null, 'removeFormat');
80 assert_equals(txt.innerHTML, '<div>abc</div>');
81 testExecCommandInputType('indent', null, 'indent');
82 testExecCommandInputType('outdent', null, 'outdent');
83 assert_equals(txt.innerHTML, '<div>abc</div>');
84
60 // Copy shouldn't fire 'input'. 85 // Copy shouldn't fire 'input'.
61 testExecCommandInputType('copy', null, kNoInputEventFired); 86 testExecCommandInputType('copy', null, NO_INPUT_EVENT_FIRED);
62 // Paste should fire 'input'. 87 // Cut/Paste should fire 'input'.
63 // TODO(chongz): Add |inputType| for 'paste'. 88 testExecCommandInputType('cut', null, 'cut');
64 testExecCommandInputType('paste', null, ''); 89 testExecCommandInputType('paste', null, 'paste');
65 } 90 }
66 }, 'Testing input with execCommand'); 91 }, 'Testing input with execCommand');
67 </script> 92 </script>
68 </body> 93 </body>
69 </html> 94 </html>
OLDNEW
« no previous file with comments | « no previous file | third_party/WebKit/LayoutTests/fast/events/inputevents/inputevent-keyboard.html » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698