Merge Chromium + Blink git repositories
[chromium-blink-merge.git] / third_party / WebKit / LayoutTests / editing / execCommand / 5685604-1.html
blob68179edeb14ebad45470fc69c468af7d15c4e9e0
1 <body>
2 <p>This tests to make sure that execCommand("styleWithCSS", ...) is supported and turns on the use of legacy tags in leu of CSS-styled spans for formatting changes.</p>
3 <div contenteditable="true" id="div">The second and last words in this sentence should be bold.</div>
4 <ul id="console"></ul>
5 <script>
6 function log(msg) {
7 console = document.getElementById("console");
8 text = document.createTextNode(msg);
9 li = document.createElement("li");
10 console.appendChild(li);
11 li.appendChild(text);
13 r = document.createRange();
14 div = document.getElementById("div");
15 text = div.firstChild;
16 window.getSelection().setBaseAndExtent(text, 4, text, 10);
17 document.execCommand("bold", false, "");
18 window.getSelection().setBaseAndExtent(text, text.length - 5, text, text.length - 1);
20 if (document.queryCommandSupported("styleWithCSS"))
21 log("Success. execCommand(\"styleWithCSS\", ...) is supported.");
22 else
23 log("Failure. execCommand(\"styleWithCSS\", ...) is not supported.");
25 document.execCommand("styleWithCSS", false, true);
26 document.execCommand("bold", false, "");
28 expectedHTML = "The <b>second</b> and last words in this sentence should be <span style=\"font-weight: bold;\">bold</span>.";
30 if (div.innerHTML == expectedHTML)
31 log("Success. A legacy formatting tag was used for styling by default, and execCommand(\"styleWithCSS\", ..., true) activated the use of CSS styling.");
32 else
33 log("Failure. Expected: " + expectedHTML);
35 if (window.testRunner) {
36 window.testRunner.dumpAsText();
37 document.body.innerText = document.getElementById("console").innerText;
39 </script>
40 </body>