| OLD | NEW |
| 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> |
| (...skipping 20 matching lines...) Expand all Loading... |
| 31 lastInputType = kNoInputEventFired; | 31 lastInputType = kNoInputEventFired; |
| 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, kNoInputEventFired, `execCommand(
${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('abc', txt.innerHTML); | 41 assert_equals(txt.innerHTML, 'abc'); |
| 42 | 42 |
| 43 // Styling | 43 // Styling |
| 44 var selection = window.getSelection(); | 44 var selection = window.getSelection(); |
| 45 selection.collapse(txt, 0); | 45 selection.collapse(txt, 0); |
| 46 selection.extend(txt, 1); | 46 selection.extend(txt, 1); |
| 47 // TODO(chongz): Add |inputType| for 'bold'. | 47 testExecCommandInputType('bold', null, 'bold'); |
| 48 testExecCommandInputType('bold', 'bc', ''); | 48 assert_equals(txt.innerHTML, '<b>abc</b>'); |
| 49 assert_equals('<b>abc</b>', txt.innerHTML); | 49 testExecCommandInputType('italic', null, 'italic'); |
| 50 assert_equals(txt.innerHTML, '<b><i>abc</i></b>'); |
| 51 testExecCommandInputType('underline', null, 'underline'); |
| 52 assert_equals(txt.innerHTML, '<b><i><u>abc</u></i></b>'); |
| 53 testExecCommandInputType('strikeThrough', null, 'strikeThrough'); |
| 54 assert_equals(txt.innerHTML, '<b><i><u><strike>abc</strike></u></i></b>'
); |
| 55 testExecCommandInputType('superscript', null, 'superscript'); |
| 56 assert_equals(txt.innerHTML, '<b><i><u><strike><sup>abc</sup></strike></
u></i></b>'); |
| 57 testExecCommandInputType('subscript', null, 'subscript'); |
| 58 assert_equals(txt.innerHTML, '<b><i><u><strike><sub>abc</sub></strike></
u></i></b>'); |
| 50 | 59 |
| 51 // Copy shouldn't fire 'input'. | 60 // Copy shouldn't fire 'input'. |
| 52 testExecCommandInputType('copy', null, kNoInputEventFired); | 61 testExecCommandInputType('copy', null, kNoInputEventFired); |
| 53 // Paste should fire 'input'. | 62 // Paste should fire 'input'. |
| 54 // TODO(chongz): Add |inputType| for 'paste'. | 63 // TODO(chongz): Add |inputType| for 'paste'. |
| 55 testExecCommandInputType('paste', null, ''); | 64 testExecCommandInputType('paste', null, ''); |
| 56 } | 65 } |
| 57 }, 'Testing input with execCommand'); | 66 }, 'Testing input with execCommand'); |
| 58 </script> | 67 </script> |
| 59 </body> | 68 </body> |
| 60 </html> | 69 </html> |
| OLD | NEW |