OLD | NEW |
1 description('Test to make sure WebKit adds just one element when applying inline
style and removes redundant styled elements.'); | 1 description('Test to make sure WebKit adds just one element when applying inline
style and removes redundant styled elements.'); |
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, value, initialContents, expectedContent
s) | 7 function testSingleToggle(toggleCommand, value, initialContents, expectedContent
s) |
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, 'false'); | 11 document.execCommand('styleWithCSS', false, 'false'); |
12 document.execCommand(toggleCommand, false, value); | 12 document.execCommand(toggleCommand, false, value); |
13 var action = toggleCommand + '(' + value + ') on all of "' + initialContents
+ '" yields "' + testContainer.innerHTML + '"'; | 13 var action = toggleCommand + '(' + value + ') on all of "' + initialContents
+ '" yields "' + testContainer.innerHTML + '"'; |
14 if (testContainer.innerHTML == expectedContents) | 14 if (testContainer.innerHTML == expectedContents) |
15 testPassed(action); | 15 testPassed(action); |
16 else | 16 else |
17 testFailed(action + ', expected "' + expectedContents + '"'); | 17 testFailed(action + ', expected "' + expectedContents + '"'); |
18 } | 18 } |
19 | 19 |
20 testSingleToggle("fontSize", 4, 'hello <font size="4">world</font> WebKit', '<fo
nt size="4">hello world WebKit</font>'); | 20 testSingleToggle("fontSize", 4, 'hello <font size="4">world</font> WebKit', '<fo
nt class="Apple-style-span" size="4">hello world WebKit</font>'); |
21 testSingleToggle("fontName", "Arial", 'hello <b><font face="Arial">world</font><
/b> WebKit', '<font face="Arial">hello <b>world</b> WebKit</font>'); | 21 testSingleToggle("fontName", "Arial", 'hello <b><font face="Arial">world</font><
/b> WebKit', '<font class="Apple-style-span" face="Arial">hello <b>world</b> Web
Kit</font>'); |
22 testSingleToggle("italic", null, 'hello <u><i title="message">world </i><i>WebKi
t</i></u>', '<i>hello <u><span title="message">world </span>WebKit</u></i>'); | 22 testSingleToggle("italic", null, 'hello <u><i title="message">world </i><i>WebKi
t</i></u>', '<i>hello <u><span title="message">world </span>WebKit</u></i>'); |
23 testSingleToggle("bold", null, 'hello <i><b>world</b> WebKit</i>', '<b>hello <i>
world WebKit</i></b>'); | 23 testSingleToggle("bold", null, 'hello <i><b>world</b> WebKit</i>', '<b>hello <i>
world WebKit</i></b>'); |
24 testSingleToggle("bold", null, 'hello <i><b class="test">world</b> WebKit</i>',
'<b>hello <i><span class="test">world</span> WebKit</i></b>'); | 24 testSingleToggle("bold", null, 'hello <i><b class="test">world</b> WebKit</i>',
'<b>hello <i><span class="test">world</span> WebKit</i></b>'); |
25 testSingleToggle("bold", null, 'hello <b contenteditable="false">world</b> <b>We
bKit </b><u><b>rocks</b></u>', '<b>hello </b><b contenteditable="false">world</b
><b> WebKit <u>rocks</u></b>'); | 25 testSingleToggle("bold", null, 'hello <b contenteditable="false">world</b> <b>We
bKit </b><u><b>rocks</b></u>', '<b>hello </b><b contenteditable="false">world</b
><b> WebKit <u>rocks</u></b>'); |
26 testSingleToggle("strikeThrough", null, 'hello <b>world <strike>WebKit</strike><
/b>', '<strike>hello <b>world WebKit</b></strike>'); | 26 testSingleToggle("strikeThrough", null, 'hello <b>world <strike>WebKit</strike><
/b>', '<strike>hello <b>world WebKit</b></strike>'); |
27 testSingleToggle("strikeThrough", null, 'hello <i><strike>world</strike></i><b><
strike>WebKit</strike></b> rocks', '<strike>hello <i>world</i><b>WebKit</b> rock
s</strike>'); | 27 testSingleToggle("strikeThrough", null, 'hello <i><strike>world</strike></i><b><
strike>WebKit</strike></b> rocks', '<strike>hello <i>world</i><b>WebKit</b> rock
s</strike>'); |
28 testSingleToggle("strikeThrough", null, 'hello <i><strike>world</strike></i> Web
Kit <b><strike>rocks</strike></b>', '<strike>hello <i>world</i> WebKit <b>rocks<
/b></strike>'); | 28 testSingleToggle("strikeThrough", null, 'hello <i><strike>world</strike></i> Web
Kit <b><strike>rocks</strike></b>', '<strike>hello <i>world</i> WebKit <b>rocks<
/b></strike>'); |
29 | 29 |
30 // block nodes and br tests | 30 // block nodes and br tests |
31 testSingleToggle("bold", null, 'hello<div><i>world</i> <b>WebKit</b></div><div>r
ocks</div>', '<b>hello</b><div><b><i>world</i> WebKit</b></div><div><b>rocks</b>
</div>'); | 31 testSingleToggle("bold", null, 'hello<div><i>world</i> <b>WebKit</b></div><div>r
ocks</div>', '<b>hello</b><div><b><i>world</i> WebKit</b></div><div><b>rocks</b>
</div>'); |
32 testSingleToggle("bold", null, 'hello<br style="display: block;"><i><b>world</b>
</i><br><b>WebKit</b>', '<b>hello<br style="display: block;"><i>world</i><br>Web
Kit</b>'); | 32 testSingleToggle("bold", null, 'hello<br style="display: block;"><i><b>world</b>
</i><br><b>WebKit</b>', '<b>hello<br style="display: block;"><i>world</i><br>Web
Kit</b>'); |
33 testSingleToggle("bold", null, 'hello<p><b>world</b> <i><b>W</b>ebKit</i></p><b>
rocks</b>', '<b>hello</b><p><b>world <i>WebKit</i></b></p><b>rocks</b>'); | 33 testSingleToggle("bold", null, 'hello<p><b>world</b> <i><b>W</b>ebKit</i></p><b>
rocks</b>', '<b>hello</b><p><b>world <i>WebKit</i></b></p><b>rocks</b>'); |
34 | 34 |
35 document.body.removeChild(testContainer); | 35 document.body.removeChild(testContainer); |
36 var successfullyParsed = true; | 36 var successfullyParsed = true; |
OLD | NEW |