Bug 596580: fix versioning on mozJSSubScriptLoader. (r=sayrer,brendan)
[mozilla-central.git] / dom / ipc / remote-test.js
blobaf54e363ff440f30c24117bc613b39e00b013bc1
1 dump("Loading remote script!\n");
2 dump(content + "\n");
4 var cpm = Components.classes["@mozilla.org/childprocessmessagemanager;1"]
5                             .getService(Components.interfaces.nsISyncMessageSender);
6 cpm.addMessageListener("cpm-async",
7   function(m) {
8     cpm.sendSyncMessage("ppm-sync");
9     dump(content.document.documentElement);
10     cpm.sendAsyncMessage("ppm-async");
11   });
13 var Cc = Components.classes;
14 var Ci = Components.interfaces;
15 var dshell = content.QueryInterface(Ci.nsIInterfaceRequestor)
16                     .getInterface(Ci.nsIWebNavigation)
17                     .QueryInterface(Ci.nsIDocShellTreeItem)
18                     .rootTreeItem
19                     .QueryInterface(Ci.nsIDocShell);
22 addEventListener("click",
23   function(e) {
24     dump(e.target + "\n");
25     if (e.target instanceof Components.interfaces.nsIDOMHTMLAnchorElement &&
26         dshell == docShell) {
27       var retval = sendSyncMessage("linkclick", { href: e.target.href });
28       dump(uneval(retval[0]) + "\n");
29       // Test here also that both retvals are the same
30       sendAsyncMessage("linkclick-reply-object", uneval(retval[0]) == uneval(retval[1]) ? retval[0] : "");
31     }
32   },
33   true);
35 addMessageListener("chrome-message",
36   function(m) {
37     dump(uneval(m.json) + "\n");
38     sendAsyncMessage("chrome-message-reply", m.json);
39   });
41 addMessageListener("speed-test-start",
42   function(m) {
43     while (sendSyncMessage("speed-test")[0].message != "done");
44   });
46 addMessageListener("async-echo", function(m) {
47   sendAsyncMessage(m.name);
48 });