OLD | NEW |
1 description("Test to make sure we remove span tags with no attributes if we remo
ved the last attribute.") | 1 description("Test to make sure we remove span tags with no attributes if we remo
ved the last attribute.") |
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 if (window.internals) | 6 if (window.internals) |
7 internals.settings.setEditingBehavior('mac'); | 7 internals.settings.setEditingBehavior("win"); |
8 | 8 |
9 function testSingleToggle(toggleCommand, initialContents, selector, expectedCont
ents) | 9 function testSingleToggle(toggleCommand, initialContents, selector, expectedCont
ents) |
10 { | 10 { |
11 testContainer.innerHTML = initialContents; | 11 testContainer.innerHTML = initialContents; |
12 var selected = selector(testContainer); | 12 var selected = selector(testContainer); |
13 document.execCommand(toggleCommand, false, 'http://webkit.org/'); | 13 document.execCommand(toggleCommand, false, 'http://webkit.org/'); |
14 action = 'select ' + selected + ' of "' + initialContents + '" and ' + toggl
eCommand + ' (http://webkit.org/) yields "' + testContainer.innerHTML + '"'; | 14 action = 'select ' + selected + ' of "' + initialContents + '" and ' + toggl
eCommand + ' (http://webkit.org/) yields "' + testContainer.innerHTML + '"'; |
15 if (testContainer.innerHTML === expectedContents) | 15 if (testContainer.innerHTML === expectedContents) |
16 testPassed(action); | 16 testPassed(action); |
17 else | 17 else |
(...skipping 15 matching lines...) Expand all Loading... |
33 function selectLastWord(container) { | 33 function selectLastWord(container) { |
34 window.getSelection().setPosition(container, container.childNodes.length); | 34 window.getSelection().setPosition(container, container.childNodes.length); |
35 window.getSelection().modify('extend', 'backward', 'word'); | 35 window.getSelection().modify('extend', 'backward', 'word'); |
36 return 'last word'; | 36 return 'last word'; |
37 } | 37 } |
38 | 38 |
39 testSingleToggle("createLink", 'hello <b>world</b>', selectAll, '<a href="http:/
/webkit.org/">hello <b>world</b></a>'); | 39 testSingleToggle("createLink", 'hello <b>world</b>', selectAll, '<a href="http:/
/webkit.org/">hello <b>world</b></a>'); |
40 testSingleToggle("createLink", '<u>hello world</u>', selectAll, '<u><a href="htt
p://webkit.org/">hello world</a></u>'); | 40 testSingleToggle("createLink", '<u>hello world</u>', selectAll, '<u><a href="htt
p://webkit.org/">hello world</a></u>'); |
41 testSingleToggle("createLink", 'hello <a href="http://bugs.webkit.org/">world</a
>', selectAll, '<a href="http://webkit.org/">hello world</a>'); | 41 testSingleToggle("createLink", 'hello <a href="http://bugs.webkit.org/">world</a
>', selectAll, '<a href="http://webkit.org/">hello world</a>'); |
42 testSingleToggle("createLink", 'hello <a href="http://bugs.webkit.org/" style="f
ont-weight: bold">world</a>', selectAll, '<a href="http://webkit.org/">hello <b>
world</b></a>'); | 42 testSingleToggle("createLink", 'hello <a href="http://bugs.webkit.org/" style="f
ont-weight: bold">world</a>', selectAll, '<a href="http://webkit.org/">hello <b>
world</b></a>'); |
43 testSingleToggle("createLink", 'hello <b>world</b> WebKit', selectFirstTwoWords,
'<a href="http://webkit.org/">hello <b>world</b></a> WebKit'); | 43 testSingleToggle("createLink", 'hello <b>world</b> WebKit', selectFirstTwoWords,
'<a href="http://webkit.org/">hello <b>world</b> </a>WebKit'); |
44 testSingleToggle("createLink", '<a href="http://trac.webkit.org/">hello <b>world
</b></a> WebKit', selectFirstTwoWords, '<a href="http://webkit.org/">hello <b>wo
rld</b></a> WebKit'); | 44 testSingleToggle("createLink", '<a href="http://trac.webkit.org/">hello <b>world
</b></a> WebKit', selectFirstTwoWords, '<a href="http://webkit.org/">hello <b>wo
rld</b> </a>WebKit'); |
45 testSingleToggle("createLink", '<a href="http://trac.webkit.org/" style="font-st
yle: italic;">hello world</a> WebKit', selectFirstTwoWords, '<i><a href="http://
webkit.org/">hello world</a></i> WebKit'); | 45 testSingleToggle("createLink", '<a href="http://trac.webkit.org/" style="font-st
yle: italic;">hello world</a> WebKit', selectFirstTwoWords, '<a href="http://web
kit.org/"><i>hello world</i> </a>WebKit'); |
46 testSingleToggle("createLink", 'hello <a href="http://trac.webkit.org/"><b>world
</b> WebKit</a>', selectFirstTwoWords, '<a href="http://webkit.org/">hello <b>wo
rld</b></a><a href="http://trac.webkit.org/"> WebKit</a>'); | 46 testSingleToggle("createLink", 'hello <a href="http://trac.webkit.org/"><b>world
</b> WebKit</a>', selectFirstTwoWords, '<a href="http://webkit.org/">hello <b>wo
rld</b> </a><a href="http://trac.webkit.org/">WebKit</a>'); |
47 testSingleToggle("createLink", 'hello <a href="http://trac.webkit.org/" style="f
ont-style: italic;"><b>world</b> WebKit</a>', selectFirstTwoWords, | 47 testSingleToggle("createLink", 'hello <a href="http://trac.webkit.org/" style="f
ont-style: italic;"><b>world</b> WebKit</a>', selectFirstTwoWords, |
48 '<a href="http://webkit.org/">hello <b style="font-style: italic;">world</b>
</a><a href="http://trac.webkit.org/"><i> WebKit</i></a>'); | 48 '<a href="http://webkit.org/">hello <b style="font-style: italic;">world</b>
</a><a href="http://trac.webkit.org/" style="font-style: italic;">WebKit</a>'); |
| 49 |
49 testSingleToggle("createLink", 'hello <b>world</b> WebKit', selectLastWord, 'hel
lo <b>world</b> <a href="http://webkit.org/">WebKit</a>'); | 50 testSingleToggle("createLink", 'hello <b>world</b> WebKit', selectLastWord, 'hel
lo <b>world</b> <a href="http://webkit.org/">WebKit</a>'); |
50 testSingleToggle("createLink", '<u>hello <b>world</b> WebKit</u>', selectLastWor
d, '<u>hello <b>world</b> <a href="http://webkit.org/">WebKit</a></u>'); | 51 testSingleToggle("createLink", '<u>hello <b>world</b> WebKit</u>', selectLastWor
d, '<u>hello <b>world</b> <a href="http://webkit.org/">WebKit</a></u>'); |
51 testSingleToggle("createLink", '<a href="http://trac.webkit.org/"><div>hello</di
v><div>world</div></a>', selectLastWord, | 52 testSingleToggle("createLink", '<a href="http://trac.webkit.org/"><div>hello</di
v><div>world</div></a>', selectLastWord, |
52 '<a href="http://trac.webkit.org/"><div>hello</div></a><div><a href="http://
webkit.org/">world</a></div>'); | 53 '<a href="http://trac.webkit.org/"><div>hello</div></a><div><a href="http://
webkit.org/">world</a></div>'); |
53 testSingleToggle("createLink", '<a href="http://trac.webkit.org/" style="font-we
ight: bold;"><div>hello</div><div>world</div></a>', selectLastWord, | 54 testSingleToggle("createLink", '<a href="http://trac.webkit.org/" style="font-we
ight: bold;"><div>hello</div><div>world</div></a>', selectLastWord, |
54 '<a href="http://trac.webkit.org/"><div style="font-weight: bold;">hello</di
v></a><div style="font-weight: bold;"><a href="http://webkit.org/">world</a></di
v>'); | 55 '<a href="http://trac.webkit.org/"><div style="font-weight: bold;">hello</di
v></a><div style="font-weight: bold;"><a href="http://webkit.org/">world</a></di
v>'); |
55 testSingleToggle("createLink", '<a href="http://trac.webkit.org/" style="font-we
ight: bold;"><div style="font-weight: normal;">hello</div><div>world</div></a>',
selectLastWord, | 56 testSingleToggle("createLink", '<a href="http://trac.webkit.org/" style="font-we
ight: bold;"><div style="font-weight: normal;">hello</div><div>world</div></a>',
selectLastWord, |
56 '<a href="http://trac.webkit.org/"><div style="font-weight: normal;">hello</
div></a><div style="font-weight: bold;"><a href="http://webkit.org/">world</a></
div>'); | 57 '<a href="http://trac.webkit.org/"><div style="font-weight: normal;">hello</
div></a><div style="font-weight: bold;"><a href="http://webkit.org/">world</a></
div>'); |
57 | 58 |
58 document.body.removeChild(testContainer); | 59 document.body.removeChild(testContainer); |
59 | 60 |
60 var successfullyParsed = true; | 61 var successfullyParsed = true; |
OLD | NEW |