Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / execCommand / use-css.html
blobc8ad298404f4c5e9bb4df6aca5e475259a285884
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../resources/js-test.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('Test useCSS command');
12 var testContainer = document.createElement("div");
13 testContainer.contentEditable = true;
14 document.body.appendChild(testContainer);
16 function testUseCSS(styleArg, expectedState)
18 document.execCommand('useCSS', false, styleArg);
19 if (document.queryCommandState('styleWithCSS') === expectedState)
20 testPassed('useCSS changed the state successfully');
21 else
22 testFailed('useCSS failed with the argument ' + styleArg);
25 function testSingleToggle(toggleCommand, initialContents, expectedContents)
27 testContainer.innerHTML = initialContents;
28 window.getSelection().selectAllChildren(testContainer);
29 document.execCommand("useCSS", false, false);
30 document.execCommand(toggleCommand, false, null);
31 if (testContainer.innerHTML === expectedContents)
32 testPassed("one " + toggleCommand + " command converted " + initialContents + " to " + expectedContents);
33 else
34 testFailed("one " + toggleCommand + " command converted " + initialContents + " to " + testContainer.innerHTML + ", expected " + expectedContents);
37 testUseCSS(false, true);
38 testUseCSS('false', true);
39 testUseCSS('FALSE', true);
40 testUseCSS(true, false);
41 testUseCSS('random string', false);
43 if (document.queryCommandState('useCSS') === false)
44 testPassed("queryCommandState('useCSS') returns false");
45 else
46 testFailed("queryCommandState('useCSS') should return boolean false");
48 if (document.queryCommandValue('useCSS') === "")
49 testPassed("queryCommandValue('useCSS') returns ''");
50 else
51 testFailed("queryCommandValue('useCSS') should return string ''");
53 testSingleToggle("underline", "test", "<span style=\"text-decoration-line: underline;\">test</span>");
55 document.body.removeChild(testContainer);
57 </script>
58 </body>
59 </html>