4 <script src="../../fast/js/resources/js-test-pre.js"></script>
7 <p id="description"></p>
8 <div id="console"></div>
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');
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);
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");
46 testFailed("queryCommandState('useCSS') should return boolean false");
48 if (document.queryCommandValue('useCSS') === false)
49 testPassed("queryCommandValue('useCSS') returns false");
51 testFailed("queryCommandValue('useCSS') should return boolean false");
53 testSingleToggle("underline", "test", "<span style=\"text-decoration: underline;\">test</span>");
55 document.body.removeChild(testContainer);
58 <script src="../../fast/js/resources/js-test-post.js"></script>