1 <!DOCTYPE HTML PUBLIC
"-//IETF//DTD HTML//EN">
4 <script src=
"../../resources/js-test.js"></script>
7 <script language=
"javascript" type=
"text/javascript">
8 description('Test that WebKit changes the dir attribute and sends an input event when we change the text direction.');
10 // The string used for storing the expected text direction when we receive an input event.
12 var sentInputEvent
= false;
14 function removeChildAndForceGC(child
) {
15 document
.body
.removeChild(child
);
19 // Create a textarea element and an input element. These elements are used for
20 // changing their text direction with Editor::setBaseWritingDirection() calls.
21 var textarea
= document
.createElement('textarea');
24 textarea
.oninput = function() {
25 shouldBe('expected', 'textarea.dir');
26 sentInputEvent
= true;
28 // When we change the direction to ltr, we remove this element to verify WebKit
29 // continue running without crashes.
30 if (expected
== 'ltr')
31 removeChildAndForceGC(textarea
);
33 document
.body
.appendChild(textarea
);
35 var input
= document
.createElement('input');
37 input
.oninput = function() {
38 shouldBe('expected', 'input.dir');
39 sentInputEvent
= true;
41 // When we change the direction to ltr, we remove this element to verify WebKit
42 // continue running without crashes.
43 if (expected
== 'ltr')
44 removeChildAndForceGC(input
);
46 document
.body
.appendChild(input
);
48 // Change the text direction of the textarea element to RTL.
50 sentInputEvent
= false;
52 testRunner
.setTextDirection('rtl');
53 shouldBeTrue('sentInputEvent');
55 // Change the text direction of the textarea element to LTR.
56 // This also removes the element to verify WebKit works without crashes.
58 sentInputEvent
= false;
60 testRunner
.setTextDirection('ltr');
61 shouldBeTrue('sentInputEvent');
63 // Change the text direction of the input element to RTL.
65 sentInputEvent
= false;
67 testRunner
.setTextDirection('rtl');
68 shouldBeTrue('sentInputEvent');
70 // Change the text direction of the input element to LTR.
71 // This also removes the element to verify WebKit works without crashes.
73 sentInputEvent
= false;
75 testRunner
.setTextDirection('ltr');
76 shouldBeTrue('sentInputEvent');