Backed out changeset 4b3e02945e19 (bug 1363886)
authorSebastian Hengst <archaeopteryx@coole-files.de>
Tue, 25 Jul 2017 10:40:32 +0200
changeset 421839 ec0aed41acb04ffa0c688b048779f877bfdeaa12
parent 421838 9706855e559680ceea9b3ac46bd75ac4937c2cc5
child 421840 47673d5cfce3af5fe8362e42e2b98e3cab453a41
push id1517
push userjlorenzo@mozilla.com
push dateThu, 14 Sep 2017 16:50:54 +0000
treeherdermozilla-release@3b41fd564418 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
bugs1363886
milestone56.0a1
backs out4b3e02945e193e39623f96942172a50865c70bd4
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
Backed out changeset 4b3e02945e19 (bug 1363886)
toolkit/components/extensions/Schemas.jsm
toolkit/components/extensions/test/xpcshell/test_ext_schemas_async.js
--- a/toolkit/components/extensions/Schemas.jsm
+++ b/toolkit/components/extensions/Schemas.jsm
@@ -2103,17 +2103,16 @@ class CallEntry extends Entry {
 FunctionEntry = class FunctionEntry extends CallEntry {
   static parseSchema(schema, path) {
     // When not in DEBUG mode, we just need to know *if* this returns.
     let returns = !!schema.returns;
     if (DEBUG && "returns" in schema) {
       returns = {
         type: Schemas.parseSchema(schema.returns, path, ["optional", "name"]),
         optional: schema.returns.optional || false,
-        name: "result",
       };
     }
 
     return new this(schema, path, schema.name,
                     Schemas.parseSchema(schema, path,
                       ["name", "unsupported", "returns",
                        "permissions",
                        "allowAmbiguousOptionalArguments"]),
@@ -2128,35 +2127,28 @@ FunctionEntry = class FunctionEntry exte
     this.unsupported = unsupported;
     this.returns = returns;
     this.permissions = permissions;
 
     this.isAsync = type.isAsync;
     this.hasAsyncCallback = type.hasAsyncCallback;
   }
 
-  checkValue({type, optional, name}, value, context) {
+  checkValue({type, optional}, value, context) {
     if (optional && value == null) {
       return;
     }
     if (type.reference === "ExtensionPanel" || type.reference === "Port") {
       // TODO: We currently treat objects with functions as SubModuleType,
       // which is just wrong, and a bigger yak.  Skipping for now.
       return;
     }
     const {error} = type.normalize(value, context);
     if (error) {
-      this.throwError(context, `Type error for ${name} value (${error})`);
-    }
-  }
-
-  checkCallback(args, context) {
-    const callback = this.parameters[this.parameters.length - 1];
-    for (const [i, param] of callback.type.parameters.entries()) {
-      this.checkValue(param, args[i], context);
+      this.throwError(context, `Type error for result value (${error})`);
     }
   }
 
   getDescriptor(path, context) {
     let apiImpl = context.getImplementation(path.join("."), this.name);
 
     let stub;
     if (this.isAsync) {
@@ -2168,31 +2160,17 @@ FunctionEntry = class FunctionEntry exte
           callback = actuals.pop();
         }
         if (callback === null && context.isChromeCompat) {
           // 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.
           callback = () => {};
         }
-        if (DEBUG && this.hasAsyncCallback && callback) {
-          let original = callback;
-          callback = (...args) => {
-            this.checkCallback(args, context);
-            original(...args);
-          };
-        }
-        let result = apiImpl.callAsyncFunction(actuals, callback);
-        if (DEBUG && this.hasAsyncCallback && !callback) {
-          return result.then(result => {
-            this.checkCallback([result], context);
-            return result;
-          });
-        }
-        return result;
+        return apiImpl.callAsyncFunction(actuals, callback);
       };
     } else if (!this.returns) {
       stub = (...args) => {
         this.checkDeprecated(context);
         let actuals = this.checkParameters(args, context);
         return apiImpl.callFunctionNoReturn(actuals);
       };
     } else {
--- a/toolkit/components/extensions/test/xpcshell/test_ext_schemas_async.js
+++ b/toolkit/components/extensions/test/xpcshell/test_ext_schemas_async.js
@@ -3,24 +3,16 @@
 Components.utils.import("resource://gre/modules/ExtensionCommon.jsm");
 Components.utils.import("resource://gre/modules/Schemas.jsm");
 
 let {BaseContext, LocalAPIImplementation} = ExtensionCommon;
 
 let schemaJson = [
   {
     namespace: "testnamespace",
-    types: [{
-      id: "Widget",
-      type: "object",
-      properties: {
-        size: {type: "integer"},
-        colour: {type: "string", optional: true},
-      },
-    }],
     functions: [{
       name: "one_required",
       type: "function",
       parameters: [{
         name: "first",
         type: "function",
         parameters: [],
       }],
@@ -47,28 +39,16 @@ let schemaJson = [
       type: "function",
       async: "first",
       parameters: [{
         name: "first",
         type: "function",
         parameters: [],
         optional: true,
       }],
-    }, {
-      name: "async_result",
-      type: "function",
-      async: "callback",
-      parameters: [{
-        name: "callback",
-        type: "function",
-        parameters: [{
-          name: "widget",
-          $ref: "Widget",
-        }],
-      }],
     }],
   },
 ];
 
 const global = this;
 class StubContext extends BaseContext {
   constructor() {
     let fakeExtension = {id: "test@web.extension"};
@@ -162,46 +142,16 @@ add_task(async function testParameterVal
     assertNoThrows("async_optional");
     assertNoThrows("async_optional", null);
     assertNoThrows("async_optional", cb);
     assertThrows("async_optional", cb, null);
     assertThrows("async_optional", cb, cb);
   }
 });
 
-add_task(async function testCheckAsyncResults() {
-  await Schemas.load("data:," + JSON.stringify(schemaJson));
-
-  const complete = generateAPIs({}, {
-    async_result: async () => ({size: 5, colour: "green"}),
-  });
-
-  const optional = generateAPIs({}, {
-    async_result: async () => ({size: 6}),
-  });
-
-  const invalid = generateAPIs({}, {
-    async_result: async () => ({}),
-  });
-
-  deepEqual(await complete.async_result(), {size: 5, colour: "green"});
-
-  deepEqual(await optional.async_result(), {size: 6},
-            "Missing optional properties is allowed");
-
-  if (AppConstants.DEBUG) {
-    await Assert.rejects(invalid.async_result(),
-          `Type error for widget value (Property "size" is required)`,
-          "Should throw for invalid callback argument in DEBUG builds");
-  } else {
-    deepEqual(await invalid.async_result(), {},
-              "Invalid callback argument doesn't throw in release builds");
-  }
-});
-
 add_task(async function testAsyncResults() {
   await Schemas.load("data:," + JSON.stringify(schemaJson));
   function runWithCallback(func) {
     do_print(`Calling testnamespace.${func.name}, expecting callback with result`);
     return new Promise(resolve => {
       let result = "uninitialized value";
       let returnValue = func(reply => {
         result = reply;