1 CONSOLE MESSAGE: line 44: Wrong node selected.
2 CONSOLE MESSAGE: line 46: Wrong anchor offset: 8 instead of 0
3 CONSOLE MESSAGE: line 41: Wrong end node type: [object HTMLBRElement]
4 CONSOLE MESSAGE: line 44: Wrong node selected.
9 | "This test tries to indent lines within pre tags. This test passes if it
18 | style="margin: 0 0 0 40px; border: none; padding: 0px;"
27 | style="margin: 0 0 0 40px; border: none; padding: 0px;"
42 | style="margin: 0 0 0 40px; border: none; padding: 0px;"
59 | "table one<#selection-anchor>
62 | style="margin: 0 0 0 40px; border: none; padding: 0px;"
66 | "table three<#selection-focus>"
74 | "PASSED (did not crash)"
81 | href="javascript:document.execCommand('indent')"
86 | href="javascript:document.execCommand('outdent')"
91 | src="../../resources/dump-as-markup.js"
100 function setSelection(node)
102 var textNode = node.firstChild;
103 if (textNode.nodeType != Node.TEXT_NODE)
104 throw "Wrong node type: " + textNode;
105 execSetSelectionCommand(textNode, 0, 0);
108 function verifyTextSelection(startNode, startOffset, endNode, endOffset)
110 if (startNode.nodeType != Node.TEXT_NODE)
111 console.log("Wrong start node type: " + startNode);
112 if (endNode.nodeType != Node.TEXT_NODE)
113 console.log("Wrong end node type: " + endNode);
114 var sel = window.getSelection();
115 if (sel.anchorNode != startNode || sel.focusNode != endNode)
116 console.log("Wrong node selected.");
117 if (sel.anchorOffset != startOffset)
118 console.log("Wrong anchor offset: " + sel.anchorOffset + " instead of " + startOffset);
119 if (sel.focusOffset != endOffset)
120 console.log("Wrong focus offset: " + sel.focusOffset + " instead of " + endOffset);
123 // Indent a single line in a pre and make sure the selection is correctly preserved.
124 var pre = document.getElementById("pre-basic");
126 execMoveSelectionForwardByCharacterCommand();
127 execExtendSelectionForwardByWordCommand();
128 document.execCommand("indent");
129 verifyTextSelection(document.getElementsByTagName("pre")[0].firstChild, 1,
130 document.getElementsByTagName("pre")[0].firstChild, 4);
134 execMoveSelectionForwardByLineCommand();
135 execExtendSelectionForwardByLineCommand();
136 execExtendSelectionForwardByWordCommand();
137 document.execCommand("indent");
138 if (document.getElementsByTagName("pre").length > 3) {
139 // FIXME: The selection for the anchorNode is wrong. It should stay at
140 // the beginning of "line three", but it moves to the end of "line 2".
141 verifyTextSelection(document.getElementsByTagName("pre")[2].firstChild, 0,
142 document.getElementsByTagName("pre")[3].firstChild, 4);
144 console.log("Wrong number of pre nodes.");
147 // Indent <pre> lines in a list.
148 pre = document.getElementById("pre-list");
150 execMoveSelectionForwardByLineCommand();
151 execExtendSelectionForwardByLineCommand();
152 execExtendSelectionForwardByLineCommand();
153 document.execCommand("indent");
154 verifyTextSelection(document.getElementsByTagName("blockquote")[2].firstChild, 0,
155 document.getElementsByTagName("blockquote")[2].firstChild.nextSibling, 10);
156 // Indenting <pre> lines in a table.
157 pre = document.getElementById("pre-table");
159 execMoveSelectionForwardByLineCommand();
160 execExtendSelectionForwardByLineCommand();
161 execExtendSelectionForwardByLineCommand();
162 // FIXME: This is wrong. The pre tags get copied when they shouldn't be.
163 // See https://bugs.webkit.org/show_bug.cgi?id=42009
164 document.execCommand("indent");
165 document.getElementById("results").innerText = "PASSED (did not crash)";