blob: 75228e46d8e8f820eda96ae91c869f47fb394003 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
|
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<script language="javascript" type="text/javascript">
description('Test that WebKit changes the dir attribute and sends an input event when we change the text direction.');
// The string used for storing the expected text direction when we receive an input event.
var expected = '';
var sentInputEvent = false;
function removeChildAndForceGC(child) {
document.body.removeChild(child);
gc();
}
// Create a textarea element and an input element. These elements are used for
// changing their text direction with Editor::setBaseWritingDirection() calls.
var textarea = document.createElement('textarea');
textarea.rows = 10;
textarea.cols = 10;
textarea.oninput = function() {
shouldBe('expected', 'textarea.dir');
sentInputEvent = true;
// When we change the direction to ltr, we remove this element to verify WebKit
// continue running without crashes.
if (expected == 'ltr')
removeChildAndForceGC(textarea);
}
document.body.appendChild(textarea);
var input = document.createElement('input');
input.type = 'text';
input.oninput = function() {
shouldBe('expected', 'input.dir');
sentInputEvent = true;
// When we change the direction to ltr, we remove this element to verify WebKit
// continue running without crashes.
if (expected == 'ltr')
removeChildAndForceGC(input);
}
document.body.appendChild(input);
// Change the text direction of the textarea element to RTL.
expected = 'rtl';
sentInputEvent = false;
textarea.focus();
testRunner.setTextDirection('rtl');
shouldBeTrue('sentInputEvent');
// Change the text direction of the textarea element to LTR.
// This also removes the element to verify WebKit works without crashes.
expected = 'ltr';
sentInputEvent = false;
textarea.focus();
testRunner.setTextDirection('ltr');
shouldBeTrue('sentInputEvent');
// Change the text direction of the input element to RTL.
expected = 'rtl';
sentInputEvent = false;
input.focus();
testRunner.setTextDirection('rtl');
shouldBeTrue('sentInputEvent');
// Change the text direction of the input element to LTR.
// This also removes the element to verify WebKit works without crashes.
expected = 'ltr';
sentInputEvent = false;
input.focus();
testRunner.setTextDirection('ltr');
shouldBeTrue('sentInputEvent');
</script>
</body>
</html>
|