| <!DOCTYPE html> |
| <html> |
| <head> |
| <title>Preserve selection direction</title> |
| <script src="../../resources/js-test-pre.js" type="text/javascript"></script> |
| </head> |
| <body> |
| <p>Bug 110979: Selection direction is not preserved when applying styles</p> |
| <p>This test verifies that selection direction is preserved when applying styles.</p> |
| <div id="editable" contenteditable>This is some sample text</div> |
| <div id="console"></div> |
| <script> |
| var editable = document.getElementById("editable"); |
| var selection = window.getSelection(); |
| |
| evalAndLog("selection.collapse(editable.firstChild, 3);"); |
| evalAndLog("selection.extend(editable.firstChild, 8);"); |
| evalAndLog("document.execCommand('foreColor', false, 'green');"); |
| shouldBe("selection.anchorOffset", "0"); |
| shouldBe("selection.focusOffset", "5"); |
| |
| evalAndLog("editable.innerHTML = 'This is some sample text';"); |
| evalAndLog("selection.collapse(editable.firstChild, 8);"); |
| evalAndLog("selection.extend(editable.firstChild, 3);"); |
| evalAndLog("document.execCommand('foreColor', false, 'green');"); |
| shouldBe("selection.anchorOffset", "5"); |
| shouldBe("selection.focusOffset", "0"); |
| </script> |
| <script src="../../resources/js-test-post.js" type="text/javascript"></script> |
| </body> |
| </html> |