1 <p>This test tries to indent lines within pre tags. This test passes if it
4 <pre id=
"pre-basic">line one
9 <ul><li><pre id=
"pre-list">list one
16 <tr><td><pre id=
"pre-table">table one
18 table three
</pre></td><td>right cell
</td></tr></table>
20 <div id=
"results">FAILED
</div>
23 <a href=
"javascript:document.execCommand('indent')">indent
</a>
24 <a href=
"javascript:document.execCommand('outdent')">outdent
</a>
25 <script src=
"../../resources/dump-as-markup.js"></script>
26 <script src=
"../editing.js"></script>
28 function setSelection(node
)
30 var textNode
= node
.firstChild
;
31 if (textNode
.nodeType
!= Node
.TEXT_NODE
)
32 throw "Wrong node type: " + textNode
;
33 execSetSelectionCommand(textNode
, 0, 0);
36 function verifyTextSelection(startNode
, startOffset
, endNode
, endOffset
)
38 if (startNode
.nodeType
!= Node
.TEXT_NODE
)
39 console
.log("Wrong start node type: " + startNode
);
40 if (endNode
.nodeType
!= Node
.TEXT_NODE
)
41 console
.log("Wrong end node type: " + endNode
);
42 var sel
= window
.getSelection();
43 if (sel
.anchorNode
!= startNode
|| sel
.focusNode
!= endNode
)
44 console
.log("Wrong node selected.");
45 if (sel
.anchorOffset
!= startOffset
)
46 console
.log("Wrong anchor offset: " + sel
.anchorOffset
+ " instead of " + startOffset
);
47 if (sel
.focusOffset
!= endOffset
)
48 console
.log("Wrong focus offset: " + sel
.focusOffset
+ " instead of " + endOffset
);
51 // Indent a single line in a pre and make sure the selection is correctly preserved.
52 var pre
= document
.getElementById("pre-basic");
54 execMoveSelectionForwardByCharacterCommand();
55 execExtendSelectionForwardByWordCommand();
56 document
.execCommand("indent");
57 verifyTextSelection(document
.getElementsByTagName("pre")[0].firstChild
, 1,
58 document
.getElementsByTagName("pre")[0].firstChild
, 4);
62 execMoveSelectionForwardByLineCommand();
63 execExtendSelectionForwardByLineCommand();
64 execExtendSelectionForwardByWordCommand();
65 document
.execCommand("indent");
66 if (document
.getElementsByTagName("pre").length
> 3) {
67 // FIXME: The selection for the anchorNode is wrong. It should stay at
68 // the beginning of "line three", but it moves to the end of "line 2".
69 verifyTextSelection(document
.getElementsByTagName("pre")[2].firstChild
, 0,
70 document
.getElementsByTagName("pre")[3].firstChild
, 4);
72 console
.log("Wrong number of pre nodes.");
75 // Indent <pre> lines in a list.
76 pre
= document
.getElementById("pre-list");
78 execMoveSelectionForwardByLineCommand();
79 execExtendSelectionForwardByLineCommand();
80 execExtendSelectionForwardByLineCommand();
81 document
.execCommand("indent");
82 verifyTextSelection(document
.getElementsByTagName("blockquote")[2].firstChild
, 0,
83 document
.getElementsByTagName("blockquote")[2].firstChild
.nextSibling
, 10);
84 // Indenting <pre> lines in a table.
85 pre
= document
.getElementById("pre-table");
87 execMoveSelectionForwardByLineCommand();
88 execExtendSelectionForwardByLineCommand();
89 execExtendSelectionForwardByLineCommand();
90 // FIXME: This is wrong. The pre tags get copied when they shouldn't be.
91 // See https://bugs.webkit.org/show_bug.cgi?id=42009
92 document
.execCommand("indent");
93 document
.getElementById("results").innerText
= "PASSED (did not crash)";