Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / execCommand / script-tests / remove-format-multiple-elements-mac.js
blob395724027e6ac6e59b6eca18c1d8675b8baa2ba3
1 description("This tests removing multiple elements by RemoveFormat command.")
3 var testContainer = document.createElement("div");
4 testContainer.contentEditable = true;
5 document.body.appendChild(testContainer);
6 if (window.internals)
7 internals.settings.setEditingBehavior("mac");
9 function testRemoveFormat(initialContents, selector, expected)
11 testContainer.innerHTML = initialContents;
12 var selected = selector(testContainer);
13 document.execCommand('RemoveFormat', false, null);
14 var action = 'RemoveFormat on ' + selected + ' of "' + initialContents + '" yields "' + testContainer.innerHTML + '"';
15 if (testContainer.innerHTML === expected)
16 testPassed(action);
17 else
18 testFailed(action + ', expected "' + expected + '"');
21 function selectAll(container) {
22 window.getSelection().selectAllChildren(container);
23 return 'all';
26 function selectSecondWord(container) {
27 window.getSelection().collapse(container, 0);
28 window.getSelection().modify('move', 'forward', 'word');
29 window.getSelection().modify('move', 'forward', 'word');
30 window.getSelection().modify('extend', 'backward', 'word');
31 return 'second word';
34 function selectFirstTwoWords(container) {
35 window.getSelection().collapse(container, 0);
36 window.getSelection().modify('extend', 'forward', 'word');
37 window.getSelection().modify('extend', 'forward', 'word');
38 return 'first two words';
41 function selectLastTwoWords(container) {
42 window.getSelection().collapse(container, container.childNodes.length);
43 window.getSelection().modify('extend', 'backward', 'word');
44 window.getSelection().modify('extend', 'backward', 'word');
45 return 'last two words';
48 function selectLastWord(container) {
49 window.getSelection().collapse(container, container.childNodes.length);
50 window.getSelection().modify('extend', 'backward', 'word');
51 return 'last word';
54 function selectFirstLine(container) {
55 window.getSelection().collapse(container, 0);
56 window.getSelection().modify('extend', 'forward', 'line');
57 return 'first line';
60 testRemoveFormat('hello', selectAll, 'hello');
61 testRemoveFormat('<i>hello</i> <u>world</u>', selectAll, 'hello world');
62 testRemoveFormat('<b><u>hello</u> world</b> <a href="http://webkit.org/"><em>WebKit</em></a>', selectAll, 'hello world <a href="http://webkit.org/">WebKit</a>');
63 testRemoveFormat('<b><u>hello</u> world</b> <a href="http://webkit.org/"><em>WebKit</em></a>',
64 selectSecondWord, '<b><u>hello</u> </b>world <a href="http://webkit.org/"><em>WebKit</em></a>');
65 testRemoveFormat('<sub><tt>hello world WebKit</tt></sub>', selectSecondWord, '<sub><tt>hello </tt></sub>world<sub><tt> WebKit</tt></sub>');
66 testRemoveFormat('<q><ins><var>hello wor</var>ld</ins> WebKit</q>', selectSecondWord, '<q><ins><var>hello </var></ins></q>world<q> WebKit</q>');
67 testRemoveFormat('<b>hello <dfn>world <kbd>WebKit</kbd></dfn></b>', selectLastWord, '<b>hello <dfn>world </dfn></b>WebKit');
68 testRemoveFormat('<b>hello <dfn>world <kbd>WebKit</kbd></dfn></b>', selectSecondWord, '<b>hello </b>world<b><dfn> <kbd>WebKit</kbd></dfn></b>');
69 testRemoveFormat('<code>hello <strong>world WebKit</storng></code>', selectFirstTwoWords, 'hello world<code><strong> WebKit</strong></code>');
70 testRemoveFormat('<acronym><tt><mark><samp>hello</samp></mark> world <sub>WebKit</sub></tt></acronym>',
71 selectFirstTwoWords, '<mark>hello</mark> world<acronym><tt> <sub>WebKit</sub></tt></acronym>');
72 testRemoveFormat('<b><div>hello world</div></b><div>WebKit</div>', selectLastTwoWords, '<div><b>hello </b>world</div><div>WebKit</div>');
73 testRemoveFormat('<q><b><div>hello world</div></b>WebKit</q>', selectLastTwoWords, '<div><q><b>hello </b></q>world</div>WebKit');
74 testRemoveFormat('<q><b><div>hello world</div></b>WebKit</q>', selectSecondWord, '<div><q><b>hello </b></q>world</div><q>WebKit</q>');
75 testRemoveFormat('<b><div>hello</div>webkit</b>', selectFirstLine, '<div>hello</div><b>webkit</b>');
77 testRemoveFormat('<i style="font-weight:bold;">hello</i> <u>world</u>', selectAll, 'hello world');
78 testRemoveFormat('<font color="red"><b style="font-size: large;"><u>hello</u> world</b> WebKit</font>',
79 selectSecondWord, '<font color="red"><b style="font-size: large;"><u>hello</u> </b></font>world<font color="red"> WebKit</font>');
80 testRemoveFormat('<font size="5"><i><u style="font-size: small;">hello</u> world</i><font size="3"> WebKit</font></font>',
81 selectSecondWord, '<font size="5"><i><u style="font-size: small;">hello</u> </i></font>world<font size="5"><font size="3"> WebKit</font></font>');
82 testRemoveFormat('<sup><div style="text-decoration-line: underline; font-size: large;">hello <dfn style="font-size: normal;">world</dfn></div> WebKit</sup>',
83 selectSecondWord, '<div><sup><font size="4"><u>hello </u></font></sup>world</div><sup> WebKit</sup>');
85 document.body.removeChild(testContainer);
87 var successfullyParsed = true;