| <html> | |
| <head> | |
| <style> | |
| .editing { | |
| border: 2px solid red; | |
| padding: 12px; | |
| font-size: 24px; | |
| } | |
| </style> | |
| <script src=../editing.js language="JavaScript" type="text/JavaScript" ></script> | |
| <script> | |
| function log(str) | |
| { | |
| var li = document.createElement("li"); | |
| li.appendChild(document.createTextNode(str)); | |
| var console = document.getElementById("console"); | |
| console.appendChild(li); | |
| } | |
| function convertStringToUnicode(string) | |
| { | |
| var returnValue = " (character in Unicode value): "; | |
| for (var i = 0; i < string.length; ++i) | |
| { | |
| returnValue += " " + string.charCodeAt(i); | |
| } | |
| return returnValue; | |
| } | |
| function assertEqual(test_name, actual, expected) | |
| { | |
| if (actual != expected) { | |
| log("=================================="); | |
| log("FAILED: " + test_name); | |
| var actual_string = "actual" + convertStringToUnicode(actual); | |
| var expected_string = "expected" + convertStringToUnicode(expected); | |
| log(actual_string); | |
| log(expected_string); | |
| } | |
| } | |
| function test(element) | |
| { | |
| var textarea = document.getElementById(element + "1"); | |
| textarea.focus(); | |
| // Type in unicode bidi control character in the middle of a string. | |
| typeCharacterCommand('a'); | |
| typeCharacterCommand(String.fromCharCode(0x202B)); | |
| typeCharacterCommand('b'); | |
| typeCharacterCommand('!'); | |
| typeCharacterCommand(String.fromCharCode(0x202C)); | |
| var string = textarea.innerHTML; | |
| assertEqual("type a‫b!‬", string, "a\u202Bb!\u202c"); | |
| // Copy and past string contains unicode bidi control character in the middle. | |
| document.execCommand("SelectAll"); | |
| copyCommand(); | |
| textarea = document.getElementById(element + "3"); | |
| textarea.focus(); | |
| pasteCommand(); | |
| string = textarea.innerHTML; | |
| assertEqual("copy/paste a‫b!‬", string, "a\u202Bb!\u202c"); | |
| textarea = document.getElementById(element + "2"); | |
| textarea.focus(); | |
| // Type in unicode bidi control character as the beginning of a string. | |
| typeCharacterCommand(String.fromCharCode(0x202B)); | |
| typeCharacterCommand('b'); | |
| typeCharacterCommand('!'); | |
| typeCharacterCommand(String.fromCharCode(0x202C)); | |
| string = textarea.innerHTML; | |
| assertEqual("type ‫b!‬", string, "\u202Bb!\u202c"); | |
| // Copy and past string contains unicode bidi control character at the beginning. | |
| document.execCommand("SelectAll"); | |
| copyCommand(); | |
| textarea = document.getElementById(element + "4"); | |
| textarea.focus(); | |
| pasteCommand(); | |
| string = textarea.innerHTML; | |
| assertEqual("copy/paste ‫b!‬", string, "\u202Bb!\u202c"); | |
| } | |
| onload = function() | |
| { | |
| if (window.testRunner) | |
| testRunner.dumpAsText(); | |
| test("div"); | |
| } | |
| </script> | |
| <title>Editing Test</title> | |
| </head> | |
| <body> | |
| <div contenteditable id="div1" class="editing"></div> | |
| <div contenteditable id="div2" class="editing"></div> | |
| <div contenteditable id="div3" class="editing"></div> | |
| <div contenteditable id="div4" class="editing"></div> | |
| <ul id="console"></ul> | |
| </body> | |
| </html> |