Bug 1229519: Fix toolkit/modules to pass eslint checks. r=mak
authorDave Townsend <dtownsend@oxymoronical.com>
Thu, 03 Dec 2015 09:58:56 -0800
changeset 309656 312c5fa54cb9e371dded556b1168b70dcf0d3bcc
parent 309655 e5c4090f0c4d16a2ffe76f842baa50130bde0e87
child 309657 acb7ba1c7eb9b105584ba3bba0991e29ab329df6
push id5513
push userraliiev@mozilla.com
push dateMon, 25 Jan 2016 13:55:34 +0000
treeherdermozilla-beta@5ee97dd05b5c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersmak
bugs1229519
milestone45.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 1229519: Fix toolkit/modules to pass eslint checks. r=mak
toolkit/modules/CharsetMenu.jsm
toolkit/modules/DeferredTask.jsm
toolkit/modules/FileUtils.jsm
toolkit/modules/GMPInstallManager.jsm
toolkit/modules/Log.jsm
toolkit/modules/Promise-backend.js
toolkit/modules/PromiseUtils.jsm
toolkit/modules/PropertyListUtils.jsm
toolkit/modules/RemotePageManager.jsm
toolkit/modules/Services.jsm
toolkit/modules/SpatialNavigation.jsm
toolkit/modules/Sqlite.jsm
toolkit/modules/Task.jsm
toolkit/modules/ZipUtils.jsm
toolkit/modules/addons/MatchPattern.jsm
toolkit/modules/addons/WebRequestContent.js
toolkit/modules/tests/xpcshell/test_DeferredTask.js
toolkit/modules/tests/xpcshell/test_Log.js
toolkit/modules/tests/xpcshell/test_NewTabUtils.js
toolkit/modules/tests/xpcshell/test_PromiseUtils.js
toolkit/modules/tests/xpcshell/test_ZipUtils.js
toolkit/modules/tests/xpcshell/test_session_recorder.js
toolkit/modules/tests/xpcshell/test_sqlite.js
toolkit/modules/tests/xpcshell/test_sqlite_shutdown.js
--- a/toolkit/modules/CharsetMenu.jsm
+++ b/toolkit/modules/CharsetMenu.jsm
@@ -181,22 +181,22 @@ var CharsetMenu = {
       label: this._getDetectorLabel(detectorName),
       accesskey: this._getDetectorAccesskey(detectorName),
       name: "detector",
       value: nodeId
     }));
   },
 
   getCharsetInfo: function(charsets, sort=true) {
-    let list = [{
+    let list = Array.from(charsets, charset => ({
       label: this._getCharsetLabel(charset),
       accesskey: this._getCharsetAccessKey(charset),
       name: "charset",
       value: charset
-    } for (charset of charsets)];
+    }));
 
     if (sort) {
       list.sort(CharsetComparator);
     }
     return list;
   },
 
   _getDetectorLabel: function(detector) {
--- a/toolkit/modules/DeferredTask.jsm
+++ b/toolkit/modules/DeferredTask.jsm
@@ -272,17 +272,17 @@ this.DeferredTask.prototype = {
     // timer callback, to prevent race conditions and to ensure that all the
     // methods behave consistently even if called from inside the task.  This
     // means that the assignment of "this._runningPromise" must complete before
     // the task gets a chance to start.
     this._timer = null;
     this._armed = false;
     this._runningPromise = runningDeferred.promise;
 
-    runningDeferred.resolve(Task.spawn(function () {
+    runningDeferred.resolve(Task.spawn(function* () {
       // Execute the provided function asynchronously.
       yield Task.spawn(this._taskFn).then(null, Cu.reportError);
 
       // Now that the task has finished, we check the state of the object to
       // determine if we should restart the task again.
       if (this._armed) {
         if (!this._finalized) {
           this._startTimer();
--- a/toolkit/modules/FileUtils.jsm
+++ b/toolkit/modules/FileUtils.jsm
@@ -63,17 +63,20 @@ this.FileUtils = {
     var dir = gDirService.get(key, Ci.nsIFile);
     for (var i = 0; i < pathArray.length; ++i) {
       dir.append(pathArray[i]);
     }
 
     if (shouldCreate) {
       try {
         dir.create(Ci.nsIFile.DIRECTORY_TYPE, this.PERMS_DIRECTORY);
-      } catch (ex if ex.result == Cr.NS_ERROR_FILE_ALREADY_EXISTS) {
+      } catch (ex) {
+        if (ex.result != Cr.NS_ERROR_FILE_ALREADY_EXISTS) {
+          throw ex;
+        }
         // Ignore the exception due to a directory that already exists.
       }
     }
 
     if (!followLinks)
       dir.followLinks = false;
     return dir;
   },
--- a/toolkit/modules/GMPInstallManager.jsm
+++ b/toolkit/modules/GMPInstallManager.jsm
@@ -104,17 +104,17 @@ GMPInstallManager.prototype = {
       }
     }
 
     ProductAddonChecker.getProductAddonList(url, allowNonBuiltIn, certs).then((addons) => {
       if (!addons) {
         this._deferred.resolve([]);
       }
       else {
-        this._deferred.resolve([for (a of addons) new GMPAddon(a)]);
+        this._deferred.resolve(addons.map(a => new GMPAddon(a)));
       }
       delete this._deferred;
     }, (ex) => {
       this._deferred.reject(ex);
       delete this._deferred;
     });
 
     return this._deferred.promise;
--- a/toolkit/modules/Log.jsm
+++ b/toolkit/modules/Log.jsm
@@ -862,17 +862,17 @@ function FileAppender(path, formatter) {
   // This is a promise exposed for testing/debugging the logger itself.
   this._lastWritePromise = null;
 }
 
 FileAppender.prototype = {
   __proto__: Appender.prototype,
 
   _openFile: function () {
-    return Task.spawn(function _openFile() {
+    return Task.spawn(function* _openFile() {
       try {
         this._file = yield OS.File.open(this._path,
                                         {truncate: true});
       } catch (err) {
         if (err instanceof OS.File.Error) {
           this._file = null;
         } else {
           throw err;
--- a/toolkit/modules/Promise-backend.js
+++ b/toolkit/modules/Promise-backend.js
@@ -231,18 +231,17 @@ var PendingErrors = {
   },
 
   /**
    * Mark all pending errors are uncaught, notify the observers.
    */
   flush: function() {
     // Since we are going to modify the map while walking it,
     // let's copying the keys first.
-    let keys = [key for (key of this._map.keys())];
-    for (let key of keys) {
+    for (let key of Array.from(this._map.keys())) {
       this.report(key);
     }
   },
 
   /**
    * Stop tracking an error, as this error has been caught,
    * eventually.
    */
--- a/toolkit/modules/PromiseUtils.jsm
+++ b/toolkit/modules/PromiseUtils.jsm
@@ -45,9 +45,9 @@ function Deferred() {
 
   /* A newly created Pomise object.
    * Initially in pending state.
    */
   this.promise = new Promise((resolve, reject) => {
     this.resolve = resolve;
     this.reject = reject;
   });
-}
\ No newline at end of file
+}
--- a/toolkit/modules/PropertyListUtils.jsm
+++ b/toolkit/modules/PropertyListUtils.jsm
@@ -687,17 +687,17 @@ XMLPropertyListReader.prototype = {
         return number;
       }
       case "date":
         return new Date(aDOMElt.textContent);
       case "data":
         // Strip spaces and new lines.
         let base64str = aDOMElt.textContent.replace(/\s*/g, "");
         let decoded = atob(base64str);
-        return new Uint8Array([decoded.charCodeAt(i) for (i in decoded)]);
+        return new Uint8Array(Array.from(decoded, c => c.charCodeAt(0)));
       case "dict":
         return this._wrapDictionary(aDOMElt);
       case "array":
         return this._wrapArray(aDOMElt);
       default:
         throw new Error("Unexpected tagname");
     }
   },
--- a/toolkit/modules/RemotePageManager.jsm
+++ b/toolkit/modules/RemotePageManager.jsm
@@ -460,17 +460,17 @@ var RemotePageManagerInternal = {
 
     // Notify all the frame scripts of the removed registration
     Services.ppmm.broadcastAsyncMessage("RemotePage:Unregister", { urls: [url] });
     this.pages.delete(url);
   },
 
   // A listener is requesting the list of currently registered urls
   initListener: function({ target: messageManager }) {
-    messageManager.sendAsyncMessage("RemotePage:Register", { urls: [u for (u of this.pages.keys())] })
+    messageManager.sendAsyncMessage("RemotePage:Register", { urls: Array.from(this.pages.keys()) })
   },
 
   // A remote page has been created and a port is ready in the content side
   initPort: function({ target: browser, data: { url, portID } }) {
     let callback = this.pages.get(url);
     if (!callback) {
       Cu.reportError("Unexpected remote page load: " + url);
       return;
--- a/toolkit/modules/Services.jsm
+++ b/toolkit/modules/Services.jsm
@@ -19,19 +19,21 @@ XPCOMUtils.defineLazyGetter(Services, "p
            .QueryInterface(Ci.nsIPrefBranch);
 });
 
 XPCOMUtils.defineLazyGetter(Services, "appinfo", function () {
   let appinfo = Cc["@mozilla.org/xre/app-info;1"]
                   .getService(Ci.nsIXULRuntime);
   try {
     appinfo.QueryInterface(Ci.nsIXULAppInfo);
-  } catch (ex if ex instanceof Components.Exception &&
-                 ex.result == Cr.NS_NOINTERFACE) {
+  } catch (ex) {
     // Not all applications implement nsIXULAppInfo (e.g. xpcshell doesn't).
+    if (!(ex instanceof Components.Exception) || ex.result != Cr.NS_NOINTERFACE) {
+      throw ex;
+    }
   }
   return appinfo;
 });
 
 XPCOMUtils.defineLazyGetter(Services, "dirsvc", function () {
   return Cc["@mozilla.org/file/directory_service;1"]
            .getService(Ci.nsIDirectoryService)
            .QueryInterface(Ci.nsIProperties);
--- a/toolkit/modules/SpatialNavigation.jsm
+++ b/toolkit/modules/SpatialNavigation.jsm
@@ -599,9 +599,9 @@ var PrefObserver = {
         } catch(e) {
           this.keyCodeReturn = Ci.nsIDOMKeyEvent.DOM_VK_RETURN;
         }
         break;
     }
   }
 };
 
-PrefObserver.register();
\ No newline at end of file
+PrefObserver.register();
--- a/toolkit/modules/Sqlite.jsm
+++ b/toolkit/modules/Sqlite.jsm
@@ -764,23 +764,25 @@ ConnectionData.prototype = Object.freeze
             rows.push(row);
             continue;
           }
 
           handledRow = true;
 
           try {
             onRow(row);
-          } catch (e if e instanceof StopIteration) {
-            userCancelled = true;
-            pending.cancel();
-            break;
-          } catch (ex) {
+          } catch (e) {
+            if (e instanceof StopIteration) {
+              userCancelled = true;
+              pending.cancel();
+              break;
+            }
+
             self._log.warn("Exception when calling onRow callback: " +
-                           CommonUtils.exceptionStr(ex));
+                           CommonUtils.exceptionStr(e));
           }
         }
       },
 
       handleError: function (error) {
         self._log.info("Error when executing SQL (" +
                        error.result + "): " + error.message);
         errors.push(error);
@@ -806,17 +808,17 @@ ConnectionData.prototype = Object.freeze
               deferred.resolve(result);
             } else {
               deferred.reject(new Error("Statement was cancelled."));
             }
 
             break;
 
           case Ci.mozIStorageStatementCallback.REASON_ERROR:
-            let error = new Error("Error(s) encountered during statement execution: " + [error.message for (error of errors)].join(", "));
+            let error = new Error("Error(s) encountered during statement execution: " + errors.map(e => e.message).join(", "));
             error.errors = errors;
             deferred.reject(error);
             break;
 
           default:
             deferred.reject(new Error("Unknown completion reason code: " +
                                       reason));
             break;
--- a/toolkit/modules/Task.jsm
+++ b/toolkit/modules/Task.jsm
@@ -232,19 +232,20 @@ function createAsyncFunction(aTask) {
           "You should either invoke the async function first " +
           "or use 'Task.spawn' instead of 'Task.async' to start " +
           "the Task and return its promise.");
       }
 
       try {
         // Let's call into the function ourselves.
         result = aTask.apply(this, arguments);
-      } catch (ex if ex instanceof Task.Result) {
-        return Promise.resolve(ex.value);
       } catch (ex) {
+        if (ex instanceof Task.Result) {
+          return Promise.resolve(ex.value);
+        }
         return Promise.reject(ex);
       }
     }
 
     if (isGenerator(result)) {
       // This is an iterator resulting from calling a generator function.
       return new TaskImpl(result).deferred.promise;
     }
@@ -325,26 +326,28 @@ TaskImpl.prototype = {
           // The generator function failed with an uncaught exception.
           this._handleException(ex);
         }
       } else {
         try {
           let yielded = aSendResolved ? this._iterator.send(aSendValue)
                                       : this._iterator.throw(aSendValue);
           this._handleResultValue(yielded);
-        } catch (ex if ex instanceof Task.Result) {
-          // The generator function threw the special exception that allows it to
-          // return a specific value on resolution.
-          this.deferred.resolve(ex.value);
-        } catch (ex if ex instanceof StopIteration) {
-          // The generator function terminated with no specific result.
-          this.deferred.resolve(undefined);
         } catch (ex) {
-          // The generator function failed with an uncaught exception.
-          this._handleException(ex);
+          if (ex instanceof Task.Result) {
+            // The generator function threw the special exception that allows it to
+            // return a specific value on resolution.
+            this.deferred.resolve(ex.value);
+          } else if (ex instanceof StopIteration) {
+            // The generator function terminated with no specific result.
+            this.deferred.resolve(undefined);
+          } else {
+            // The generator function failed with an uncaught exception.
+            this._handleException(ex);
+          }
         }
       }
     } finally {
       //
       // At this stage, the Task may have finished executing, or have
       // walked through a `yield` or passed control to a sub-Task.
       // Regardless, if we still own `gCurrentTask`, reset it. If we
       // have not finished execution of this Task, re-entering `_run`
--- a/toolkit/modules/ZipUtils.jsm
+++ b/toolkit/modules/ZipUtils.jsm
@@ -74,21 +74,21 @@ function saveStreamAsync(aPath, aStream,
       let count = Math.min(source.available(), EXTRACTION_BUFFER);
       let data = new Uint8Array(count);
       source.readArrayBuffer(count, data.buffer);
 
       aFile.write(data, { bytes: count }).then(function() {
         input.asyncWait(readData, 0, 0, Services.tm.currentThread);
       }, readFailed);
     }
-    catch (e if e.result == Cr.NS_BASE_STREAM_CLOSED) {
-      deferred.resolve(aFile.close());
-    }
     catch (e) {
-      readFailed(e);
+      if (e.result == Cr.NS_BASE_STREAM_CLOSED)
+        deferred.resolve(aFile.close());
+      else
+        readFailed(e);
     }
   }
 
   input.asyncWait(readData, 0, 0, Services.tm.currentThread);
 
   return deferred.promise;
 }
 
@@ -110,17 +110,17 @@ this.ZipUtils = {
 
     try {
       zipReader.open(aZipFile);
     }
     catch (e) {
       return Promise.reject(e);
     }
 
-    return Task.spawn(function() {
+    return Task.spawn(function* () {
       // Get all of the entries in the zip and sort them so we create directories
       // before files
       let entries = zipReader.findEntries(null);
       let names = [];
       while (entries.hasMore())
         names.push(entries.getNext());
       names.sort();
 
--- a/toolkit/modules/addons/MatchPattern.jsm
+++ b/toolkit/modules/addons/MatchPattern.jsm
@@ -94,17 +94,17 @@ SingleMatchPattern.prototype = {
 this.MatchPattern = function(pat)
 {
   this.pat = pat;
   if (!pat) {
     this.matchers = [];
   } else if (pat instanceof String || typeof(pat) == "string") {
     this.matchers = [new SingleMatchPattern(pat)];
   } else {
-    this.matchers = [for (p of pat) new SingleMatchPattern(p)];
+    this.matchers = pat.map(p => new SingleMatchPattern(p));
   }
 }
 
 MatchPattern.prototype = {
   // |uri| should be an nsIURI.
   matches(uri) {
     for (let matcher of this.matchers) {
       if (matcher.matches(uri)) {
--- a/toolkit/modules/addons/WebRequestContent.js
+++ b/toolkit/modules/addons/WebRequestContent.js
@@ -135,17 +135,21 @@ var ContentPolicy = {
       }
 
       let ir = window.QueryInterface(Ci.nsIInterfaceRequestor)
                      .getInterface(Ci.nsIDocShell)
                      .QueryInterface(Ci.nsIInterfaceRequestor);
       try {
         // If e10s is disabled, this throws NS_NOINTERFACE for closed tabs.
         mm = ir.getInterface(Ci.nsIContentFrameMessageManager);
-      } catch (e if e.result == Cr.NS_NOINTERFACE) {}
+      } catch (e) {
+        if (e.result != Cr.NS_NOINTERFACE) {
+          throw e;
+        }
+      }
     }
 
     let data = {ids,
                 url: contentLocation.spec,
                 type: WebRequestCommon.typeForPolicyType(policyType),
                 windowId,
                 parentWindowId};
 
--- a/toolkit/modules/tests/xpcshell/test_DeferredTask.js
+++ b/toolkit/modules/tests/xpcshell/test_DeferredTask.js
@@ -151,17 +151,17 @@ add_test(function test_arm_recursive()
  * the task is finished before restarting the delay.
  */
 add_test(function test_arm_async()
 {
   let finishedExecution = false;
   let finishedExecutionAgain = false;
 
   // Create a task that will run later.
-  let deferredTask = new DeferredTask(function () {
+  let deferredTask = new DeferredTask(function* () {
     yield promiseTimeout(4*T);
     if (!finishedExecution) {
       finishedExecution = true;
     } else if (!finishedExecutionAgain) {
       finishedExecutionAgain = true;
     }
   }, 2*T);
   deferredTask.arm();
@@ -242,17 +242,17 @@ add_test(function test_disarm_delay_rest
 /**
  * Checks that calling "disarm" while an asynchronous task is running does not
  * prevent the task to finish.
  */
 add_test(function test_disarm_async()
 {
   let finishedExecution = false;
 
-  let deferredTask = new DeferredTask(function () {
+  let deferredTask = new DeferredTask(function* () {
     deferredTask.arm();
     yield promiseTimeout(2*T);
     finishedExecution = true;
   }, 1*T);
   deferredTask.arm();
 
   do_timeout(2*T, function () {
     do_check_true(deferredTask.isRunning);
@@ -272,17 +272,17 @@ add_test(function test_disarm_async()
 /**
  * Checks that calling "arm" immediately followed by "disarm" while an
  * asynchronous task is running does not cause it to run again.
  */
 add_test(function test_disarm_immediate_async()
 {
   let executed = false;
 
-  let deferredTask = new DeferredTask(function () {
+  let deferredTask = new DeferredTask(function* () {
     do_check_false(executed);
     executed = true;
     yield promiseTimeout(2*T);
   }, 1*T);
   deferredTask.arm();
 
   do_timeout(2*T, function () {
     do_check_true(deferredTask.isRunning);
@@ -348,17 +348,17 @@ add_test(function test_finalize()
  * finish in case it is already running.
  */
 add_test(function test_finalize_executes_entirely()
 {
   let executed = false;
   let executedAgain = false;
   let timePassed = false;
 
-  let deferredTask = new DeferredTask(function () {
+  let deferredTask = new DeferredTask(function* () {
     // The first time, we arm the timer again and set up the finalization.
     if (!executed) {
       deferredTask.arm();
       do_check_true(deferredTask.isArmed);
       do_check_true(deferredTask.isRunning);
 
       deferredTask.finalize().then(function () {
         // When we reach this point, the task must be finished.
--- a/toolkit/modules/tests/xpcshell/test_Log.js
+++ b/toolkit/modules/tests/xpcshell/test_Log.js
@@ -228,17 +228,17 @@ add_task(function test_StorageStreamAppe
 
 function fileContents(path) {
   let decoder = new TextDecoder();
   return OS.File.read(path).then(array => {
     return decoder.decode(array);
   });
 }
 
-add_task(function test_FileAppender() {
+add_task(function* test_FileAppender() {
   // This directory does not exist yet
   let dir = OS.Path.join(do_get_profile().path, "test_Log");
   do_check_false(yield OS.File.exists(dir));
   let path = OS.Path.join(dir, "test_FileAppender");
   let appender = new Log.FileAppender(path, testFormatter);
   let logger = Log.repository.getLogger("test.FileAppender");
   logger.addAppender(appender);
 
@@ -282,17 +282,17 @@ add_task(function test_FileAppender() {
   do_check_eq((yield fileContents(path)),
               "test.FileAppender\tDEBUG\t1\n" +
               "test.FileAppender\tINFO\t2\n" +
               "test.FileAppender\tINFO\t3\n" +
               "test.FileAppender\tINFO\t4\n" +
               "test.FileAppender\tINFO\t5\n");
 });
 
-add_task(function test_BoundedFileAppender() {
+add_task(function* test_BoundedFileAppender() {
   let dir = OS.Path.join(do_get_profile().path, "test_Log");
 
   if (!(yield OS.File.exists(dir))) {
     yield OS.File.makeDir(dir);
   }
 
   let path = OS.Path.join(dir, "test_BoundedFileAppender");
   // This appender will hold about two lines at a time.
@@ -333,17 +333,17 @@ add_task(function test_BoundedFileAppend
               "test.BoundedFileAppender\tINFO\tTHREE\n" +
               "test.BoundedFileAppender\tINFO\tFOUR\n");
 
 });
 
 /*
  * Test parameter formatting.
  */
-add_task(function log_message_with_params() {
+add_task(function* log_message_with_params() {
   let formatter = new Log.BasicFormatter();
 
   function formatMessage(text, params) {
     let full = formatter.format(new Log.LogMessage("test.logger", Log.Level.Warn, text, params));
     return full.split("\t")[3];
   }
 
   // Strings are substituted directly.
@@ -482,17 +482,17 @@ add_task(function log_message_with_param
 });
 
 /*
  * If we call a log function with a non-string object in place of the text
  * argument, and no parameters, treat that the same as logging empty text
  * with the object argument as parameters. This makes the log useful when the
  * caller does "catch(err) {logger.error(err)}"
  */
-add_task(function test_log_err_only() {
+add_task(function* test_log_err_only() {
   let log = Log.repository.getLogger("error.only");
   let testFormatter = { format: msg => msg };
   let appender = new MockAppender(testFormatter);
   log.addAppender(appender);
 
   /*
    * Check that log.error(err) is treated the same as
    * log.error(null, err) by the logMessage constructor; the formatMessage()
@@ -508,17 +508,17 @@ add_task(function test_log_err_only() {
     do_check_eq(msg.message, null);
     do_check_eq(msg.params, e);
   }
 });
 
 /*
  * Test logStructured() messages through basic formatter.
  */
-add_task(function test_structured_basic() {
+add_task(function* test_structured_basic() {
   let log = Log.repository.getLogger("test.logger");
   let appender = new MockAppender(new Log.BasicFormatter());
 
   log.level = Log.Level.Info;
   appender.level = Log.Level.Info;
   log.addAppender(appender);
 
   // A structured entry with no _message is treated the same as log./level/(null, params)
@@ -533,17 +533,17 @@ add_task(function test_structured_basic(
   do_check_eq(appender.messages.length, 2);
   do_print(appender.messages[1]);
   do_check_true(appender.messages[1].includes('Structured sub structure'));
 });
 
 /*
  * Test that all the basic logger methods pass the message and params through to the appender.
  */
-add_task(function log_message_with_params() {
+add_task(function* log_message_with_params() {
   let log = Log.repository.getLogger("error.logger");
   let testFormatter = { format: msg => msg };
   let appender = new MockAppender(testFormatter);
   log.addAppender(appender);
 
   let testParams = {a:1, b:2};
   log.fatal("Test fatal", testParams);
   log.error("Test error", testParams);
@@ -557,17 +557,17 @@ add_task(function log_message_with_param
     do_check_true(msg.params === testParams);
     do_check_true(msg.message.startsWith("Test "));
   }
 });
 
 /*
  * Check that we format JS Errors reasonably.
  */
-add_task(function format_errors() {
+add_task(function* format_errors() {
   let pFormat = new Log.ParameterFormatter();
 
   // Test that subclasses of Error are recognized as errors.
   err = new ReferenceError("Ref Error", "ERROR_FILE", 28);
   str = pFormat.format(err);
   do_check_true(str.includes("ReferenceError"));
   do_check_true(str.includes("ERROR_FILE:28"));
   do_check_true(str.includes("Ref Error"));
--- a/toolkit/modules/tests/xpcshell/test_NewTabUtils.js
+++ b/toolkit/modules/tests/xpcshell/test_NewTabUtils.js
@@ -11,17 +11,17 @@ Cu.import("resource://gre/modules/Servic
 
 const PREF_NEWTAB_ENHANCED = "browser.newtabpage.enhanced";
 
 function run_test() {
   Services.prefs.setBoolPref(PREF_NEWTAB_ENHANCED, true);
   run_next_test();
 }
 
-add_task(function validCacheMidPopulation() {
+add_task(function* validCacheMidPopulation() {
   let expectedLinks = makeLinks(0, 3, 1);
 
   let provider = new TestProvider(done => done(expectedLinks));
   provider.maxNumLinks = expectedLinks.length;
 
   NewTabUtils.initWithoutProviders();
   NewTabUtils.links.addProvider(provider);
   let promise = new Promise(resolve => NewTabUtils.links.populateCache(resolve));
@@ -34,17 +34,17 @@ add_task(function validCacheMidPopulatio
   yield promise;
 
   // Once the cache is populated, we get the expected results
   do_check_true(NewTabUtils.isTopSiteGivenProvider("example1.com", provider));
   do_check_links(NewTabUtils.getProviderLinks(provider), expectedLinks);
   NewTabUtils.links.removeProvider(provider);
 });
 
-add_task(function notifyLinkDelete() {
+add_task(function* notifyLinkDelete() {
   let expectedLinks = makeLinks(0, 3, 1);
 
   let provider = new TestProvider(done => done(expectedLinks));
   provider.maxNumLinks = expectedLinks.length;
 
   NewTabUtils.initWithoutProviders();
   NewTabUtils.links.addProvider(provider);
   yield new Promise(resolve => NewTabUtils.links.populateCache(resolve));
@@ -69,17 +69,17 @@ add_task(function notifyLinkDelete() {
   do_check_eq(links.siteMap.size, 2);
   do_check_true(links.siteMap.has(NewTabUtils.extractSite(expectedLinks[0].url)));
   do_check_true(links.siteMap.has(NewTabUtils.extractSite(expectedLinks[1].url)));
   do_check_false(links.siteMap.has(NewTabUtils.extractSite(removedLink.url)));
 
   NewTabUtils.links.removeProvider(provider);
 });
 
-add_task(function populatePromise() {
+add_task(function* populatePromise() {
   let count = 0;
   let expectedLinks = makeLinks(0, 10, 2);
 
   let getLinksFcn = Task.async(function* (callback) {
     //Should not be calling getLinksFcn twice
     count++;
     do_check_eq(count, 1);
     yield Promise.resolve();
@@ -93,17 +93,17 @@ add_task(function populatePromise() {
 
   NewTabUtils.links.populateProviderCache(provider, () => {});
   NewTabUtils.links.populateProviderCache(provider, () => {
     do_check_links(NewTabUtils.links.getLinks(), expectedLinks);
     NewTabUtils.links.removeProvider(provider);
   });
 });
 
-add_task(function isTopSiteGivenProvider() {
+add_task(function* isTopSiteGivenProvider() {
   let expectedLinks = makeLinks(0, 10, 2);
 
   // The lowest 2 frecencies have the same base domain.
   expectedLinks[expectedLinks.length - 2].url = expectedLinks[expectedLinks.length - 1].url + "Test";
 
   let provider = new TestProvider(done => done(expectedLinks));
   provider.maxNumLinks = expectedLinks.length;
 
@@ -132,17 +132,17 @@ add_task(function isTopSiteGivenProvider
 
   // Our count reached 0 for the example2.com domain so it's no longer a frecent site.
   do_check_eq(NewTabUtils.isTopSiteGivenProvider("example5.com", provider), true);
   do_check_eq(NewTabUtils.isTopSiteGivenProvider("example2.com", provider), false);
 
   NewTabUtils.links.removeProvider(provider);
 });
 
-add_task(function multipleProviders() {
+add_task(function* multipleProviders() {
   // Make each provider generate NewTabUtils.links.maxNumLinks links to check
   // that no more than maxNumLinks are actually returned in the merged list.
   let evenLinks = makeLinks(0, 2 * NewTabUtils.links.maxNumLinks, 2);
   let evenProvider = new TestProvider(done => done(evenLinks));
   let oddLinks = makeLinks(0, 2 * NewTabUtils.links.maxNumLinks - 1, 2);
   let oddProvider = new TestProvider(done => done(oddLinks));
 
   NewTabUtils.initWithoutProviders();
@@ -157,17 +157,17 @@ add_task(function multipleProviders() {
                                 1);
   do_check_eq(links.length, NewTabUtils.links.maxNumLinks);
   do_check_links(links, expectedLinks);
 
   NewTabUtils.links.removeProvider(evenProvider);
   NewTabUtils.links.removeProvider(oddProvider);
 });
 
-add_task(function changeLinks() {
+add_task(function* changeLinks() {
   let expectedLinks = makeLinks(0, 20, 2);
   let provider = new TestProvider(done => done(expectedLinks));
 
   NewTabUtils.initWithoutProviders();
   NewTabUtils.links.addProvider(provider);
 
   yield new Promise(resolve => NewTabUtils.links.populateCache(resolve));
 
@@ -215,17 +215,17 @@ add_task(function changeLinks() {
   yield NewTabUtils.links._providers.get(provider).populatePromise;
 
   // NewTabUtils.links will now repopulate its cache
   do_check_links(NewTabUtils.links.getLinks(), expectedLinks);
 
   NewTabUtils.links.removeProvider(provider);
 });
 
-add_task(function oneProviderAlreadyCached() {
+add_task(function* oneProviderAlreadyCached() {
   let links1 = makeLinks(0, 10, 1);
   let provider1 = new TestProvider(done => done(links1));
 
   NewTabUtils.initWithoutProviders();
   NewTabUtils.links.addProvider(provider1);
 
   yield new Promise(resolve => NewTabUtils.links.populateCache(resolve));
   do_check_links(NewTabUtils.links.getLinks(), links1);
@@ -236,17 +236,17 @@ add_task(function oneProviderAlreadyCach
 
   yield new Promise(resolve => NewTabUtils.links.populateCache(resolve));
   do_check_links(NewTabUtils.links.getLinks(), links2.concat(links1));
 
   NewTabUtils.links.removeProvider(provider1);
   NewTabUtils.links.removeProvider(provider2);
 });
 
-add_task(function newLowRankedLink() {
+add_task(function* newLowRankedLink() {
   // Init a provider with 10 links and make its maximum number also 10.
   let links = makeLinks(0, 10, 1);
   let provider = new TestProvider(done => done(links));
   provider.maxNumLinks = links.length;
 
   NewTabUtils.initWithoutProviders();
   NewTabUtils.links.addProvider(provider);
 
@@ -263,17 +263,17 @@ add_task(function newLowRankedLink() {
     url: newLink.url,
     title: "a new title",
   });
   do_check_links(NewTabUtils.links.getLinks(), links);
 
   NewTabUtils.links.removeProvider(provider);
 });
 
-add_task(function extractSite() {
+add_task(function* extractSite() {
   // All these should extract to the same site
   [ "mozilla.org",
     "m.mozilla.org",
     "mobile.mozilla.org",
     "www.mozilla.org",
     "www3.mozilla.org",
   ].forEach(host => {
     let url = "http://" + host;
--- a/toolkit/modules/tests/xpcshell/test_PromiseUtils.js
+++ b/toolkit/modules/tests/xpcshell/test_PromiseUtils.js
@@ -97,9 +97,9 @@ add_task(function* test_reject_resolved_
 
 /* Test for the case when a rejected Promise is
  * passed to the reject method */
 add_task(function* test_reject_resolved_promise() {
   let def = PromiseUtils.defer();
   let p = new Promise((resolve, reject) => reject(new Error("This on rejects")));
   def.reject(p);
   yield Assert.rejects(def.promise, Promise, "Rejection with a rejected promise uses the passed promise itself as the reason of rejection");
-});
\ No newline at end of file
+});
--- a/toolkit/modules/tests/xpcshell/test_ZipUtils.js
+++ b/toolkit/modules/tests/xpcshell/test_ZipUtils.js
@@ -55,17 +55,17 @@ add_task(function test_extractFiles() {
   } catch(e) {
     do_throw("Failed to extract synchronously!");
   }
 
   ensureExtracted(target);
   ensureHasSymlink(target);
 });
 
-add_task(function test_extractFilesAsync() {
+add_task(function* test_extractFilesAsync() {
   let target = dir.clone();
   target.append("test_extractFilesAsync");
   target.create(Components.interfaces.nsIFile.DIRECTORY_TYPE,
     FileUtils.PERMS_DIRECTORY);
 
   yield ZipUtils.extractFilesAsync(archive, target).then(
     function success() {
       do_print("SUCCESS");
--- a/toolkit/modules/tests/xpcshell/test_session_recorder.js
+++ b/toolkit/modules/tests/xpcshell/test_session_recorder.js
@@ -48,17 +48,17 @@ function getRecorder(name, start, offset
 add_test(function test_basic() {
   let recorder = getRecorder("basic");
   recorder.onStartup();
   recorder.onShutdown();
 
   run_next_test();
 });
 
-add_task(function test_current_properties() {
+add_task(function* test_current_properties() {
   let now = new Date();
   let recorder = getRecorder("current_properties", now);
   yield sleep(25);
   recorder.onStartup();
 
   do_check_eq(recorder.startDate.getTime(), now.getTime());
   do_check_eq(recorder.activeTicks, 0);
   do_check_true(recorder.fineTotalTime > 0);
@@ -73,17 +73,17 @@ add_task(function test_current_propertie
   recorder.updateTotalTime();
   do_check_eq(recorder.totalTime, 1);
 
   recorder.onShutdown();
 });
 
 // If startup info isn't present yet, we should install a timer and get
 // it eventually.
-add_task(function test_current_availability() {
+add_task(function* test_current_availability() {
   let recorder = new SessionRecorder("testing.current_availability.");
   let now = new Date();
 
   Object.defineProperty(recorder, "_getStartupInfo", {
     value: function _getStartupInfo() {
       return {
         process: now,
         main: new Date(now.getTime() + 500),
@@ -151,17 +151,17 @@ add_test(function test_timer_clear_on_sh
   do_check_neq(recorder._timer, null);
 
   recorder.onShutdown();
   do_check_null(recorder._timer);
 
   run_next_test();
 });
 
-add_task(function test_previous_clean() {
+add_task(function* test_previous_clean() {
   let now = new Date();
   let recorder = getRecorder("previous_clean", now);
   yield sleep(25);
   recorder.onStartup();
 
   recorder.incrementActiveTicks();
   recorder.incrementActiveTicks();
 
@@ -191,17 +191,17 @@ add_task(function test_previous_clean() 
   do_check_eq(session.firstPaint, 1000);
   do_check_eq(session.sessionRestored, 1500);
   do_check_eq(session.totalTime, total);
   do_check_eq(session.activeTicks, 2);
 
   recorder2.onShutdown();
 });
 
-add_task(function test_previous_abort() {
+add_task(function* test_previous_abort() {
   let now = new Date();
   let recorder = getRecorder("previous_abort", now);
   yield sleep(25);
   recorder.onStartup();
   recorder.incrementActiveTicks();
   yield sleep(25);
   let total = recorder.totalTime;
   yield sleep(25);
@@ -217,17 +217,17 @@ add_task(function test_previous_abort() 
   let session = sessions[0];
   do_check_false(session.clean);
   do_check_eq(session.totalTime, total);
 
   recorder.onShutdown();
   recorder2.onShutdown();
 });
 
-add_task(function test_multiple_sessions() {
+add_task(function* test_multiple_sessions() {
   for (let i = 0; i < 10; i++) {
     let recorder = getRecorder("multiple_sessions");
     yield sleep(25);
     recorder.onStartup();
     for (let j = 0; j < i; j++) {
       recorder.incrementActiveTicks();
     }
     yield sleep(25);
@@ -259,17 +259,17 @@ add_task(function test_multiple_sessions
   recorder.pruneOldSessions(threshold);
   sessions = recorder.getPreviousSessions();
   do_check_eq(Object.keys(sessions).length, 4);
   do_check_eq(recorder._prunedIndex, 5);
 
   recorder.onShutdown();
 });
 
-add_task(function test_record_activity() {
+add_task(function* test_record_activity() {
   let recorder = getRecorder("record_activity");
   yield sleep(25);
   recorder.onStartup();
   let total = recorder.totalTime;
   yield sleep(25);
 
   for (let i = 0; i < 3; i++) {
     Services.obs.notifyObservers(null, "user-interaction-active", null);
--- a/toolkit/modules/tests/xpcshell/test_sqlite.js
+++ b/toolkit/modules/tests/xpcshell/test_sqlite.js
@@ -121,17 +121,19 @@ add_task(function* test_schema_version()
   do_check_eq(version, 14);
 
   for (let v of [0.5, "foobar", NaN]) {
     let success;
     try {
       yield db.setSchemaVersion(v);
       do_print("Schema version " + v + " should have been rejected");
       success = false;
-    } catch (ex if ex.message.startsWith("Schema version must be an integer.")) {
+    } catch (ex) {
+      if (!ex.message.startsWith("Schema version must be an integer."))
+        throw ex;
       success = true;
     }
     do_check_true(success);
 
     version = yield db.getSchemaVersion();
     do_check_eq(version, 14);
   }
 
@@ -913,17 +915,21 @@ add_task(function* test_cloneStorageConn
   yield clone.close();
 });
 
 // Test Sqlite.cloneStorageConnection invalid argument.
 add_task(function* test_cloneStorageConnection() {
   try {
     let clone = yield Sqlite.cloneStorageConnection({ connection: null });
     do_throw(new Error("Should throw on invalid connection"));
-  } catch (ex if ex.name == "TypeError") {}
+  } catch (ex) {
+    if (ex.name != "TypeError") {
+      throw ex;
+    }
+  }
 });
 
 // Test clone() method.
 add_task(function* test_clone() {
   let c = yield getDummyDatabase("clone");
 
   let clone = yield c.clone();
   // Just check that it works.
--- a/toolkit/modules/tests/xpcshell/test_sqlite_shutdown.js
+++ b/toolkit/modules/tests/xpcshell/test_sqlite_shutdown.js
@@ -20,31 +20,31 @@ function getConnection(dbName, extraOpti
   let options = {path: path};
   for (let [k, v] in Iterator(extraOptions)) {
     options[k] = v;
   }
 
   return Sqlite.openConnection(options);
 }
 
-function getDummyDatabase(name, extraOptions={}) {
+function* getDummyDatabase(name, extraOptions={}) {
   const TABLES = {
     dirs: "id INTEGER PRIMARY KEY AUTOINCREMENT, path TEXT",
     files: "id INTEGER PRIMARY KEY AUTOINCREMENT, dir_id INTEGER, path TEXT",
   };
 
   let c = yield getConnection(name, extraOptions);
   c._initialStatementCount = 0;
 
   for (let [k, v] in Iterator(TABLES)) {
     yield c.execute("CREATE TABLE " + k + "(" + v + ")");
     c._initialStatementCount++;
   }
 
-  throw new Task.Result(c);
+  return c;
 }
 
 function sleep(ms) {
   let deferred = Promise.defer();
 
   let timer = Cc["@mozilla.org/timer;1"]
                 .createInstance(Ci.nsITimer);