Backed out changeset ce90a9d52e86 (bug 1331705) for eslint failures a=backout
authorWes Kocher <wkocher@mozilla.com>
Tue, 17 Jan 2017 17:24:09 -0800
changeset 329755 d5479d988affeb3582021817a10d690000616999
parent 329754 e34a208d8ac2af7a013870e52b1370dc40a3d2d5
child 329756 ea3744df8af6f0d3368f83a789cc33e0fea41278
push id36143
push userkwierso@gmail.com
push dateWed, 18 Jan 2017 01:24:14 +0000
treeherderautoland@d5479d988aff [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbackout
bugs1331705
milestone53.0a1
backs outce90a9d52e86c1edc7e194a23eabc1548e4dc104
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 ce90a9d52e86 (bug 1331705) for eslint failures a=backout MozReview-Commit-ID: KaCGMDAwWzz
browser/extensions/shield-recipe-client/lib/RecipeRunner.jsm
browser/extensions/shield-recipe-client/test/browser.ini
browser/extensions/shield-recipe-client/test/browser_RecipeRunner.js
--- a/browser/extensions/shield-recipe-client/lib/RecipeRunner.jsm
+++ b/browser/extensions/shield-recipe-client/lib/RecipeRunner.jsm
@@ -123,57 +123,40 @@ this.RecipeRunner = {
   },
 
   /**
    * Execute a recipe by fetching it action and executing it.
    * @param  {Object} recipe A recipe to execute
    * @promise Resolves when the action has executed
    */
   executeRecipe: Task.async(function* (recipe, extraContext) {
+    const sandboxManager = new SandboxManager();
+    const {sandbox} = sandboxManager;
+
     const action = yield NormandyApi.fetchAction(recipe.action);
     const response = yield fetch(action.implementation_url);
 
     const actionScript = yield response.text();
-    yield this.executeAction(recipe, extraContext, actionScript);
-  }),
+    const prepScript = `
+      var pendingAction = null;
 
-  /**
-   * Execute an action in a sandbox for a specific recipe.
-   * @param  {Object} recipe A recipe to execute
-   * @param  {Object} extraContext Extra data about the user, see NormandyDriver
-   * @param  {String} actionScript The JavaScript for the action to execute.
-   * @promise Resolves or rejects when the action has executed or failed.
-   */
-  executeAction: function(recipe, extraContext, actionScript) {
-    return new Promise((resolve, reject) => {
-      const sandboxManager = new SandboxManager();
-      const {sandbox} = sandboxManager;
-      const prepScript = `
-        function registerAction(name, Action) {
-          let a = new Action(sandboxedDriver, sandboxedRecipe);
-          a.execute()
-            .then(actionFinished)
-            .catch(err => sandboxedDriver.log(err, 'error'));
-        };
-
-        window.registerAction = registerAction;
-        window.setTimeout = sandboxedDriver.setTimeout;
-        window.clearTimeout = sandboxedDriver.clearTimeout;
-      `;
-
-      const driver = new NormandyDriver(sandboxManager, extraContext);
-      sandbox.sandboxedDriver = Cu.cloneInto(driver, sandbox, {cloneFunctions: true});
-      sandbox.sandboxedRecipe = Cu.cloneInto(recipe, sandbox);
-      sandbox.actionFinished = result => {
-        sandboxManager.removeHold("recipeExecution");
-        resolve(result);
-      };
-      sandbox.actionFailed = err => {
-        sandboxManager.removeHold("recipeExecution");
-        reject(err);
+      function registerAction(name, Action) {
+        let a = new Action(sandboxedDriver, sandboxedRecipe);
+        pendingAction = a.execute()
+          .catch(err => sandboxedDriver.log(err, 'error'));
       };
 
-      sandboxManager.addHold("recipeExecution");
-      Cu.evalInSandbox(prepScript, sandbox);
-      Cu.evalInSandbox(actionScript, sandbox);
-    });
-  },
+      window.registerAction = registerAction;
+      window.setTimeout = sandboxedDriver.setTimeout;
+      window.clearTimeout = sandboxedDriver.clearTimeout;
+    `;
+
+    const driver = new NormandyDriver(sandboxManager, extraContext);
+    sandbox.sandboxedDriver = Cu.cloneInto(driver, sandbox, {cloneFunctions: true});
+    sandbox.sandboxedRecipe = Cu.cloneInto(recipe, sandbox);
+
+    Cu.evalInSandbox(prepScript, sandbox);
+    Cu.evalInSandbox(actionScript, sandbox);
+
+    sandboxManager.addHold("recipeExecution");
+    sandbox.pendingAction.then(() => sandboxManager.removeHold("recipeExecution"));
+  }),
 };
--- a/browser/extensions/shield-recipe-client/test/browser.ini
+++ b/browser/extensions/shield-recipe-client/test/browser.ini
@@ -1,9 +1,8 @@
 [browser_driver_uuids.js]
 [browser_env_expressions.js]
 [browser_EventEmitter.js]
 [browser_Storage.js]
 [browser_Heartbeat.js]
 [browser_NormandyApi.js]
   support-files =
     test_server.sjs
-[browser_RecipeRunner.js]
deleted file mode 100644
--- a/browser/extensions/shield-recipe-client/test/browser_RecipeRunner.js
+++ /dev/null
@@ -1,29 +0,0 @@
-"use strict";
-
-const {utils: Cu} = Components;
-Cu.import("resource://shield-recipe-client/lib/RecipeRunner.jsm", this);
-
-add_task(function*() {
-  // Test that RecipeRunner can execute a basic recipe/action.
-  const recipe = {
-    foo: "bar",
-  };
-  const actionScript = `
-    class TestAction {
-      constructor(driver, recipe) {
-        this.recipe = recipe;
-      }
-
-      execute() {
-        return new Promise(resolve => {
-          resolve(this.recipe.foo);
-        });
-      }
-    }
-
-    registerAction('test-action', TestAction);
-  `;
-
-  const result = yield RecipeRunner.executeAction(recipe, {}, actionScript);
-  is(result, "bar", "Recipe executed correctly");
-});