tizen beta release
[profile/ivi/webkit-efl.git] / LayoutTests / editing / execCommand / use-css.html
1 <!DOCTYPE html>
2 <html>
3 <head>
4 <script src="../../fast/js/resources/js-test-pre.js"></script>
5 </head>
6 <body>
7 <p id="description"></p>
8 <div id="console"></div>
9 <script>
10 description('Test useCSS command');
11
12 var testContainer = document.createElement("div");
13 testContainer.contentEditable = true;
14 document.body.appendChild(testContainer);
15
16 function testUseCSS(styleArg, expectedState)
17 {
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);
23 }
24
25 function testSingleToggle(toggleCommand, initialContents, expectedContents)
26 {
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);
35 }
36
37 testUseCSS(false, true);
38 testUseCSS('false', true);
39 testUseCSS('FALSE', true);
40 testUseCSS(true, false);
41 testUseCSS('random string', false);
42
43 if (document.queryCommandState('useCSS') === false)
44     testPassed("queryCommandState('useCSS') returns false");
45 else
46     testFailed("queryCommandState('useCSS') should return boolean false");
47
48 if (document.queryCommandValue('useCSS') === false)
49     testPassed("queryCommandValue('useCSS') returns false");
50 else
51     testFailed("queryCommandValue('useCSS') should return boolean false");
52
53 testSingleToggle("underline", "test", "<span style=\"text-decoration: underline;\">test</span>");
54
55 document.body.removeChild(testContainer);
56
57 </script>
58 <script src="../../fast/js/resources/js-test-post.js"></script>
59 </body>
60 </html>