Bug 1454813: Part 1b - Stop automatically exposing Task singleton to browser tests. r?florian draft
authorKris Maglione <maglione.k@gmail.com>
Wed, 18 Apr 2018 11:45:13 -0700
changeset 784527 23c55b2bcaaed9ce16c5b96ccca0d9832a428d16
parent 784526 1506d372ea07e5569b3d2454b5c3b06c6fdf6765
child 784528 700dc00411c136a06ee8f1789d5799423101e29f
push id106959
push usermaglione.k@gmail.com
push dateWed, 18 Apr 2018 19:09:46 +0000
reviewersflorian
bugs1454813
milestone61.0a1
Bug 1454813: Part 1b - Stop automatically exposing Task singleton to browser tests. r?florian Now that Task.jsm is deprecated and add_task no longer excepts generators, it doesn't make sense to continue making this automatically available in test scopes. MozReview-Commit-ID: AckO5nnFngG
testing/mochitest/browser-test.js
--- a/testing/mochitest/browser-test.js
+++ b/testing/mochitest/browser-test.js
@@ -1,16 +1,15 @@
 /* -*- js-indent-level: 2; tab-width: 2; indent-tabs-mode: nil -*- */
 // Test timeout (seconds)
 var gTimeoutSeconds = 45;
 var gConfig;
 var gSaveInstrumentationData = null;
 
 ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm");
-ChromeUtils.import("resource://gre/modules/Task.jsm");
 ChromeUtils.import("resource://gre/modules/AppConstants.jsm");
 ChromeUtils.import("resource://gre/modules/Services.jsm");
 
 ChromeUtils.defineModuleGetter(this, "ContentSearch",
   "resource:///modules/ContentSearch.jsm");
 
 const SIMPLETEST_OVERRIDES =
   ["ok", "is", "isnot", "todo", "todo_is", "todo_isnot", "info", "expectAssertions", "requestCompleteLog"];
@@ -404,21 +403,19 @@ function Tester(aTests, structuredLogger
   };
   extensionUtilsScope.SimpleTest = this.SimpleTest;
   this._scriptLoader.loadSubScript("chrome://mochikit/content/tests/SimpleTest/ExtensionTestUtils.js", extensionUtilsScope);
   this.ExtensionTestUtils = extensionUtilsScope.ExtensionTestUtils;
 
   this.SimpleTest.harnessParameters = gConfig;
 
   this.MemoryStats = simpleTestScope.MemoryStats;
-  this.Task = Task;
   this.ContentTask = ChromeUtils.import("resource://testing-common/ContentTask.jsm", null).ContentTask;
   this.BrowserTestUtils = ChromeUtils.import("resource://testing-common/BrowserTestUtils.jsm", null).BrowserTestUtils;
   this.TestUtils = ChromeUtils.import("resource://testing-common/TestUtils.jsm", null).TestUtils;
-  this.Task.Debugging.maintainStack = true;
   this.Promise = ChromeUtils.import("resource://gre/modules/Promise.jsm", null).Promise;
   this.PromiseTestUtils = ChromeUtils.import("resource://testing-common/PromiseTestUtils.jsm", null).PromiseTestUtils;
   this.Assert = ChromeUtils.import("resource://testing-common/Assert.jsm", null).Assert;
 
   this.PromiseTestUtils.init();
 
   this.SimpleTestOriginal = {};
   SIMPLETEST_OVERRIDES.forEach(m => {
@@ -451,17 +448,16 @@ function Tester(aTests, structuredLogger
         loadSubScriptWithOptions: this._scriptLoader.loadSubScriptWithOptions.bind(this._scriptLoader),
       },
     },
   });
 }
 Tester.prototype = {
   EventUtils: {},
   SimpleTest: {},
-  Task: null,
   ContentTask: null,
   ExtensionTestUtils: null,
   Assert: null,
 
   repeat: 0,
   runUntilFailure: false,
   checker: null,
   currentTestIndex: -1,
@@ -985,17 +981,16 @@ Tester.prototype = {
     let currentScope = this.currentTest.scope = new testScope(this, this.currentTest, this.currentTest.expected);
     let currentTest = this.currentTest;
 
     // Import utils in the test scope.
     let {scope} = this.currentTest;
     scope.EventUtils = this.currentTest.usesUnsafeCPOWs ? this.cpowEventUtils : this.EventUtils;
     scope.SimpleTest = this.SimpleTest;
     scope.gTestPath = this.currentTest.path;
-    scope.Task = this.Task;
     scope.ContentTask = this.ContentTask;
     scope.BrowserTestUtils = this.BrowserTestUtils;
     scope.TestUtils = this.TestUtils;
     scope.ExtensionTestUtils = this.ExtensionTestUtils;
     // Pass a custom report function for mochitest style reporting.
     scope.Assert = new this.Assert(function(err, message, stack) {
       currentTest.addResult(new testResult(err ? {
         name: err.message,
@@ -1251,17 +1246,17 @@ function testResult({ name, pass, todo, 
       let frames = [];
       for (let frame = stack; frame; frame = frame.caller) {
         frames.push(frame.filename + ":" + frame.name + ":" + frame.lineNumber);
       }
       normalized = frames.join("\n");
     } else {
       normalized = "" + stack;
     }
-    this.msg += Task.Debugging.generateReadableStack(normalized, "    ");
+    this.msg += normalized;
   }
 
   if (gConfig.debugOnFailure) {
     // You've hit this line because you requested to break into the
     // debugger upon a testcase failure on your test run.
     debugger;
   }
 }