OLD | NEW |
1 description("Test to make sure we can toggle text decorations correctly.") | 1 description("Test to make sure we can toggle text decorations correctly.") |
2 | 2 |
3 var testContainer = document.createElement("div"); | 3 var testContainer = document.createElement("div"); |
4 testContainer.contentEditable = true; | 4 testContainer.contentEditable = true; |
5 document.body.appendChild(testContainer); | 5 document.body.appendChild(testContainer); |
6 | 6 |
7 function testSingleToggle(toggleCommand, initialContents, expectedContents) | 7 function testSingleToggle(toggleCommand, initialContents, expectedContents) |
8 { | 8 { |
9 testContainer.innerHTML = initialContents; | 9 testContainer.innerHTML = initialContents; |
10 window.getSelection().selectAllChildren(testContainer); | 10 window.getSelection().selectAllChildren(testContainer); |
11 document.execCommand("styleWithCSS", false, true); | 11 document.execCommand("styleWithCSS", false, true); |
12 document.execCommand(toggleCommand, false, null); | 12 document.execCommand(toggleCommand, false, null); |
13 if (testContainer.innerHTML === expectedContents) { | 13 if (testContainer.innerHTML === expectedContents) { |
14 testPassed("one " + toggleCommand + " command converted " + initialConte
nts + " to " + expectedContents); | 14 testPassed("one " + toggleCommand + " command converted " + initialConte
nts + " to " + expectedContents); |
15 } else { | 15 } else { |
16 testFailed("one " + toggleCommand + " command converted " + initialConte
nts + " to " + testContainer.innerHTML + ", expected " + expectedContents); | 16 testFailed("one " + toggleCommand + " command converted " + initialConte
nts + " to " + testContainer.innerHTML + ", expected " + expectedContents); |
17 } | 17 } |
18 } | 18 } |
19 | 19 |
20 testSingleToggle("underline", "test", "<span style=\"text-decoration: underline;
\">test</span>"); | 20 testSingleToggle("underline", "test", "<span style=\"text-decoration-line: under
line;\">test</span>"); |
21 testSingleToggle("underline", "<span style=\"text-decoration: underline;\">test<
/span>", "test"); | 21 testSingleToggle("underline", "<span style=\"text-decoration: underline;\">test<
/span>", "test"); |
22 testSingleToggle("underline", "<span style=\"text-decoration: underline line-thr
ough overline;\">test</span>", "<span style=\"text-decoration: overline line-thr
ough;\">test</span>"); | 22 testSingleToggle("underline", "<span style=\"text-decoration: underline line-thr
ough overline;\">test</span>", "<span style=\"text-decoration-line: overline lin
e-through;\">test</span>"); |
23 testSingleToggle("strikethrough", "test", "<span style=\"text-decoration: line-t
hrough;\">test</span>"); | 23 testSingleToggle("strikethrough", "test", "<span style=\"text-decoration-line: l
ine-through;\">test</span>"); |
24 testSingleToggle("strikethrough", "<span style=\"text-decoration: line-through;\
">test</span>", "test"); | 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: underline ove
rline;\">test</span>"); | 25 testSingleToggle("strikethrough", "<span style=\"text-decoration: underline line
-through overline;\">test</span>", "<span style=\"text-decoration-line: underlin
e overline;\">test</span>"); |
26 | 26 |
27 document.body.removeChild(testContainer); | 27 document.body.removeChild(testContainer); |
28 | 28 |
29 var successfullyParsed = true; | 29 var successfullyParsed = true; |
OLD | NEW |