From 7802980fa2314f724a7169f95c7f5b27bd6588c5 Mon Sep 17 00:00:00 2001 From: Rob Wu Date: Thu, 1 Jun 2017 19:08:02 +0200 Subject: [PATCH] Bug 1307852 - Pass ID of calling add-on to native messaging app r=aswan This allows native messaging binaries to identify the add-on that invoked the native messaging app, in case more than one add-on is allowed to launch the native messaging app. MozReview-Commit-ID: GgjwfJDbBkW --HG-- extra : rebase_source : b60d33e9f3936f26b8792ef5cd1f9fea304f29ae --- toolkit/components/extensions/NativeMessaging.jsm | 2 +- .../extensions/test/xpcshell/test_ext_native_messaging.js | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/toolkit/components/extensions/NativeMessaging.jsm b/toolkit/components/extensions/NativeMessaging.jsm index 0002e9f0e65b..2c80cb657ba5 100644 --- a/toolkit/components/extensions/NativeMessaging.jsm +++ b/toolkit/components/extensions/NativeMessaging.jsm @@ -198,7 +198,7 @@ this.NativeApp = class extends EventEmitter { let subprocessOpts = { command: command, - arguments: [hostInfo.path], + arguments: [hostInfo.path, context.extension.id], workdir: OS.Path.dirname(command), stderr: "pipe", }; diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js b/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js index 23f7de67c993..f1c6a75f59ac 100644 --- a/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js +++ b/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js @@ -435,8 +435,9 @@ add_task(async function test_child_process() { await extension.startup(); let msg = await extension.awaitMessage("result"); - equal(msg.args.length, 2, "Received one command line argument"); + equal(msg.args.length, 3, "Received two command line arguments"); equal(msg.args[1], getPath("info.json"), "Command line argument is the path to the native host manifest"); + equal(msg.args[2], ID, "Second command line argument is the ID of the calling extension"); equal(msg.cwd.replace(/^\/private\//, "/"), tmpDir.path, "Working directory is the directory containing the native appliation");