blob: 116c94b54bf79a6a478065bb38af29f5ac628d72 [file] [log] [blame]
<!DOCTYPE html>
<html>
<body>
<script src="../../resources/dump-as-markup.js"></script>
<div id="test0" contenteditable>
<pre>
<ul><li>hello</li></ul></pre>
</div>
<div id="test1" contenteditable>
<pre><ul><li>hello
world</li>
</ul></pre>
</div>
<div id="test2" contenteditable>
<ul><li><pre>
hello
world
webkit
</pre></li></ul>
</div>
<div id="test3" contenteditable>
<ul><li><pre>
hello
world
webkit
</pre></li></ul>
</div>
<div id="test4" contenteditable>
<ul><li><pre>
hello
world
webkit
</pre></li></ul>
</div>
<div id="test5" contenteditable>
<ul><li><pre>
hello
world
webkit
</pre></li></ul>
</div>
<script>
function testIndentation(containerId, selector) {
var container = document.getElementById(containerId);
selector(container);
Markup.dump(container, 'Indenting');
document.execCommand('indent', false, null);
Markup.dump(container, 'yields');
}
function selectAll(container) {
window.getSelection().selectAllChildren(container);
}
function selectorForLineN(line) {
return function (container) {
window.getSelection().setPosition(container, 0);
for (var i = 0; i < line - 1; i++)
window.getSelection().modify('move', 'forward', 'line');
window.getSelection().modify('extend', 'forward', 'line');
// Avoid including \n at the end of line.
window.getSelection().modify('extend', 'backward', 'character');
}
}
testIndentation('test0', selectAll);
testIndentation('test1', selectAll);
testIndentation('test2', selectAll);
testIndentation('test3', selectorForLineN(1));
testIndentation('test4', selectorForLineN(2));
testIndentation('test5', selectorForLineN(3));
</script>
</body>
</html>