| <html> |
| <head> |
| <style> |
| body { margin: 10; padding: 0 } |
| </style> |
| </head> |
| <body contenteditable>12<b>3<i>4</i></b> |
| <script type="text/javascript"> |
| |
| var console_messages = document.createElement("ol"); |
| |
| function log(message) |
| { |
| var item = document.createElement("li"); |
| item.appendChild(document.createTextNode(String(message).replace(/0x[0-9a-fA-F]{8}/g, "0xXXXXXXXX"))); |
| console_messages.appendChild(item); |
| } |
| |
| if (window.layoutTestController) { |
| |
| try { |
| |
| layoutTestController.dumpAsText(); |
| |
| log("Testing styled text (12<b>3<i>456</i></b>)"); |
| window.getSelection().setPosition(document.body, 4); |
| textInputController.setMarkedText("56", 0, 1); |
| |
| log("(0, 0): " + textInputController.attributedSubstringFromRange(0, 0).string()); |
| log("(0, 2): " + textInputController.attributedSubstringFromRange(0, 2).string()); |
| log("(0, 3): " + textInputController.attributedSubstringFromRange(0, 3).string()); |
| log("(0, 6): " + textInputController.attributedSubstringFromRange(0, 6).string()); |
| log("(0, 7): " + textInputController.attributedSubstringFromRange(0, 7).string()); |
| log("(0, 100): " + textInputController.attributedSubstringFromRange(0, 100).string()); |
| log("(5, 1): " + textInputController.attributedSubstringFromRange(5, 1).string()); |
| log("(5, 2): " + textInputController.attributedSubstringFromRange(5, 2).string()); |
| log("(100, 0): " + textInputController.attributedSubstringFromRange(100, 0)); // should be undefined |
| log("(100, 100): " + textInputController.attributedSubstringFromRange(100, 100)); // should be undefined |
| |
| log("\nTesting proper space runs (1._2.__3.___4_5)"); |
| document.body.innerHTML = "1 2 3 4 5"; |
| window.getSelection().setPosition(document.body, 0); |
| |
| log("total length: " + textInputController.attributedSubstringFromRange(0, 100).length()); |
| log("one space: \"" + textInputController.attributedSubstringFromRange(1, 1).string() + "\""); |
| log("two spaces: \"" + textInputController.attributedSubstringFromRange(1, 2).string() + "\""); |
| log("three spaces: \"" + textInputController.attributedSubstringFromRange(4, 3).string() + "\""); |
| log("four spaces: \"" + textInputController.attributedSubstringFromRange(8, 4).string() + "\""); |
| |
| log("\nTesting space-only runs (1..2...3....4.5)"); |
| document.body.innerHTML = "1 2 3 4 5"; |
| window.getSelection().setPosition(document.body, 0); |
| |
| log("total length: " + textInputController.attributedSubstringFromRange(0, 100).length()); |
| log("(0, 100): " + textInputController.attributedSubstringFromRange(0, 100).string()); |
| |
| document.body.innerHTML = ""; |
| |
| } catch (ex) { |
| log("Exception: " + ex.description); |
| } |
| |
| var console = document.createElement("pre"); |
| console.appendChild(console_messages); |
| document.body.appendChild(console); |
| |
| } else { |
| document.write("This testcase is buggy: 9337. (cannot run interactively)"); |
| } |
| </script> |
| </body> |
| </html> |