Bug 1307852 - Pass ID of calling add-on to native messaging app r=aswan
authorRob Wu <rob@robwu.nl>
Thu, 01 Jun 2017 19:08:02 +0200
changeset 410039 5ae487045afba6c08bd1310ca597bfe888b0693b
parent 410038 2b5bcdc6c93b558108654815201c14774f6218c1
child 410040 975ba5ad9bb040982e81aa6091be9acfdaa019c6
push id7391
push usermtabara@mozilla.com
push dateMon, 12 Jun 2017 13:08:53 +0000
treeherdermozilla-beta@2191d7f87e2e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersaswan
bugs1307852
milestone55.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
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
toolkit/components/extensions/NativeMessaging.jsm
toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js
--- a/toolkit/components/extensions/NativeMessaging.jsm
+++ b/toolkit/components/extensions/NativeMessaging.jsm
@@ -193,17 +193,17 @@ this.NativeApp = class extends EventEmit
           // OS.Path.join() ignores anything before the last absolute path
           // it sees, so if command is already absolute, it remains unchanged
           // here.  If it is relative, we get the proper absolute path here.
           command = OS.Path.join(OS.Path.dirname(hostInfo.path), command);
         }
 
         let subprocessOpts = {
           command: command,
-          arguments: [hostInfo.path],
+          arguments: [hostInfo.path, context.extension.id],
           workdir: OS.Path.dirname(command),
           stderr: "pipe",
         };
         return Subprocess.call(subprocessOpts);
       }).then(proc => {
         this.startupPromise = null;
         this.proc = proc;
         this._startRead();
--- a/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_native_messaging.js
@@ -430,18 +430,19 @@ add_task(async function test_child_proce
       applications: {gecko: {id: ID}},
       permissions: ["nativeMessaging"],
     },
   });
 
   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");
 
   let exitPromise = waitForSubprocessExit();
   await extension.unload();
   await exitPromise;
 });