1 description("Test to make sure we can toggle text decorations correctly.")
3 var testContainer = document.createElement("div");
4 testContainer.contentEditable = true;
5 document.body.appendChild(testContainer);
7 function testSingleToggle(toggleCommand, initialContents, expectedContents)
9 testContainer.innerHTML = initialContents;
10 window.getSelection().selectAllChildren(testContainer);
11 document.execCommand("styleWithCSS", false, true);
12 document.execCommand(toggleCommand, false, null);
13 if (testContainer.innerHTML === expectedContents) {
14 testPassed("one " + toggleCommand + " command converted " + initialContents + " to " + expectedContents);
16 testFailed("one " + toggleCommand + " command converted " + initialContents + " to " + testContainer.innerHTML + ", expected " + expectedContents);
20 testSingleToggle("underline", "test", "<span style=\"text-decoration-line: underline;\">test</span>");
21 testSingleToggle("underline", "<span style=\"text-decoration: underline;\">test</span>", "test");
22 testSingleToggle("underline", "<span style=\"text-decoration: underline line-through overline;\">test</span>", "<span style=\"text-decoration-line: overline line-through;\">test</span>");
23 testSingleToggle("strikethrough", "test", "<span style=\"text-decoration-line: line-through;\">test</span>");
24 testSingleToggle("strikethrough", "<span style=\"text-decoration: line-through;\">test</span>", "test");
25 testSingleToggle("strikethrough", "<span style=\"text-decoration: underline line-through overline;\">test</span>", "<span style=\"text-decoration-line: underline overline;\">test</span>");
27 document.body.removeChild(testContainer);
29 var successfullyParsed = true;