Bug 1197346 - Add callFunctionNoReturn (r=kmag)
authorBill McCloskey <billm@mozilla.com>
Tue, 05 Apr 2016 15:21:25 -0700
changeset 332566 7c6d8e1ab93734c711f1e2f8e0080bf7c1def5ef
parent 332565 83e84e280fe7bc7814a0ece41cd02466279f36b6
child 332567 2ce33bb34122b1862be894f8d93708dbd9916881
push id6048
push userkmoir@mozilla.com
push dateMon, 06 Jun 2016 19:02:08 +0000
treeherdermozilla-beta@46d72a56c57d [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerskmag
bugs1197346
milestone48.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 1197346 - Add callFunctionNoReturn (r=kmag)
toolkit/components/extensions/Extension.jsm
toolkit/components/extensions/Schemas.jsm
toolkit/components/extensions/test/xpcshell/test_ext_schemas.js
--- a/toolkit/components/extensions/Extension.jsm
+++ b/toolkit/components/extensions/Extension.jsm
@@ -392,16 +392,20 @@ GlobalManager = {
           get cloneScope() {
             return context.cloneScope;
           },
 
           callFunction(path, name, args) {
             return findPath(path)[name](...args);
           },
 
+          callFunctionNoReturn(path, name, args) {
+            return findPath(path)[name](...args);
+          },
+
           callAsyncFunction(path, name, args, callback) {
             // We pass an empty stub function as a default callback for
             // the `chrome` API, so promise objects are not returned,
             // and lastError values are reported immediately.
             if (callback === null) {
               callback = defaultCallback;
             }
 
--- a/toolkit/components/extensions/Schemas.jsm
+++ b/toolkit/components/extensions/Schemas.jsm
@@ -84,17 +84,18 @@ class Context {
 
     this.path = [];
     this.preprocessors = {
       localize(value, context) {
         return value;
       },
     };
 
-    let props = ["addListener", "callFunction", "callAsyncFunction",
+    let props = ["addListener", "callFunction",
+                 "callFunctionNoReturn", "callAsyncFunction",
                  "hasListener", "removeListener",
                  "getProperty", "setProperty",
                  "checkLoadURL", "logError",
                  "preprocessors"];
     for (let prop of props) {
       if (prop in params) {
         if (prop in this && typeof this[prop] == "object") {
           Object.assign(this[prop], params[prop]);
@@ -997,16 +998,22 @@ class FunctionEntry extends CallEntry {
     let stub;
     if (this.isAsync) {
       stub = (...args) => {
         this.checkDeprecated(context);
         let actuals = this.checkParameters(args, context);
         let callback = actuals.pop();
         return context.callAsyncFunction(path, name, actuals, callback);
       };
+    } else if (!this.returns) {
+      stub = (...args) => {
+        this.checkDeprecated(context);
+        let actuals = this.checkParameters(args, context);
+        return context.callFunctionNoReturn(path, name, actuals);
+      };
     } else {
       stub = (...args) => {
         this.checkDeprecated(context);
         let actuals = this.checkParameters(args, context);
         return context.callFunction(path, name, actuals);
       };
     }
     Cu.exportFunction(stub, dest, {defineAs: name});
--- a/toolkit/components/extensions/test/xpcshell/test_ext_schemas.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_schemas.js
@@ -365,16 +365,21 @@ let wrapper = {
     talliedErrors.push(message);
   },
 
   callFunction(path, name, args) {
     let ns = path.join(".");
     tally("call", ns, name, args);
   },
 
+  callFunctionNoReturn(path, name, args) {
+    let ns = path.join(".");
+    tally("call", ns, name, args);
+  },
+
   shouldInject(path) {
     let ns = path.join(".");
     return ns != "do-not-inject";
   },
 
   getProperty(path, name) {
     let ns = path.join(".");
     tally("get", ns, name);