blob: f0af441c4a71dcb9c025dfe6d831ced38a5ddb29 [file] [log] [blame]
<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test-pre.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
description("Test to make sure we can toggle text decorations correctly.")
var testContainer = document.createElement("div");
testContainer.contentEditable = true;
document.body.appendChild(testContainer);
function testSingleToggle(toggleCommand, initialContents, expectedContents)
{
testContainer.innerHTML = initialContents;
window.getSelection().selectAllChildren(testContainer);
document.execCommand("styleWithCSS", false, true);
document.execCommand(toggleCommand, false, null);
if (testContainer.innerHTML === expectedContents) {
testPassed("one " + toggleCommand + " command converted " + initialContents + " to " + expectedContents);
} else {
testFailed("one " + toggleCommand + " command converted " + initialContents + " to " + testContainer.innerHTML + ", expected " + expectedContents);
}
}
testSingleToggle("underline", "test", "<span style=\"text-decoration: underline;\">test</span>");
testSingleToggle("underline", "<span style=\"text-decoration: underline;\">test</span>", "test");
testSingleToggle("underline", "<span style=\"text-decoration: underline line-through overline;\">test</span>",
"<span style=\"text-decoration: line-through overline;\">test</span>");
testSingleToggle("strikethrough", "test", "<span style=\"text-decoration: line-through;\">test</span>");
testSingleToggle("strikethrough", "<span style=\"text-decoration: line-through;\">test</span>", "test");
testSingleToggle("strikethrough", "<span style=\"text-decoration: underline line-through overline;\">test</span>", "<span style=\"text-decoration: underline overline;\">test</span>");
document.body.removeChild(testContainer);
var successfullyParsed = true;
</script>
<script src="../../resources/js-test-post.js"></script>
</body>
</html>