Upstream version 7.36.149.0
[platform/framework/web/crosswalk.git] / src / third_party / WebKit / LayoutTests / editing / execCommand / merge-text-decoration-with-typing-style.html
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <p>This test ensures WebKit merges text decorations in the typing style and the focused element's style property.</p>
5 <div id="test" contenteditable>hello world</div>
6 <pre><script>
7
8 if (window.testRunner)
9     testRunner.dumpAsText();
10
11 function queryTextDecorations() {
12     var result = '';
13     if (document.queryCommandState('underline'))
14         result += 'underline';
15     if (document.queryCommandState('strikeThrough')) {
16         if (result.length)
17             result += ' ';
18         result += 'strikeThrough';
19     }
20     return result;
21 }
22
23 function runTest(command, inlineStyle) {
24     document.writeln('Test to set ' + command + ' by typing command and add ' + inlineStyle + ' as inline style:');
25     var test = document.getElementById('test');
26     test.style.textDecoration = null;
27     window.getSelection().collapse(test, 0);
28     document.execCommand(command, false, null);
29     test.style.textDecoration = inlineStyle;
30     if (queryTextDecorations() != 'underline strikeThrough')
31         document.writeln('FAIL: got "' + queryTextDecorations() + '" but expected "underline strikeThrough"');
32     else
33         document.writeln('PASS');
34     document.writeln();
35 }
36
37 runTest('strikeThrough', 'underline');
38 window.getSelection().collapse(test, 1);
39 runTest('underline', 'line-through');
40
41 </script></pre>
42 </body>
43 </html>