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);
15 testFailed("one " + toggleCommand + " command converted " + initialContents + " to " + testContainer.innerHTML + ", expected " + expectedContents);
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);
28 testFailed("two " + toggleCommand + " commands converted " + initialContents + " to " + testContainer.innerHTML + ", expected " + expectedContents);
32 testSingleToggle("bold", "<span><span style='font-weight: bold'>test</span></span>", "<span>test</span>");
33 testSingleToggle("bold", "<span style='font-weight: bold'><span>test</span></span>", "test");
34 testSingleToggle("bold", "<span style='font-weight: bold'><span style='font-weight: bold'>test</span></span>", "test");
35 testSingleToggle("bold", "<span foo=\"bar\" style='font-weight: bold'>test</span>", "<span foo=\"bar\">test</span>");
36 testDoubleToggle("bold", "<span>test</span>", "<span>test</span>");
38 document.body.removeChild(testContainer);
40 var successfullyParsed = true;