blob: 542778ee35194975ed3a3f6379bc2f71736ac4c6 [file] [log] [blame]
<html>
<body>
<script src="../../resources/dump-as-markup.js"></script>
<div id="test" contenteditable></div>
<script type="text/javascript">
var test = document.getElementById('test');
function printState(command, description) {
var underlineState = document.queryCommandState('underline');
var strikeThroughState = document.queryCommandState('strikeThrough');
var state = 'no text decorations';
if (underlineState && strikeThroughState)
state = 'underline and strike';
else if (underlineState)
state = 'underline';
else (strikeThroughState)
state = 'strike';
Markup.dump(test, 'Has ' + state + (description ? " " + description : "") + " in");
}
function runTextDecorationTest(command) {
printState(command, 'before adding ' + command);
document.execCommand(command, false, null);
printState(command, 'after adding ' + command);
document.execCommand("InsertText", false, 'x');
document.execCommand("InsertText", false, 'x');
printState(command);
window.getSelection().modify('move', 'backward', 'character');
printState(command);
document.execCommand(command, false, null);
printState(command, 'after removing ' + command);
document.execCommand("InsertText", false, 'x');
printState(command);
window.getSelection().modify('move', 'forward', 'line');
printState(command, 'before removing ' + command);
document.execCommand(command, false, null);
printState(command, 'after removing ' + command);
document.execCommand("InsertText", false, 'x');
printState(command);
}
window.getSelection().collapse(test, 0);
runTextDecorationTest('underline');
runTextDecorationTest('strikeThrough');
</script>
</body>
</html>