Move parseFontFaceDescriptor to CSSPropertyParser.cpp
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / execCommand / script-tests / toggle-compound-styles.js
blobda45460b47be73b6d231b9ab41a60c94c2be794e
1 description("Test to make sure we can toggle text decorations correctly. The first three tests give different result on mac only.")
3 var testContainer = document.createElement("div");
4 testContainer.contentEditable = true;
5 document.body.appendChild(testContainer);
7 function testSingleToggle(toggleCommand, initialContents, expectedContents)
9 testContainer.innerHTML = initialContents;
10 window.getSelection().selectAllChildren(testContainer);
11 document.execCommand(toggleCommand, false, null);
12 var action = 'one ' + toggleCommand + ' command converted "' + initialContents + '" to "' + expectedContents;
13 if (testContainer.innerHTML === expectedContents)
14 testPassed(action);
15 else
16 testFailed(action + '", expected "' + expectedContents + '"');
19 platforms = ['mac', 'win', 'unix', 'android'];
21 for (var i = 0; i < platforms.length; i++) {
22 platform = platforms[i];
23 debug('Platform: ' + platform);
25 if (window.internals)
26 internals.settings.setEditingBehavior(platform);
28 if (platform != 'mac')
29 platform = 'nonmac';
31 testSingleToggle("bold", "<u><b>hello</b> world</u>", {mac: '<u>hello world</u>', nonmac: '<u><b>hello world</b></u>'}[platform]);
32 testSingleToggle("bold", "<b>hello </b>world", {mac: 'hello world', nonmac: '<b>hello world</b>'}[platform]);
33 testSingleToggle("bold", "<u><b>hello </b></u>world", {mac: '<u>hello </u>world', nonmac: '<b><u>hello </u>world</b>'}[platform]);
34 testSingleToggle("italic", "<i>hello</i> <img>", {mac: 'hello <img>', nonmac: '<i>hello <img></i>'}[platform]);
36 // Following tests are cross-platform
37 testSingleToggle("bold", "<u><span id='test'><b>hello</b></span><b>world</b></u>", '<u><span id="test">hello</span>world</u>');
38 testSingleToggle("bold", "<span id='test' style='font-weight:normal;'><b>hello</b></span>", '<span id="test">hello</span>');
39 testSingleToggle("bold", "<div><b>hello</b><br><br><b>world</b></div>", "<div>hello<br><br>world</div>");
40 testSingleToggle("italic", "<i>hello </i><img>", "hello <img>");
41 testSingleToggle("italic", "<i><b>hello</b>world</i>", "<b>hello</b>world");
42 testSingleToggle("italic", "<span style='font-style: normal;'> <i> hello </i> </span>", " hello ");
43 testSingleToggle("italic", "<p><i>hello</i><span style='font-style:italic;'>world</span></p>", "<p>helloworld</p>");
44 testSingleToggle("italic", "<s><b>hello<i> world</i></b></s>", "<s><b><i>hello world</i></b></s>");
46 debug('');
49 document.body.removeChild(testContainer);
51 var successfullyParsed = true;