summaryrefslogtreecommitdiffstats
path: root/dom/ipc/remote-test.js
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-28 14:29:10 +0000
commit2aa4a82499d4becd2284cdb482213d541b8804dd (patch)
treeb80bf8bf13c3766139fbacc530efd0dd9d54394c /dom/ipc/remote-test.js
parentInitial commit. (diff)
downloadfirefox-2aa4a82499d4becd2284cdb482213d541b8804dd.tar.xz
firefox-2aa4a82499d4becd2284cdb482213d541b8804dd.zip
Adding upstream version 86.0.1.upstream/86.0.1upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'dom/ipc/remote-test.js')
-rw-r--r--dom/ipc/remote-test.js55
1 files changed, 55 insertions, 0 deletions
diff --git a/dom/ipc/remote-test.js b/dom/ipc/remote-test.js
new file mode 100644
index 0000000000..395aef8e47
--- /dev/null
+++ b/dom/ipc/remote-test.js
@@ -0,0 +1,55 @@
+/* This Source Code Form is subject to the terms of the Mozilla Public
+ * License, v. 2.0. If a copy of the MPL was not distributed with this
+ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */
+
+/* eslint-env mozilla/frame-script */
+
+dump("Loading remote script!\n");
+dump(content + "\n");
+
+var cpm = Cc["@mozilla.org/childprocessmessagemanager;1"].getService();
+cpm.addMessageListener("cpm-async", function(m) {
+ cpm.sendSyncMessage("ppm-sync");
+ dump(content.document.documentElement);
+ cpm.sendAsyncMessage("ppm-async");
+});
+
+var dshell = content.docShell.sameTypeRootTreeItem.QueryInterface(
+ Ci.nsIDocShell
+);
+
+addEventListener(
+ "click",
+ function(e) {
+ dump(e.target + "\n");
+ if (
+ ChromeUtils.getClassName(e.target) === "HTMLAnchorElement" &&
+ dshell == docShell
+ ) {
+ var retval = docShell.messageManager.sendSyncMessage("linkclick", {
+ href: e.target.href,
+ });
+ dump(uneval(retval[0]) + "\n");
+ // Test here also that both retvals are the same
+ sendAsyncMessage(
+ "linkclick-reply-object",
+ uneval(retval[0]) == uneval(retval[1]) ? retval[0] : ""
+ );
+ }
+ },
+ true
+);
+
+addMessageListener("chrome-message", function(m) {
+ dump(uneval(m.json) + "\n");
+ sendAsyncMessage("chrome-message-reply", m.json);
+});
+
+addMessageListener("speed-test-start", function(m) {
+ // eslint-disable-next-line no-empty
+ while (sendSyncMessage("speed-test")[0].message != "done") {}
+});
+
+addMessageListener("async-echo", function(m) {
+ sendAsyncMessage(m.name);
+});