Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / inserting / insert-paste-bidi-control.html
blob40a5961f0ae2644256d2c22c7b84eae2f32fe23a
1 <html>
2 <head>
4 <style>
5 .editing {
6 border: 2px solid red;
7 padding: 12px;
8 font-size: 24px;
10 </style>
11 <script src=../editing.js language="JavaScript" type="text/JavaScript" ></script>
13 <script>
14 function log(str)
16 var li = document.createElement("li");
17 li.appendChild(document.createTextNode(str));
18 var console = document.getElementById("console");
19 console.appendChild(li);
22 function convertStringToUnicode(string)
24 var returnValue = " (character in Unicode value): ";
25 for (var i = 0; i < string.length; ++i)
27 returnValue += " " + string.charCodeAt(i);
29 return returnValue;
32 function assertEqual(test_name, actual, expected)
34 if (actual != expected) {
35 log("==================================");
36 log("FAILED: " + test_name);
37 var actual_string = "actual" + convertStringToUnicode(actual);
38 var expected_string = "expected" + convertStringToUnicode(expected);
39 log(actual_string);
40 log(expected_string);
45 function test(element)
47 var textarea = document.getElementById(element + "1");
48 textarea.focus();
49 // Type in unicode bidi control character in the middle of a string.
50 typeCharacterCommand('a');
51 typeCharacterCommand(String.fromCharCode(0x202B));
52 typeCharacterCommand('b');
53 typeCharacterCommand('!');
54 typeCharacterCommand(String.fromCharCode(0x202C));
56 var string = textarea.innerHTML;
57 assertEqual("type a&#x202B;b!&#x202C;", string, "a\u202Bb!\u202c");
59 // Copy and past string contains unicode bidi control character in the middle.
60 document.execCommand("SelectAll");
61 copyCommand();
62 textarea = document.getElementById(element + "3");
63 textarea.focus();
64 pasteCommand();
66 string = textarea.innerHTML;
67 assertEqual("copy/paste a&#x202B;b!&#x202C;", string, "a\u202Bb!\u202c");
69 textarea = document.getElementById(element + "2");
70 textarea.focus();
71 // Type in unicode bidi control character as the beginning of a string.
72 typeCharacterCommand(String.fromCharCode(0x202B));
73 typeCharacterCommand('b');
74 typeCharacterCommand('!');
75 typeCharacterCommand(String.fromCharCode(0x202C));
77 string = textarea.innerHTML;
78 assertEqual("type &#x202B;b!&#x202C;", string, "\u202Bb!\u202c");
80 // Copy and past string contains unicode bidi control character at the beginning.
81 document.execCommand("SelectAll");
82 copyCommand();
83 textarea = document.getElementById(element + "4");
84 textarea.focus();
85 pasteCommand();
87 string = textarea.innerHTML;
88 assertEqual("copy/paste &#x202B;b!&#x202C;", string, "\u202Bb!\u202c");
91 onload = function()
93 if (window.testRunner)
94 testRunner.dumpAsText();
95 test("div");
97 </script>
99 <title>Editing Test</title>
100 </head>
101 <body>
102 <div contenteditable id="div1" class="editing"></div>
104 <div contenteditable id="div2" class="editing"></div>
106 <div contenteditable id="div3" class="editing"></div>
108 <div contenteditable id="div4" class="editing"></div>
109 <ul id="console"></ul>
110 </body>
111 </html>