OLD | NEW |
1 <body> | 1 <body> |
2 <p>This tests to make sure that execCommand("styleWithCSS", ...) is supported an
d turns on the use of legacy tags in leu of CSS-styled spans for formatting chan
ges.</p> | 2 <p>This tests to make sure that execCommand("styleWithCSS", ...) is supported an
d turns on the use of legacy tags in leu of CSS-styled spans for formatting chan
ges.</p> |
3 <div contenteditable="true" id="div">The second and last words in this sentence
should be bold.</div> | 3 <div contenteditable="true" id="div">The second and last words in this sentence
should be bold.</div> |
4 <ul id="console"></ul> | 4 <ul id="console"></ul> |
5 <script> | 5 <script> |
6 function log(msg) { | 6 function log(msg) { |
7 console = document.getElementById("console"); | 7 console = document.getElementById("console"); |
8 text = document.createTextNode(msg); | 8 text = document.createTextNode(msg); |
9 li = document.createElement("li"); | 9 li = document.createElement("li"); |
10 console.appendChild(li); | 10 console.appendChild(li); |
11 li.appendChild(text); | 11 li.appendChild(text); |
12 } | 12 } |
13 r = document.createRange(); | 13 r = document.createRange(); |
14 div = document.getElementById("div"); | 14 div = document.getElementById("div"); |
15 text = div.firstChild; | 15 text = div.firstChild; |
16 window.getSelection().setBaseAndExtent(text, 4, text, 10); | 16 window.getSelection().setBaseAndExtent(text, 4, text, 10); |
17 document.execCommand("bold", false, ""); | 17 document.execCommand("bold", false, ""); |
18 window.getSelection().setBaseAndExtent(text, text.length - 5, text, text.length
- 1); | 18 window.getSelection().setBaseAndExtent(text, text.length - 5, text, text.length
- 1); |
19 | 19 |
20 if (document.queryCommandSupported("styleWithCSS")) | 20 if (document.queryCommandSupported("styleWithCSS")) |
21 log("Success. execCommand(\"styleWithCSS\", ...) is supported."); | 21 log("Success. execCommand(\"styleWithCSS\", ...) is supported."); |
22 else | 22 else |
23 log("Failure. execCommand(\"styleWithCSS\", ...) is not supported."); | 23 log("Failure. execCommand(\"styleWithCSS\", ...) is not supported."); |
24 | 24 |
25 document.execCommand("styleWithCSS", false, true); | 25 document.execCommand("styleWithCSS", false, true); |
26 document.execCommand("bold", false, ""); | 26 document.execCommand("bold", false, ""); |
27 | 27 |
28 expectedHTML = "The <b>second</b> and last words in this sentence should be <spa
n style=\"font-weight: bold;\">bold</span>."; | 28 expectedHTML = "The <b>second</b> and last words in this sentence should be <spa
n class=\"Apple-style-span\" style=\"font-weight: bold;\">bold</span>."; |
29 | 29 |
30 if (div.innerHTML == expectedHTML) | 30 if (div.innerHTML == expectedHTML) |
31 log("Success. A legacy formatting tag was used for styling by default, and e
xecCommand(\"styleWithCSS\", ..., true) activated the use of CSS styling."); | 31 log("Success. A legacy formatting tag was used for styling by default, and e
xecCommand(\"styleWithCSS\", ..., true) activated the use of CSS styling."); |
32 else | 32 else |
33 log("Failure. Expected: " + expectedHTML); | 33 log("Failure. Expected: " + expectedHTML); |
34 | 34 |
35 if (window.layoutTestController) { | 35 if (window.layoutTestController) { |
36 window.layoutTestController.dumpAsText(); | 36 window.layoutTestController.dumpAsText(); |
37 document.body.innerText = document.getElementById("console").innerText; | 37 document.body.innerText = document.getElementById("console").innerText; |
38 } | 38 } |
39 </script> | 39 </script> |
40 </body> | 40 </body> |
OLD | NEW |