OLD | NEW |
1 description('Test to make sure WebKit adds style to the appropriate container.')
; | 1 description('Test to make sure WebKit adds style to the appropriate container.')
; |
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 var styleWithCSS = false; | 7 var styleWithCSS = false; |
8 function testSingleToggle(toggleCommand, value, initialContents, expectedContent
s) | 8 function testSingleToggle(toggleCommand, value, initialContents, expectedContent
s) |
9 { | 9 { |
10 testContainer.innerHTML = initialContents; | 10 testContainer.innerHTML = initialContents; |
11 window.getSelection().selectAllChildren(testContainer); | 11 window.getSelection().selectAllChildren(testContainer); |
12 document.execCommand('styleWithCSS', false, styleWithCSS); | 12 document.execCommand('styleWithCSS', false, styleWithCSS); |
13 document.execCommand(toggleCommand, false, value); | 13 document.execCommand(toggleCommand, false, value); |
14 var action = toggleCommand + '(' + value + ') on all of "' + initialContents
+ '" yields "' + testContainer.innerHTML + '"'; | 14 var action = toggleCommand + '(' + value + ') on all of "' + initialContents
+ '" yields "' + testContainer.innerHTML + '"'; |
15 if (testContainer.innerHTML == expectedContents) | 15 if (testContainer.innerHTML == expectedContents) |
16 testPassed(action); | 16 testPassed(action); |
17 else | 17 else |
18 testFailed(action + ', expected "' + expectedContents + '"'); | 18 testFailed(action + ', expected "' + expectedContents + '"'); |
19 } | 19 } |
20 | 20 |
21 debug('styleWithCSS = false'); | 21 debug('styleWithCSS = false'); |
22 testSingleToggle("fontSize", 3, '<font size="3">hello <font size="4">world</font
></font>', '<font size="3">hello world</font>'); | 22 testSingleToggle("fontSize", 3, '<font size="3">hello <font size="4">world</font
></font>', '<font size="3">hello world</font>'); |
23 testSingleToggle("fontSize", 4, '<font face="Arial">hello</font>', '<font face="
Arial" size="4">hello</font>'); | 23 testSingleToggle("fontSize", 4, '<font face="Arial">hello</font>', '<font face="
Arial" size="4">hello</font>'); |
24 testSingleToggle("fontSize", 4, '<font color="blue"><font face="Arial">hello</fo
nt></font>', '<font color="blue"><font face="Arial" size="4">hello</font></font>
'); | 24 testSingleToggle("fontSize", 4, '<font color="blue"><font face="Arial">hello</fo
nt></font>', '<font color="blue"><font face="Arial" size="4">hello</font></font>
'); |
25 testSingleToggle("fontSize", 4, '<b><font face="Arial">hello</font></b>', '<b><f
ont face="Arial" size="4">hello</font></b>'); | 25 testSingleToggle("fontSize", 4, '<b><font face="Arial">hello</font></b>', '<b><f
ont face="Arial" size="4">hello</font></b>'); |
26 testSingleToggle("fontSize", 4, '<font face="Arial"><i>hello</i></font>', '<font
face="Arial" size="4"><i>hello</i></font>'); | 26 testSingleToggle("fontSize", 4, '<font face="Arial"><i>hello</i></font>', '<font
face="Arial" size="4"><i>hello</i></font>'); |
27 testSingleToggle("fontName", "Arial", '<b><font face="Arial">hello</font></b> wo
rld', '<font face="Arial"><b>hello</b> world</font>'); | 27 testSingleToggle("fontName", "Arial", '<b><font face="Arial">hello</font></b> wo
rld', '<font class="Apple-style-span" face="Arial"><b>hello</b> world</font>'); |
28 testSingleToggle("fontName", "Arial", '<font color="blue">hello</font> world', '
<font face="Arial"><font color="blue">hello</font> world</font>'); | 28 testSingleToggle("fontName", "Arial", '<font color="blue">hello</font> world', '
<font class="Apple-style-span" face="Arial"><font color="blue">hello</font> worl
d</font>'); |
29 testSingleToggle("fontName", "Arial", '<b><u>hello</u> world</b>', '<b><font fac
e="Arial"><u>hello</u> world</font></b>'); | 29 testSingleToggle("fontName", "Arial", '<b><u>hello</u> world</b>', '<b><font cla
ss="Apple-style-span" face="Arial"><u>hello</u> world</font></b>'); |
30 testSingleToggle("foreColor", 'blue', '<font><u style="color:red;">hello</u></fo
nt>', '<font color="#0000ff"><u>hello</u></font>'); | 30 testSingleToggle("foreColor", 'blue', '<font><u style="color:red;">hello</u></fo
nt>', '<font color="#0000ff"><u>hello</u></font>'); |
31 testSingleToggle("foreColor", 'rgba(0, 50, 100, 0.4)', '<font><u style="color:re
d;">hello</u></font>', '<font color="rgba(0, 50, 100, 0.4)"><u>hello</u></font>'
); | 31 testSingleToggle("foreColor", 'rgba(0, 50, 100, 0.4)', '<font><u style="color:re
d;">hello</u></font>', '<font color="rgba(0, 50, 100, 0.4)"><u>hello</u></font>'
); |
32 testSingleToggle("bold", null, '<u><strike>hello</strike> <strike>world</strike>
</u>', '<u><b><strike>hello</strike> <strike>world</strike></b></u>'); | 32 testSingleToggle("bold", null, '<u><strike>hello</strike> <strike>world</strike>
</u>', '<u><b><strike>hello</strike> <strike>world</strike></b></u>'); |
33 testSingleToggle("bold", null, '<i>hello</i> <b>world</b>', '<b><i>hello</i> wor
ld</b>'); | 33 testSingleToggle("bold", null, '<i>hello</i> <b>world</b>', '<b><i>hello</i> wor
ld</b>'); |
34 testSingleToggle("bold", null, '<strike><i><u>hello <b>world</b></u></i> webkit<
/strike>', '<strike><b><i><u>hello world</u></i> webkit</b></strike>'); | 34 testSingleToggle("bold", null, '<strike><i><u>hello <b>world</b></u></i> webkit<
/strike>', '<strike><b><i><u>hello world</u></i> webkit</b></strike>'); |
35 testSingleToggle("bold", null, | 35 testSingleToggle("bold", null, |
36 '<b contenteditable="false"><span style="font-weight: normal;">hello</span>
world</b> world', | 36 '<b contenteditable="false"><span style="font-weight: normal;">hello</span>
world</b> world', |
37 '<b contenteditable="false"><span style="font-weight: normal;">hello</span>
world</b><b> world</b>'); | 37 '<b contenteditable="false"><span style="font-weight: normal;">hello</span>
world</b><b> world</b>'); |
38 testSingleToggle("bold", null, | 38 testSingleToggle("bold", null, |
39 '<i>hello</i> <b contenteditable="false">world</b>', | 39 '<i>hello</i> <b contenteditable="false">world</b>', |
(...skipping 10 matching lines...) Expand all Loading... |
50 testSingleToggle("fontSize", 4, '<i><b>hello</b> world</i>', '<i style="font-siz
e: large;"><b>hello</b> world</i>'); | 50 testSingleToggle("fontSize", 4, '<i><b>hello</b> world</i>', '<i style="font-siz
e: large;"><b>hello</b> world</i>'); |
51 testSingleToggle("fontSize", 4, '<font color="blue"><b>hello</b></font>', '<font
color="blue"><b style="font-size: large;">hello</b></font>'); | 51 testSingleToggle("fontSize", 4, '<font color="blue"><b>hello</b></font>', '<font
color="blue"><b style="font-size: large;">hello</b></font>'); |
52 testSingleToggle("bold", null, '<span style="font-style: italic;">hello</span>',
'<span style="font-style: italic; font-weight: bold;">hello</span>'); | 52 testSingleToggle("bold", null, '<span style="font-style: italic;">hello</span>',
'<span style="font-style: italic; font-weight: bold;">hello</span>'); |
53 testSingleToggle("underline", null, '<span style="font-style: italic;"><b>hello<
/b></span>', '<span style="font-style: italic; text-decoration: underline;"><b>h
ello</b></span>'); | 53 testSingleToggle("underline", null, '<span style="font-style: italic;"><b>hello<
/b></span>', '<span style="font-style: italic; text-decoration: underline;"><b>h
ello</b></span>'); |
54 testSingleToggle("underline", null, | 54 testSingleToggle("underline", null, |
55 '<span style="color: blue;"><i><span style="font-size: large;"><b>hello</b>
world</span></i></span>', | 55 '<span style="color: blue;"><i><span style="font-size: large;"><b>hello</b>
world</span></i></span>', |
56 '<span style="color: blue;"><i><span style="font-size: large; text-decoratio
n: underline;"><b>hello</b> world</span></i></span>'); | 56 '<span style="color: blue;"><i><span style="font-size: large; text-decoratio
n: underline;"><b>hello</b> world</span></i></span>'); |
57 | 57 |
58 document.body.removeChild(testContainer); | 58 document.body.removeChild(testContainer); |
59 var successfullyParsed = true; | 59 var successfullyParsed = true; |
OLD | NEW |