OLD | NEW |
1 description("Test to make sure we preserve styles when removing links") | 1 description("Test to make sure we preserve styles when removing links") |
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, initialContents, selector, expectedCont
ents) | 7 function testSingleToggle(toggleCommand, initialContents, selector, expectedCont
ents) |
8 { | 8 { |
9 testContainer.innerHTML = initialContents; | 9 testContainer.innerHTML = initialContents; |
10 var selected = selector(testContainer); | 10 var selected = selector(testContainer); |
(...skipping 27 matching lines...) Expand all Loading... |
38 function selectLastWord(container) { | 38 function selectLastWord(container) { |
39 window.getSelection().setPosition(container, container.childNodes.length); | 39 window.getSelection().setPosition(container, container.childNodes.length); |
40 window.getSelection().modify('extend', 'backward', 'word'); | 40 window.getSelection().modify('extend', 'backward', 'word'); |
41 return 'last word'; | 41 return 'last word'; |
42 } | 42 } |
43 | 43 |
44 testSingleToggle("unlink", 'hello <b>world</b>', selectAll, 'hello <b>world</b>'
); | 44 testSingleToggle("unlink", 'hello <b>world</b>', selectAll, 'hello <b>world</b>'
); |
45 testSingleToggle("unlink", '<a href="http://webkit.org/"><u>hello world</u></a>'
, selectAll, '<u>hello world</u>'); | 45 testSingleToggle("unlink", '<a href="http://webkit.org/"><u>hello world</u></a>'
, selectAll, '<u>hello world</u>'); |
46 testSingleToggle("unlink", 'hello <i><a href="http://webkit.org/">world</a></i>'
, selectAll, 'hello <i>world</i>'); | 46 testSingleToggle("unlink", 'hello <i><a href="http://webkit.org/">world</a></i>'
, selectAll, 'hello <i>world</i>'); |
47 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-weigh
t: bold;">world</a>', selectAll, 'hello <b>world</b>'); | 47 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-weigh
t: bold;">world</a>', selectAll, 'hello <b>world</b>'); |
48 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="color: blu
e;">world</a> WebKit', selectAll, 'hello <font color="#0000ff">world</font> WebK
it'); | 48 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="color: blu
e;">world</a> WebKit', selectAll, 'hello <font class="Apple-style-span" color="#
0000ff">world</font> WebKit'); |
49 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="color: blu
e; display: block;">world</a> WebKit', | 49 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="color: blu
e; display: block;">world</a> WebKit', selectAll, 'hello <font class="Apple-styl
e-span" color="#0000ff"><span class="Apple-style-span" style="display: block;">w
orld</span></font> WebKit'); |
50 selectAll, 'hello <font color="#0000ff"><span style="display: block;">world<
/span></font> WebKit'); | |
51 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-size: large
;">hello world</a> WebKit', | 50 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-size: large
;">hello world</a> WebKit', |
52 selectLastTwoWords, '<a href="http://webkit.org/" style="font-size: large;">
hello </a><font size="4">world</font> WebKit'); | 51 selectLastTwoWords, '<a href="http://webkit.org/" style="font-size: large;">
hello </a><font class="Apple-style-span" size="4">world</font> WebKit'); |
53 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-size:
large;">world <span style="font-size: small; ">WebKit</span> rocks</a>', | 52 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-size:
large;">world <span style="font-size: small; ">WebKit</span> rocks</a>', |
54 selectLastTwoWords, 'hello <a href="http://webkit.org/"><font size="4">world
</font></a><span style="font-size: small; ">WebKit</span><font size="4"> rocks<
/font>'); | 53 selectLastTwoWords, 'hello <a href="http://webkit.org/"><font class="Apple-s
tyle-span" size="4">world </font></a><span style="font-size: small; ">WebKit</sp
an><font class="Apple-style-span" size="4"> rocks</font>'); |
55 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-style
: italic;"><b>world</b> WebKit</a>', | 54 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-style
: italic;"><b>world</b> WebKit</a>', |
56 selectFirstTwoWords, 'hello <b style="font-style: italic; ">world</b><a href
="http://webkit.org/"><i> WebKit</i></a>'); | 55 selectFirstTwoWords, 'hello <b style="font-style: italic; ">world</b><a href
="http://webkit.org/"><i> WebKit</i></a>'); |
57 | 56 |
58 testSingleToggle("unlink", '<a href="http://webkit.org/" style="background-color
: yellow;"><div>hello</div><div>world</div></a>', | 57 testSingleToggle("unlink", '<a href="http://webkit.org/" style="background-color
: yellow;"><div>hello</div><div>world</div></a>', |
59 selectAll, '<div style="background-color: yellow; ">hello</div><div style="b
ackground-color: yellow; ">world</div>'); | 58 selectAll, '<div style="background-color: yellow; ">hello</div><div style="b
ackground-color: yellow; ">world</div>'); |
60 testSingleToggle("unlink", 'hello<a href="http://webkit.org/" style="background-
color: yellow;"><div>world</div></a>WebKit', | 59 testSingleToggle("unlink", 'hello<a href="http://webkit.org/" style="background-
color: yellow;"><div>world</div></a>WebKit', |
61 selectAll, 'hello<div style="background-color: yellow; ">world</div><span st
yle="background-color: yellow;">WebKit</span>'); | 60 selectAll, 'hello<div style="background-color: yellow; ">world</div><span cl
ass="Apple-style-span" style="background-color: yellow;">WebKit</span>'); |
62 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-weight: bol
d;"><div>hello</div><div>world WebKit</div></a>', | 61 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-weight: bol
d;"><div>hello</div><div>world WebKit</div></a>', |
63 selectLastTwoWords, '<a href="http://webkit.org/"><div style="font-weight: b
old; ">hello</div></a><div style="font-weight: bold; ">world WebKit</div>'); | 62 selectLastTwoWords, '<a href="http://webkit.org/"><div style="font-weight: b
old; ">hello</div></a><div style="font-weight: bold; ">world WebKit</div>'); |
64 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-weight: bol
d;"><div style="font-weight: normal;">hello</div><div>world</div></a>', | 63 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-weight: bol
d;"><div style="font-weight: normal;">hello</div><div>world</div></a>', |
65 selectLastWord, '<a href="http://webkit.org/"><div style="font-weight: norma
l; ">hello</div></a><div style="font-weight: bold; ">world</div>'); | 64 selectLastWord, '<a href="http://webkit.org/"><div style="font-weight: norma
l; ">hello</div></a><div style="font-weight: bold; ">world</div>'); |
66 | 65 |
67 document.body.removeChild(testContainer); | 66 document.body.removeChild(testContainer); |
68 | 67 |
69 var successfullyParsed = true; | 68 var successfullyParsed = true; |
OLD | NEW |