Fix for http://bugzilla.opendarwin.org/show_bug.cgi?id=7223
[WebKit-https.git] / LayoutTests / fast / AppleScript / 001.html
1 <html>
2 <head>
3 <title>do JavaScript - converting to AppleScript types</title>
4 </head>
5 <body>
6 An automated test for basic AppleScript "do JavaScript" support.
7 <script type="text/javascript">
8
9     var console_messages = document.createElement("ol");
10     
11     function log(message)
12     {
13         var item = document.createElement("li");
14         item.appendChild(document.createTextNode(message));
15         console_messages.appendChild(item);
16     }
17     if (window.layoutTestController) {
18         
19         try {
20         
21             layoutTestController.dumpAsText();
22             document.execCommand("SelectAll");
23             
24             log(appleScriptController.doJavaScript("2*2;"));
25             log(appleScriptController.doJavaScript("new Number(2*2);"));
26             log(appleScriptController.doJavaScript("2/3;"));
27             log(appleScriptController.doJavaScript("new Number(2/3);"));
28             log(appleScriptController.doJavaScript("2/0;"));
29             log(appleScriptController.doJavaScript("new Number(-2/0);"));
30             log(appleScriptController.doJavaScript("1!=1"));
31             log(appleScriptController.doJavaScript("new Boolean"));
32             log(appleScriptController.doJavaScript("'a string'"));
33             log(appleScriptController.doJavaScript("new String('a string')"));
34             log(appleScriptController.doJavaScript("window.getSelection()"));
35             log(appleScriptController.doJavaScript("window.getSelection() + \"\""));
36             log(appleScriptController.doJavaScript("document"));
37             log(appleScriptController.doJavaScript("document.title"));
38             log(appleScriptController.doJavaScript("document.lalala"));
39             log(appleScriptController.doJavaScript("document.lalala()")); // ideally, should pass the error to AppleScript
40             log(appleScriptController.doJavaScript("function Polygon() {this.edges = 8;} new Polygon;"));
41             
42         } catch (ex) {
43             log("Exception: " + ex.description);
44         }
45
46         var console = document.createElement("p");
47         console.appendChild(console_messages);
48         document.body.appendChild(console);
49         
50     } else {
51         document.write("(cannot run interactively)");
52     }
53 </script>
54 </body>
55 </html>