summaryrefslogtreecommitdiffstats
path: root/toolkit/components/webextensions/ext-c-runtime.js
diff options
context:
space:
mode:
authorMoonchild <mcwerewolf@wolfbeast.com>2019-03-13 07:49:07 +0100
committerGitHub <noreply@github.com>2019-03-13 07:49:07 +0100
commitbf0413359245579e9509146d42cd5547e35da695 (patch)
tree8218d4f60d9eccacbf42df8cb88094a082d401b4 /toolkit/components/webextensions/ext-c-runtime.js
parent51b821b3fdc5a7eab2369cb6a6680598a6264b08 (diff)
parent709bc24e9110eba12f94cfcb8db00a8338ac4098 (diff)
downloadUXP-bf0413359245579e9509146d42cd5547e35da695.tar
UXP-bf0413359245579e9509146d42cd5547e35da695.tar.gz
UXP-bf0413359245579e9509146d42cd5547e35da695.tar.lz
UXP-bf0413359245579e9509146d42cd5547e35da695.tar.xz
UXP-bf0413359245579e9509146d42cd5547e35da695.zip
Merge pull request #998 from MoonchildProductions/master
Merge master into Sync-weave
Diffstat (limited to 'toolkit/components/webextensions/ext-c-runtime.js')
-rw-r--r--toolkit/components/webextensions/ext-c-runtime.js96
1 files changed, 0 insertions, 96 deletions
diff --git a/toolkit/components/webextensions/ext-c-runtime.js b/toolkit/components/webextensions/ext-c-runtime.js
deleted file mode 100644
index 1dcac35da..000000000
--- a/toolkit/components/webextensions/ext-c-runtime.js
+++ /dev/null
@@ -1,96 +0,0 @@
-"use strict";
-
-function runtimeApiFactory(context) {
- let {extension} = context;
-
- return {
- runtime: {
- onConnect: context.messenger.onConnect("runtime.onConnect"),
-
- onMessage: context.messenger.onMessage("runtime.onMessage"),
-
- onConnectExternal: context.messenger.onConnectExternal("runtime.onConnectExternal"),
-
- onMessageExternal: context.messenger.onMessageExternal("runtime.onMessageExternal"),
-
- connect: function(extensionId, connectInfo) {
- let name = connectInfo !== null && connectInfo.name || "";
- extensionId = extensionId || extension.id;
- let recipient = {extensionId};
-
- return context.messenger.connect(context.messageManager, name, recipient);
- },
-
- sendMessage: function(...args) {
- let options; // eslint-disable-line no-unused-vars
- let extensionId, message, responseCallback;
- if (typeof args[args.length - 1] == "function") {
- responseCallback = args.pop();
- }
- if (!args.length) {
- return Promise.reject({message: "runtime.sendMessage's message argument is missing"});
- } else if (args.length == 1) {
- message = args[0];
- } else if (args.length == 2) {
- if (typeof args[0] == "string" && args[0]) {
- [extensionId, message] = args;
- } else {
- [message, options] = args;
- }
- } else if (args.length == 3) {
- [extensionId, message, options] = args;
- } else if (args.length == 4 && !responseCallback) {
- return Promise.reject({message: "runtime.sendMessage's last argument is not a function"});
- } else {
- return Promise.reject({message: "runtime.sendMessage received too many arguments"});
- }
-
- if (extensionId != null && typeof extensionId != "string") {
- return Promise.reject({message: "runtime.sendMessage's extensionId argument is invalid"});
- }
- if (options != null && typeof options != "object") {
- return Promise.reject({message: "runtime.sendMessage's options argument is invalid"});
- }
-
- extensionId = extensionId || extension.id;
- let recipient = {extensionId};
-
- return context.messenger.sendMessage(context.messageManager, message, recipient, responseCallback);
- },
-
- connectNative(application) {
- let recipient = {
- childId: context.childManager.id,
- toNativeApp: application,
- };
-
- return context.messenger.connectNative(context.messageManager, "", recipient);
- },
-
- sendNativeMessage(application, message) {
- let recipient = {
- childId: context.childManager.id,
- toNativeApp: application,
- };
- return context.messenger.sendNativeMessage(context.messageManager, message, recipient);
- },
-
- get lastError() {
- return context.lastError;
- },
-
- getManifest() {
- return Cu.cloneInto(extension.manifest, context.cloneScope);
- },
-
- id: extension.id,
-
- getURL: function(url) {
- return extension.baseURI.resolve(url);
- },
- },
- };
-}
-
-extensions.registerSchemaAPI("runtime", "addon_child", runtimeApiFactory);
-extensions.registerSchemaAPI("runtime", "content_child", runtimeApiFactory);