Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / execCommand / script-tests / toggle-style-2.js
blobe83827a0e8d0e610f9d7733442bce83ae5866980
1 description("Test to make sure we remove span tags with no attributes if we removed the last attribute.")
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(toggleCommand, false, null);
12     if (testContainer.innerHTML === expectedContents) {
13         testPassed("one " + toggleCommand + " command converted " + initialContents + " to " + expectedContents);
14     } else {
15         testFailed("one " + toggleCommand + " command converted " + initialContents + " to " + testContainer.innerHTML + ", expected " + expectedContents);
16     }
19 function testDoubleToggle(toggleCommand, initialContents, expectedContents)
21     testContainer.innerHTML = initialContents;
22     window.getSelection().selectAllChildren(testContainer);
23     document.execCommand(toggleCommand, false, null);
24     document.execCommand(toggleCommand, false, null);
25     if (testContainer.innerHTML === expectedContents) {
26         testPassed("two " + toggleCommand + " commands converted " + initialContents + " to " + expectedContents);
27     } else {
28         testFailed("two " + toggleCommand + " commands converted " + initialContents + " to " + testContainer.innerHTML + ", expected " + expectedContents);
29     }
32 testSingleToggle("underline", "test", "<u>test</u>");
33 testSingleToggle("underline", "<u><b><strike>test</strike></b></u>", "<b><strike>test</strike></b>");
34 testDoubleToggle("underline", "test", "test");
35 testSingleToggle("strikethrough", "test", "<strike>test</strike>");
36 testSingleToggle("strikethrough", "<u><b><strike>test</strike></b></u>", "<u><b>test</b></u>");
37 testDoubleToggle("strikethrough", "test", "test");
39 testSingleToggle("strikethrough", "<u>test</u>", "<u><strike>test</strike></u>");
40 testSingleToggle("underline", "<strike>test</strike>", "<u><strike>test</strike></u>");
42 testSingleToggle("strikethrough", '<span style="text-decoration: overline;">test</span>', '<span style="text-decoration-line: overline;"><strike>test</strike></span>');
43 testSingleToggle("underline", '<span style="text-decoration: overline;">test</span>', '<span style="text-decoration-line: overline;"><u>test</u></span>');
45 document.body.removeChild(testContainer);
47 var successfullyParsed = true;