blob: a760b92e94157dec6bff0d108dbb4f04b6693c77 [file] [log] [blame]
<!DOCTYPE html>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<p>
Should see the "bar" and "baz" lines centered in their own boxes. The "foo" line should not be centered.
</p>
<div id="sample" contenteditable>foo<div>bar</div>baz</div>
<div id="log"></div>
<script>
test(function() {
var selection = window.getSelection();
var sample = document.getElementById('sample');
selection.collapse(sample.childNodes[1].firstChild, 0);
selection.extend(sample.lastChild, 1);
document.execCommand('justifyCenter');
assert_equals(sample.innerHTML, 'foo<div style="text-align: center;">bar</div><div style="text-align: center;">baz</div>', 'innerHTML');
assert_false(selection.isCollapsed, 'isCollapsed');
assert_equals(selection.anchorNode, sample.childNodes[1].firstChild, 'anchorNode');
assert_equals(selection.anchorOffset, 0, 'anchorOffset');
assert_equals(selection.focusNode, sample.childNodes[2].firstChild, 'focusNode');
assert_equals(selection.focusOffset, 1, 'focusOffset');
});
</script>