From f1f4e879483c66285f1ea10c38238349384021b4 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Thu, 19 Apr 2018 14:52:47 -0700 Subject: [PATCH] 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 accepts generators, it doesn't make sense to continue making this automatically available in test scopes. MozReview-Commit-ID: AckO5nnFngG --HG-- extra : rebase_source : 826b7cce67d9ab000d6385663c543bc72eef174b --- dom/security/test/cors/head.js | 10 +++++----- .../test/general/browser_test_FTP_console_warning.js | 10 +++++----- testing/mochitest/browser-test.js | 8 +------- 3 files changed, 11 insertions(+), 17 deletions(-) diff --git a/dom/security/test/cors/head.js b/dom/security/test/cors/head.js index d5d3967c2137..c32bc538d97d 100644 --- a/dom/security/test/cors/head.js +++ b/dom/security/test/cors/head.js @@ -19,12 +19,12 @@ let promise = require("promise"); * @param {String} hostType Optional. The type of toolbox host to be used. * @return {Promise} Resolves with the toolbox, when it has been opened. */ -var openToolboxForTab = Task.async(function* (tab, toolId, hostType) { +var openToolboxForTab = async function(tab, toolId, hostType) { info("Opening the toolbox"); let toolbox; let target = TargetFactory.forTab(tab); - yield target.makeRemote(); + await target.makeRemote(); // Check if the toolbox is already loaded. toolbox = gDevTools.getToolbox(target); @@ -36,15 +36,15 @@ var openToolboxForTab = Task.async(function* (tab, toolId, hostType) { } // If not, load it now. - toolbox = yield gDevTools.showToolbox(target, toolId, hostType); + toolbox = await gDevTools.showToolbox(target, toolId, hostType); // Make sure that the toolbox frame is focused. - yield new Promise(resolve => waitForFocus(resolve, toolbox.win)); + await new Promise(resolve => waitForFocus(resolve, toolbox.win)); info("Toolbox opened and focused"); return toolbox; -}); +}; /** * Find multiple messages in the output. diff --git a/dom/security/test/general/browser_test_FTP_console_warning.js b/dom/security/test/general/browser_test_FTP_console_warning.js index a9d8048c9715..17e6646fe825 100644 --- a/dom/security/test/general/browser_test_FTP_console_warning.js +++ b/dom/security/test/general/browser_test_FTP_console_warning.js @@ -21,12 +21,12 @@ let promise = require("promise"); * @param {String} hostType Optional. The type of toolbox host to be used. * @return {Promise} Resolves with the toolbox, when it has been opened. */ -var openToolboxForTab = Task.async(function* (tab, toolId, hostType) { +var openToolboxForTab = async function(tab, toolId, hostType) { info("Opening the toolbox"); let toolbox; let target = TargetFactory.forTab(tab); - yield target.makeRemote(); + await target.makeRemote(); // Check if the toolbox is already loaded. toolbox = gDevTools.getToolbox(target); @@ -38,15 +38,15 @@ var openToolboxForTab = Task.async(function* (tab, toolId, hostType) { } // If not, load it now. - toolbox = yield gDevTools.showToolbox(target, toolId, hostType); + toolbox = await gDevTools.showToolbox(target, toolId, hostType); // Make sure that the toolbox frame is focused. - yield new Promise(resolve => waitForFocus(resolve, toolbox.win)); + await new Promise(resolve => waitForFocus(resolve, toolbox.win)); info("Toolbox opened and focused"); return toolbox; -}); +}; function console_observer(subject, topic, data) { diff --git a/testing/mochitest/browser-test.js b/testing/mochitest/browser-test.js index 27b991a89f04..836b72677c9a 100644 --- a/testing/mochitest/browser-test.js +++ b/testing/mochitest/browser-test.js @@ -5,7 +5,6 @@ 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"); @@ -409,11 +408,9 @@ function Tester(aTests, structuredLogger, aCallback) { 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; @@ -456,7 +453,6 @@ function Tester(aTests, structuredLogger, aCallback) { Tester.prototype = { EventUtils: {}, SimpleTest: {}, - Task: null, ContentTask: null, ExtensionTestUtils: null, Assert: null, @@ -990,7 +986,6 @@ Tester.prototype = { 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; @@ -1256,7 +1251,7 @@ function testResult({ name, pass, todo, ex, stack, allowFailure }) { } else { normalized = "" + stack; } - this.msg += Task.Debugging.generateReadableStack(normalized, " "); + this.msg += normalized; } if (gConfig.debugOnFailure) { @@ -1424,7 +1419,6 @@ testScope.prototype = { EventUtils: {}, SimpleTest: {}, - Task: null, ContentTask: null, BrowserTestUtils: null, TestUtils: null,