Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / execCommand / indent-pre.html
blob3cd0c5169573bb12eaa4d7980247b9b4ef057ab1
1 <p>This test tries to indent lines within pre tags. This test passes if it
2 does not crash.</p>
3 <div contentEditable>
4 <pre id="pre-basic">line one
5 line two
6 line three
7 line four</pre>
9 <ul><li><pre id="pre-list">list one
10 list two
11 list three
12 list four
13 </pre></li></ul>
15 <table>
16 <tr><td><pre id="pre-table">table one
17 table two
18 table three</pre></td><td>right cell</td></tr></table>
20 <div id="results">FAILED</div>
21 </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>
27 <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");
53 setSelection(pre);
54 execMoveSelectionForwardByCharacterCommand();
55 execExtendSelectionForwardByWordCommand();
56 document.execCommand("indent");
57 verifyTextSelection(document.getElementsByTagName("pre")[0].firstChild, 1,
58 document.getElementsByTagName("pre")[0].firstChild, 4);
60 // Indent 2 lines.
61 setSelection(pre);
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);
71 } else {
72 console.log("Wrong number of pre nodes.");
75 // Indent <pre> lines in a list.
76 pre = document.getElementById("pre-list");
77 setSelection(pre);
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");
86 setSelection(pre);
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)";
94 </script>