11 <script src=../editing.js
language=
"JavaScript" type=
"text/JavaScript" ></script>
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
);
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
);
45 function test(element
)
47 var textarea
= document
.getElementById(element
+ "1");
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‫b!‬", string
, "a\u202Bb!\u202c");
59 // Copy and past string contains unicode bidi control character in the middle.
60 document
.execCommand("SelectAll");
62 textarea
= document
.getElementById(element
+ "3");
66 string
= textarea
.innerHTML
;
67 assertEqual("copy/paste a‫b!‬", string
, "a\u202Bb!\u202c");
69 textarea
= document
.getElementById(element
+ "2");
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 ‫b!‬", string
, "\u202Bb!\u202c");
80 // Copy and past string contains unicode bidi control character at the beginning.
81 document
.execCommand("SelectAll");
83 textarea
= document
.getElementById(element
+ "4");
87 string
= textarea
.innerHTML
;
88 assertEqual("copy/paste ‫b!‬", string
, "\u202Bb!\u202c");
93 if (window
.testRunner
)
94 testRunner
.dumpAsText();
99 <title>Editing Test
</title>
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>