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>
7 console
= document
.getElementById("console");
8 text
= document
.createTextNode(msg
);
9 li
= document
.createElement("li");
10 console
.appendChild(li
);
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.");
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.");
33 log("Failure. Expected: " + expectedHTML
);
35 if (window
.testRunner
) {
36 window
.testRunner
.dumpAsText();
37 document
.body
.innerText
= document
.getElementById("console").innerText
;