| <!DOCTYPE html> |
| <script src="../../resources/testharness.js"></script> |
| <script src="../../resources/testharnessreport.js"></script> |
| <p>This tests for a bug where changing the alignment of an image would result in a selection that wasn't the one that was present before the alignment change. The image should be centered and the selection should be the same before and after the operation.</p> |
| <div id="div" contenteditable="true">foo<br><img src="../resources/abe.png"><br>baz</div> |
| <div id="log"></div> |
| <script> |
| test(function() { |
| var div = document.getElementById("div"); |
| var selection = window.getSelection(); |
| |
| selection.collapse(div, 0); |
| selection.modify("move", "forward", "paragraphBoundary"); |
| selection.modify("move", "forward", "character"); |
| selection.modify("extend", "forward", "character"); |
| |
| document.execCommand("JustifyCenter"); |
| |
| assert_equals(div.innerHTML, 'foo<br><div style="text-align: center;"><img src="../resources/abe.png"></div>baz'); |
| assert_equals(selection.anchorNode, div.childNodes[2]); |
| assert_equals(selection.anchorOffset, 0); |
| assert_equals(selection.focusNode, div.childNodes[2]); |
| assert_equals(selection.focusOffset, 1); |
| }); |
| </script> |