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 24 matching lines...) Expand all Loading... |
35 return 'last two words'; | 35 return 'last two words'; |
36 } | 36 } |
37 | 37 |
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 if (window.internals) | 44 if (window.internals) |
45 internals.settings.setEditingBehavior('mac'); | 45 internals.settings.setEditingBehavior('win'); |
46 | 46 |
47 testSingleToggle("unlink", 'hello <b>world</b>', selectAll, 'hello <b>world</b>'
); | 47 testSingleToggle("unlink", 'hello <b>world</b>', selectAll, 'hello <b>world</b>'
); |
48 testSingleToggle("unlink", '<a href="http://webkit.org/"><u>hello world</u></a>'
, selectAll, '<u>hello world</u>'); | 48 testSingleToggle("unlink", '<a href="http://webkit.org/"><u>hello world</u></a>'
, selectAll, '<u>hello world</u>'); |
49 testSingleToggle("unlink", 'hello <i><a href="http://webkit.org/">world</a></i>'
, selectAll, 'hello <i>world</i>'); | 49 testSingleToggle("unlink", 'hello <i><a href="http://webkit.org/">world</a></i>'
, selectAll, 'hello <i>world</i>'); |
50 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-weigh
t: bold;">world</a>', selectAll, 'hello <b>world</b>'); | 50 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-weigh
t: bold;">world</a>', selectAll, 'hello <b>world</b>'); |
51 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="color: blu
e;">world</a> WebKit', selectAll, 'hello <font color="#0000ff">world</font> WebK
it'); | 51 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="color: blu
e;">world</a> WebKit', selectAll, 'hello <font color="#0000ff">world</font> WebK
it'); |
52 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="color: blu
e; display: block;">world</a> WebKit', | 52 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="color: blu
e; display: block;">world</a> WebKit', |
53 selectAll, 'hello <font color="#0000ff"><span style="display: block;">world<
/span></font> WebKit'); | 53 selectAll, 'hello <font color="#0000ff"><span style="display: block;">world<
/span></font> WebKit'); |
54 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-size: large
;">hello world</a> WebKit', | 54 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-size: large
;">hello world</a> WebKit', |
55 selectLastTwoWords, '<a href="http://webkit.org/" style="font-size: large;">
hello </a><font size="4">world</font> WebKit'); | 55 selectLastTwoWords, '<a href="http://webkit.org/" style="font-size: large;">
hello </a><font size="4">world</font> WebKit'); |
56 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-size:
large;">world <span style="font-size: small;">WebKit</span> rocks</a>', | 56 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-size:
large;">world <span style="font-size: small;">WebKit</span> rocks</a>', |
57 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>'); | 57 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>'); |
58 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-style
: italic;"><b>world</b> WebKit</a>', | 58 testSingleToggle("unlink", 'hello <a href="http://webkit.org/" style="font-style
: italic;"><b>world</b> WebKit</a>', |
59 selectFirstTwoWords, 'hello <b style="font-style: italic;">world</b><a href=
"http://webkit.org/"><i> WebKit</i></a>'); | 59 selectFirstTwoWords, 'hello <b style="font-style: italic;">world</b> <a href
="http://webkit.org/" style="font-style: italic;">WebKit</a>'); |
60 | |
61 testSingleToggle("unlink", '<a href="http://webkit.org/" style="background-color
: yellow;"><div>hello</div><div>world</div></a>', | 60 testSingleToggle("unlink", '<a href="http://webkit.org/" style="background-color
: yellow;"><div>hello</div><div>world</div></a>', |
62 selectAll, '<div style="background-color: yellow;">hello</div><div style="ba
ckground-color: yellow;">world</div>'); | 61 selectAll, '<div style="background-color: yellow;">hello</div><div style="ba
ckground-color: yellow;">world</div>'); |
63 testSingleToggle("unlink", 'hello<a href="http://webkit.org/" style="background-
color: yellow;"><div>world</div></a>WebKit', | 62 testSingleToggle("unlink", 'hello<a href="http://webkit.org/" style="background-
color: yellow;"><div>world</div></a>WebKit', |
64 selectAll, 'hello<div style="background-color: yellow;">world</div><span sty
le="background-color: yellow;">WebKit</span>'); | 63 selectAll, 'hello<div style="background-color: yellow;">world</div><span sty
le="background-color: yellow;">WebKit</span>'); |
65 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-weight: bol
d;"><div>hello</div><div>world WebKit</div></a>', | 64 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-weight: bol
d;"><div>hello</div><div>world WebKit</div></a>', |
66 selectLastTwoWords, '<a href="http://webkit.org/"><div style="font-weight: b
old;">hello</div></a><div style="font-weight: bold;">world WebKit</div>'); | 65 selectLastTwoWords, '<a href="http://webkit.org/"><div style="font-weight: b
old;">hello</div></a><div style="font-weight: bold;">world WebKit</div>'); |
67 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-weight: bol
d;"><div style="font-weight: normal;">hello</div><div>world</div></a>', | 66 testSingleToggle("unlink", '<a href="http://webkit.org/" style="font-weight: bol
d;"><div style="font-weight: normal;">hello</div><div>world</div></a>', |
68 selectLastWord, '<a href="http://webkit.org/"><div style="font-weight: norma
l;">hello</div></a><div style="font-weight: bold;">world</div>'); | 67 selectLastWord, '<a href="http://webkit.org/"><div style="font-weight: norma
l;">hello</div></a><div style="font-weight: bold;">world</div>'); |
69 | 68 |
70 document.body.removeChild(testContainer); | 69 document.body.removeChild(testContainer); |
71 | 70 |
72 var successfullyParsed = true; | 71 var successfullyParsed = true; |
OLD | NEW |