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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
|
CONSOLE MESSAGE: line 48: Wrong focus offset: 5 instead of 4
CONSOLE MESSAGE: line 44: Wrong node selected.
CONSOLE MESSAGE: line 46: Wrong anchor offset: 8 instead of 0
CONSOLE MESSAGE: line 48: Wrong focus offset: 5 instead of 4
CONSOLE MESSAGE: line 41: Wrong end node type: [object HTMLBRElement]
CONSOLE MESSAGE: line 44: Wrong node selected.
| <html>
| <head>
| <body>
| <p>
| "This test tries to indent lines within pre tags. This test passes if it
does not crash."
| "
"
| <div>
| contenteditable=""
| "
"
| <blockquote>
| style="margin: 0 0 0 40px; border: none; padding: 0px;"
| <pre>
| id="pre-basic"
| "line one"
| <pre>
| id="pre-basic"
| "line two
"
| <blockquote>
| style="margin: 0 0 0 40px; border: none; padding: 0px;"
| <pre>
| "line three"
| <pre>
| "line four"
| "
"
| <ul>
| <li>
| <pre>
| id="pre-list"
| "list one
"
| <blockquote>
| style="margin: 0 0 0 40px; border: none; padding: 0px;"
| "list two"
| <br>
| "list three"
| "list four
"
| "
"
| <table>
| "
"
| <tbody>
| <tr>
| <td>
| <pre>
| id="pre-table"
| "table one<#selection-anchor>
"
| <blockquote>
| style="margin: 0 0 0 40px; border: none; padding: 0px;"
| <pre>
| "table two"
| <pre>
| "table three<#selection-focus>"
| <td>
| "right cell"
| "
"
| <div>
| id="results"
| "PASSED (did not crash)"
| "
"
| "
"
| <a>
| href="javascript:document.execCommand('indent')"
| "indent"
| "
"
| <a>
| href="javascript:document.execCommand('outdent')"
| "outdent"
| "
"
| <script>
| src="../../resources/dump-as-markup.js"
| "
"
| <script>
| src="../editing.js"
| "
"
| <script>
| "
function setSelection(node)
{
var textNode = node.firstChild;
if (textNode.nodeType != Node.TEXT_NODE)
throw "Wrong node type: " + textNode;
execSetSelectionCommand(textNode, 0, textNode, 0);
}
function verifyTextSelection(startNode, startOffset, endNode, endOffset)
{
if (startNode.nodeType != Node.TEXT_NODE)
console.log("Wrong start node type: " + startNode);
if (endNode.nodeType != Node.TEXT_NODE)
console.log("Wrong end node type: " + endNode);
var sel = window.getSelection();
if (sel.anchorNode != startNode || sel.focusNode != endNode)
console.log("Wrong node selected.");
if (sel.anchorOffset != startOffset)
console.log("Wrong anchor offset: " + sel.anchorOffset + " instead of " + startOffset);
if (sel.focusOffset != endOffset)
console.log("Wrong focus offset: " + sel.focusOffset + " instead of " + endOffset);
}
// Indent a single line in a pre and make sure the selection is correctly preserved.
var pre = document.getElementById("pre-basic");
setSelection(pre);
execMoveSelectionForwardByCharacterCommand();
execExtendSelectionForwardByWordCommand();
document.execCommand("indent");
verifyTextSelection(document.getElementsByTagName("pre")[0].firstChild, 1,
document.getElementsByTagName("pre")[0].firstChild, 4);
// Indent 2 lines.
setSelection(pre);
execMoveSelectionForwardByLineCommand();
execExtendSelectionForwardByLineCommand();
execExtendSelectionForwardByWordCommand();
document.execCommand("indent");
if (document.getElementsByTagName("pre").length > 3) {
// FIXME: The selection for the anchorNode is wrong. It should stay at
// the beginning of "line three", but it moves to the end of "line 2".
verifyTextSelection(document.getElementsByTagName("pre")[2].firstChild, 0,
document.getElementsByTagName("pre")[3].firstChild, 4);
} else {
console.log("Wrong number of pre nodes.");
}
// Indent <pre> lines in a list.
pre = document.getElementById("pre-list");
setSelection(pre);
execMoveSelectionForwardByLineCommand();
execExtendSelectionForwardByLineCommand();
execExtendSelectionForwardByLineCommand();
document.execCommand("indent");
verifyTextSelection(document.getElementsByTagName("blockquote")[2].firstChild, 0,
document.getElementsByTagName("blockquote")[2].firstChild.nextSibling, 10);
// Indenting <pre> lines in a table.
pre = document.getElementById("pre-table");
setSelection(pre);
execMoveSelectionForwardByLineCommand();
execExtendSelectionForwardByLineCommand();
execExtendSelectionForwardByLineCommand();
// FIXME: This is wrong. The pre tags get copied when they shouldn't be.
// See https://bugs.webkit.org/show_bug.cgi?id=42009
document.execCommand("indent");
document.getElementById("results").innerText = "PASSED (did not crash)";
"
| "
"
|