LayoutTests:
[WebKit-https.git] / LayoutTests / editing / input / text-input-controller.html
1 <html>
2 <head>
3 <style>
4 body { margin: 0; padding: 0 }
5 </style>
6 </head>
7 <body>
8 <div id="test" contenteditable>FAILURE</div>
9 <script type="text/javascript">
10
11     if (window.layoutTestController) {
12         
13         try {
14         
15             layoutTestController.dumpAsText();
16             document.getElementById("test").focus();
17             document.execCommand("SelectAll");
18         
19             textInputController.insertText("to be deleted");
20             textInputController.doCommand("selectAll:");
21             textInputController.doCommand("delete:");
22     
23             textInputController.setMarkedText("Failure", 0, 7);
24             if (textInputController.hasMarkedText() && textInputController.markedRange().toString() == "0,7")
25                 textInputController.setMarkedText("Success", 0, 7);
26             
27             var textAttributes = textInputController.validAttributesForMarkedText();
28             textInputController.unmarkText();
29     
30             textInputController.doCommand("selectAll:");
31             if (textInputController.hasMarkedText() || textInputController.selectedRange().toString() != "0,7") {
32                 textInputController.doCommand("delete:");
33                 textInputController.insertText("Failure");
34             }
35     
36             var charRect = textInputController.firstRectForCharacterRange(0, 1);
37             textInputController.characterIndexForPoint(0, 0); // currently unimplemented
38             textInputController.substringFromRange(1, 1); // currently unimplemented
39             textInputController.conversationIdentifier(); // just an identifier...
40             
41             textAttributes = textAttributes.toString();
42             if (-1 == textAttributes.indexOf("NSUnderline"))
43                 textInputController.insertText("Attribute NSUnderline is missing");
44
45             if (-1 == textAttributes.indexOf("NSUnderlineColor"))
46                 textInputController.insertText("Attribute NSUnderlineColor is missing");
47
48             if (-1 == textAttributes.indexOf("NSMarkedClauseSegment"))
49                 textInputController.insertText("Attribute NSMarkedClauseSegment is missing");
50
51             if (-1 == textAttributes.indexOf("NSTextInputReplacementRangeAttributeName"))
52                 textInputController.insertText("Attribute NSTextInputReplacementRangeAttributeName is missing");
53
54         } catch (ex) {
55             document.write("Exception: " + ex.description);
56         }
57     } else {
58         document.write("(cannot run interactively)");
59     }
60 </script>
61 </body>
62 </html>