diff --git a/devtools/shared/async-utils.js b/devtools/shared/async-utils.js index f4d96f46b553..c67899f884a3 100644 --- a/devtools/shared/async-utils.js +++ b/devtools/shared/async-utils.js @@ -13,8 +13,6 @@ * See Task documentation at https://developer.mozilla.org/en-US/docs/Mozilla/JavaScript_code_modules/Task.jsm. */ -var {Task} = require("devtools/shared/task"); - /** * Adds an event listener to the given element, and then removes its event * listener once the event is called, returning the event object as a promise. diff --git a/devtools/shared/client/connection-manager.js b/devtools/shared/client/connection-manager.js index 9ea7c4af1e5b..fa5291d37feb 100644 --- a/devtools/shared/client/connection-manager.js +++ b/devtools/shared/client/connection-manager.js @@ -11,7 +11,6 @@ const EventEmitter = require("devtools/shared/old-event-emitter"); const { DebuggerServer } = require("devtools/server/main"); const { DebuggerClient } = require("devtools/shared/client/debugger-client"); const Services = require("Services"); -const { Task } = require("devtools/shared/task"); const REMOTE_TIMEOUT = "devtools.debugger.remote-timeout"; @@ -297,7 +296,7 @@ Connection.prototype = { this._setStatus(Connection.Status.DESTROYED); }, - _getTransport: Task.async(function* () { + async _getTransport() { if (this._customTransport) { return this._customTransport; } @@ -305,9 +304,9 @@ Connection.prototype = { return DebuggerServer.connectPipe(); } let settings = this.socketSettings; - let transport = yield DebuggerClient.socketConnect(settings); + let transport = await DebuggerClient.socketConnect(settings); return transport; - }), + }, _clientConnect: function () { this._getTransport().then(transport => { diff --git a/devtools/shared/css/parsing-utils.js b/devtools/shared/css/parsing-utils.js index 11b7447f851d..05c403dbd135 100644 --- a/devtools/shared/css/parsing-utils.js +++ b/devtools/shared/css/parsing-utils.js @@ -19,7 +19,6 @@ loader.lazyRequireGetter(this, "CSS_ANGLEUNIT", const promise = require("promise"); const {getCSSLexer} = require("devtools/shared/css/lexer"); -const {Task} = require("devtools/shared/task"); const SELECTOR_ATTRIBUTE = exports.SELECTOR_ATTRIBUTE = 1; const SELECTOR_ELEMENT = exports.SELECTOR_ELEMENT = 2; @@ -902,7 +901,7 @@ RuleRewriter.prototype = { * @return {Promise} a promise that is resolved when the edit has * completed */ - internalCreateProperty: Task.async(function* (index, name, value, priority, enabled) { + async internalCreateProperty(index, name, value, priority, enabled) { this.completeInitialization(index); let newIndentation = ""; if (this.hasNewLine) { @@ -912,7 +911,7 @@ RuleRewriter.prototype = { } else if (this.defaultIndentation) { newIndentation = this.defaultIndentation; } else { - newIndentation = yield this.getDefaultIndentation(); + newIndentation = await this.getDefaultIndentation(); } } @@ -954,7 +953,7 @@ RuleRewriter.prototype = { // index. this.completeCopying(this.decl.offsets[0]); } - }), + }, /** * Create a new declaration. diff --git a/devtools/shared/discovery/tests/unit/test_discovery.js b/devtools/shared/discovery/tests/unit/test_discovery.js index 0a712a572dc8..58758141eafe 100644 --- a/devtools/shared/discovery/tests/unit/test_discovery.js +++ b/devtools/shared/discovery/tests/unit/test_discovery.js @@ -74,7 +74,7 @@ Object.defineProperty(discovery.device, "name", { } }); -add_task(function* () { +add_task(async function () { // At startup, no remote devices are known deepEqual(discovery.getRemoteDevicesWithService("devtools"), []); deepEqual(discovery.getRemoteDevicesWithService("penguins"), []); @@ -91,14 +91,14 @@ add_task(function* () { deepEqual(discovery.getRemoteDevicesWithService("devtools"), []); deepEqual(discovery.getRemoteDevicesWithService("penguins"), []); - yield scanForChange("devtools", "added"); + await scanForChange("devtools", "added"); // Now we see the new service deepEqual(discovery.getRemoteDevicesWithService("devtools"), ["test-device"]); deepEqual(discovery.getRemoteDevicesWithService("penguins"), []); discovery.addService("penguins", { tux: true }); - yield scanForChange("penguins", "added"); + await scanForChange("penguins", "added"); deepEqual(discovery.getRemoteDevicesWithService("devtools"), ["test-device"]); deepEqual(discovery.getRemoteDevicesWithService("penguins"), ["test-device"]); @@ -110,20 +110,20 @@ add_task(function* () { { tux: true, host: "localhost" }); discovery.removeService("devtools"); - yield scanForChange("devtools", "removed"); + await scanForChange("devtools", "removed"); discovery.addService("penguins", { tux: false }); - yield scanForChange("penguins", "updated"); + await scanForChange("penguins", "updated"); // Scan again, but nothing should be removed - yield scanForNoChange("penguins", "removed"); + await scanForNoChange("penguins", "removed"); // Split the scanning side from the service side to simulate the machine with // the service becoming unreachable gTestTransports = {}; discovery.removeService("penguins"); - yield scanForChange("penguins", "removed"); + await scanForChange("penguins", "removed"); }); function scanForChange(service, changeType) { diff --git a/devtools/shared/fronts/animation.js b/devtools/shared/fronts/animation.js index f0fcc5512dcb..42b6100290d8 100644 --- a/devtools/shared/fronts/animation.js +++ b/devtools/shared/fronts/animation.js @@ -13,7 +13,6 @@ const { animationPlayerSpec, animationsSpec } = require("devtools/shared/specs/animation"); -const { Task } = require("devtools/shared/task"); const AnimationPlayerFront = FrontClassWithSpec(animationPlayerSpec, { initialize: function (conn, form, detail, ctx) { @@ -88,12 +87,12 @@ const AnimationPlayerFront = FrontClassWithSpec(animationPlayerSpec, { * Refresh the current state of this animation on the client from information * found on the server. Doesn't return anything, just stores the new state. */ - refreshState: Task.async(function* () { - let data = yield this.getCurrentState(); + async refreshState() { + let data = await this.getCurrentState(); if (this.currentStateHasChanged) { this.state = data; } - }), + }, /** * getCurrentState interceptor re-constructs incomplete states since the actor diff --git a/devtools/shared/fronts/inspector.js b/devtools/shared/fronts/inspector.js index 4db853c9b26e..b9f96f5b70bf 100644 --- a/devtools/shared/fronts/inspector.js +++ b/devtools/shared/fronts/inspector.js @@ -15,7 +15,6 @@ const { walkerSpec } = require("devtools/shared/specs/inspector"); const defer = require("devtools/shared/defer"); -const { Task } = require("devtools/shared/task"); loader.lazyRequireGetter(this, "nodeConstants", "devtools/shared/dom-node-constants"); loader.lazyRequireGetter(this, "CommandUtils", @@ -207,7 +206,7 @@ const WalkerFront = FrontClassWithSpec(walkerSpec, { * - "selectorOnly": treat input as a selector string (don't search text * tags, attributes, etc) */ - search: custom(Task.async(function* (query, options = { }) { + search: custom(async function (query, options = { }) { let nodeList; let searchType; let searchData = this.searchData = this.searchData || { }; @@ -215,10 +214,10 @@ const WalkerFront = FrontClassWithSpec(walkerSpec, { if (selectorOnly) { searchType = "selector"; - nodeList = yield this.multiFrameQuerySelectorAll(query); + nodeList = await this.multiFrameQuerySelectorAll(query); } else { searchType = "search"; - let result = yield this._search(query, options); + let result = await this._search(query, options); nodeList = result.list; } @@ -245,14 +244,14 @@ const WalkerFront = FrontClassWithSpec(walkerSpec, { } // Send back the single node, along with any relevant search data - let node = yield nodeList.item(searchData.index); + let node = await nodeList.item(searchData.index); return { type: searchType, node: node, resultsLength: nodeList.length, resultsIndex: searchData.index, }; - }), { + }, { impl: "_search" }), @@ -437,14 +436,14 @@ const WalkerFront = FrontClassWithSpec(walkerSpec, { return !!this.conn._transport._serverConnection; }, - removeNode: custom(Task.async(function* (node) { - let previousSibling = yield this.previousSibling(node); - let nextSibling = yield this._removeNode(node); + removeNode: custom(async function (node) { + let previousSibling = await this.previousSibling(node); + let nextSibling = await this._removeNode(node); return { previousSibling: previousSibling, nextSibling: nextSibling, }; - }), { + }, { impl: "_removeNode" }), }); @@ -494,15 +493,15 @@ var InspectorFront = FrontClassWithSpec(inspectorSpec, { impl: "_getPageStyle" }), - pickColorFromPage: custom(Task.async(function* (toolbox, options) { + pickColorFromPage: custom(async function (toolbox, options) { if (toolbox) { // If the eyedropper was already started using the gcli command, hide it so we don't // end up with 2 instances of the eyedropper on the page. CommandUtils.executeOnTarget(toolbox.target, "eyedropper --hide"); } - yield this._pickColorFromPage(options); - }), { + await this._pickColorFromPage(options); + }, { impl: "_pickColorFromPage" }) }); diff --git a/devtools/shared/fronts/memory.js b/devtools/shared/fronts/memory.js index dad0056c7e43..80cb9406499e 100644 --- a/devtools/shared/fronts/memory.js +++ b/devtools/shared/fronts/memory.js @@ -4,7 +4,6 @@ "use strict"; const { memorySpec } = require("devtools/shared/specs/memory"); -const { Task } = require("devtools/shared/task"); const protocol = require("devtools/shared/protocol"); loader.lazyRequireGetter(this, "FileUtils", @@ -41,16 +40,16 @@ const MemoryFront = protocol.FrontClassWithSpec(memorySpec, { * * @returns Promise */ - saveHeapSnapshot: protocol.custom(Task.async(function* (options = {}) { - const snapshotId = yield this._saveHeapSnapshotImpl(options.boundaries); + saveHeapSnapshot: protocol.custom(async function (options = {}) { + const snapshotId = await this._saveHeapSnapshotImpl(options.boundaries); if (!options.forceCopy && - (yield HeapSnapshotFileUtils.haveHeapSnapshotTempFile(snapshotId))) { + (await HeapSnapshotFileUtils.haveHeapSnapshotTempFile(snapshotId))) { return HeapSnapshotFileUtils.getHeapSnapshotTempFilePath(snapshotId); } - return yield this.transferHeapSnapshot(snapshotId); - }), { + return this.transferHeapSnapshot(snapshotId); + }, { impl: "_saveHeapSnapshotImpl" }), @@ -80,11 +79,11 @@ const MemoryFront = protocol.FrontClassWithSpec(memorySpec, { const outFile = new FileUtils.File(outFilePath); const outFileStream = FileUtils.openSafeFileOutputStream(outFile); - request.on("bulk-reply", Task.async(function* ({ copyTo }) { - yield copyTo(outFileStream); + request.on("bulk-reply", async function ({ copyTo }) { + await copyTo(outFileStream); FileUtils.closeSafeFileOutputStream(outFileStream); resolve(outFilePath); - })); + }); }); }) }); diff --git a/devtools/shared/fronts/performance.js b/devtools/shared/fronts/performance.js index ff766212ab34..1fffa68cfb1d 100644 --- a/devtools/shared/fronts/performance.js +++ b/devtools/shared/fronts/performance.js @@ -7,7 +7,6 @@ const { Cu } = require("chrome"); const { Front, FrontClassWithSpec, custom, preEvent } = require("devtools/shared/protocol"); const { PerformanceRecordingFront } = require("devtools/shared/fronts/performance-recording"); const { performanceSpec } = require("devtools/shared/specs/performance"); -const { Task } = require("devtools/shared/task"); loader.lazyRequireGetter(this, "PerformanceIO", "devtools/client/performance/modules/io"); @@ -29,13 +28,13 @@ const PerformanceFront = FrontClassWithSpec(performanceSpec, { * Conenct to the server, and handle once-off tasks like storing traits * or system info. */ - connect: custom(Task.async(function* () { - let systemClient = yield getSystemInfo(); - let { traits } = yield this._connect({ systemClient }); + connect: custom(async function () { + let systemClient = await getSystemInfo(); + let { traits } = await this._connect({ systemClient }); this._traits = traits; return this._traits; - }), { + }, { impl: "_connect" }), diff --git a/devtools/shared/fronts/styles.js b/devtools/shared/fronts/styles.js index e65a622c9ce0..6c4317b13f57 100644 --- a/devtools/shared/fronts/styles.js +++ b/devtools/shared/fronts/styles.js @@ -14,7 +14,6 @@ const { styleRuleSpec } = require("devtools/shared/specs/styles"); const promise = require("promise"); -const { Task } = require("devtools/shared/task"); loader.lazyRequireGetter(this, "RuleRewriter", "devtools/shared/css/parsing-utils", true); @@ -56,17 +55,17 @@ const PageStyleFront = FrontClassWithSpec(pageStyleSpec, { impl: "_getMatchedSelectors" }), - getApplied: custom(Task.async(function* (node, options = {}) { + getApplied: custom(async function (node, options = {}) { // If the getApplied method doesn't recreate the style cache itself, this // means a call to cssLogic.highlight is required before trying to access // the applied rules. Issue a request to getLayout if this is the case. // See https://bugzilla.mozilla.org/show_bug.cgi?id=1103993#c16. if (!this._form.traits || !this._form.traits.getAppliedCreatesStyleCache) { - yield this.getLayout(node); + await this.getLayout(node); } - let ret = yield this._getApplied(node, options); + let ret = await this._getApplied(node, options); return ret.entries; - }), { + }, { impl: "_getApplied" }), @@ -253,24 +252,24 @@ const StyleRuleFront = FrontClassWithSpec(styleRuleSpec, { }); }, - modifySelector: custom(Task.async(function* (node, value) { + modifySelector: custom(async function (node, value) { let response; if (this.supportsModifySelectorUnmatched) { // If the debugee supports adding unmatched rules (post FF41) if (this.canSetRuleText) { - response = yield this.modifySelector2(node, value, true); + response = await this.modifySelector2(node, value, true); } else { - response = yield this.modifySelector2(node, value); + response = await this.modifySelector2(node, value); } } else { - response = yield this._modifySelector(value); + response = await this._modifySelector(value); } if (response.ruleProps) { response.ruleProps = response.ruleProps.entries[0]; } return response; - }), { + }, { impl: "_modifySelector" }), diff --git a/devtools/shared/fronts/stylesheets.js b/devtools/shared/fronts/stylesheets.js index bbb5db69773f..6a1b4b06f90e 100644 --- a/devtools/shared/fronts/stylesheets.js +++ b/devtools/shared/fronts/stylesheets.js @@ -10,7 +10,6 @@ const { styleSheetsSpec } = require("devtools/shared/specs/stylesheets"); const promise = require("promise"); -const { Task } = require("devtools/shared/task"); loader.lazyRequireGetter(this, "getIndentationFromPrefs", "devtools/shared/indentation", true); @@ -130,14 +129,14 @@ const StyleSheetFront = FrontClassWithSpec(styleSheetSpec, { return promise.resolve(indentWithTabs ? "\t" : " ".repeat(indentUnit)); } - return Task.spawn(function* () { - let longStr = yield this.getText(); - let source = yield longStr.string(); + return (async function () { + let longStr = await this.getText(); + let source = await longStr.string(); let {indentUnit, indentWithTabs} = getIndentationFromString(source); return indentWithTabs ? "\t" : " ".repeat(indentUnit); - }.bind(this)); + }.bind(this))(); } }); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_DominatorTree_02.js b/devtools/shared/heapsnapshot/tests/unit/test_DominatorTree_02.js index ae4d40713494..ca8d0533ab0d 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_DominatorTree_02.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_DominatorTree_02.js @@ -4,7 +4,7 @@ // Test that we can compute dominator trees from a snapshot in a worker. -add_task(function* () { +add_task(async function () { const worker = new ChromeWorker("resource://test/dominator-tree-worker.js"); worker.postMessage({}); @@ -18,7 +18,7 @@ add_task(function* () { assertionCount++; }; - yield waitForDone(worker); + await waitForDone(worker); ok(assertionCount > 0); worker.terminate(); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_computeDominatorTree_01.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_computeDominatorTree_01.js index ce3c860fa574..e05830284067 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_computeDominatorTree_01.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_computeDominatorTree_01.js @@ -4,14 +4,14 @@ // Test the HeapAnalyses{Client,Worker} "computeDominatorTree" request. -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); - const dominatorTreeId = yield client.computeDominatorTree(snapshotFilePath); + const dominatorTreeId = await client.computeDominatorTree(snapshotFilePath); equal(typeof dominatorTreeId, "number", "should get a dominator tree id, and it should be a number"); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_computeDominatorTree_02.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_computeDominatorTree_02.js index 93576d757352..c3ee76be135b 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_computeDominatorTree_02.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_computeDominatorTree_02.js @@ -5,12 +5,12 @@ // Test the HeapAnalyses{Client,Worker} "computeDominatorTree" request with bad // file paths. -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); let threw = false; try { - yield client.computeDominatorTree("/etc/passwd"); + await client.computeDominatorTree("/etc/passwd"); } catch (_) { threw = true; } diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_01.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_01.js index b3ef3be6f85f..2e630a59a30e 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_01.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_01.js @@ -12,22 +12,22 @@ const breakdown = { other: { by: "count", count: true, bytes: true }, }; -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); - let dominatorTreeId = yield client.computeDominatorTree(snapshotFilePath); + let dominatorTreeId = await client.computeDominatorTree(snapshotFilePath); ok(true, "Should have computed the dominator tree"); - yield client.deleteHeapSnapshot(snapshotFilePath); + await client.deleteHeapSnapshot(snapshotFilePath); ok(true, "Should have deleted the snapshot"); let threw = false; try { - yield client.getDominatorTree({ + await client.getDominatorTree({ dominatorTreeId: dominatorTreeId, breakdown }); @@ -38,7 +38,7 @@ add_task(function* () { threw = false; try { - yield client.computeDominatorTree(snapshotFilePath); + await client.computeDominatorTree(snapshotFilePath); } catch (_) { threw = true; } @@ -46,7 +46,7 @@ add_task(function* () { threw = false; try { - yield client.takeCensus(snapshotFilePath); + await client.takeCensus(snapshotFilePath); } catch (_) { threw = true; } diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_02.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_02.js index 9eac8141c4ca..6960081afd3c 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_02.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_02.js @@ -4,12 +4,12 @@ // Test deleteHeapSnapshot is a noop if the provided path matches no snapshot -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); let threw = false; try { - yield client.deleteHeapSnapshot("path-does-not-exist"); + await client.deleteHeapSnapshot("path-does-not-exist"); } catch (_) { threw = true; } diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_03.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_03.js index a51950af365c..13a2e059a5c3 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_03.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_deleteHeapSnapshot_03.js @@ -12,27 +12,27 @@ const breakdown = { other: { by: "count", count: true, bytes: true }, }; -function* createSnapshotAndDominatorTree(client) { +async function createSnapshotAndDominatorTree(client) { let snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); - let dominatorTreeId = yield client.computeDominatorTree(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); + let dominatorTreeId = await client.computeDominatorTree(snapshotFilePath); return { dominatorTreeId, snapshotFilePath }; } -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); let savedSnapshots = [ - yield createSnapshotAndDominatorTree(client), - yield createSnapshotAndDominatorTree(client), - yield createSnapshotAndDominatorTree(client) + await createSnapshotAndDominatorTree(client), + await createSnapshotAndDominatorTree(client), + await createSnapshotAndDominatorTree(client) ]; ok(true, "Create 3 snapshots and dominator trees"); - yield client.deleteHeapSnapshot(savedSnapshots[1].snapshotFilePath); + await client.deleteHeapSnapshot(savedSnapshots[1].snapshotFilePath); ok(true, "Snapshot deleted"); - let tree = yield client.getDominatorTree({ + let tree = await client.getDominatorTree({ dominatorTreeId: savedSnapshots[0].dominatorTreeId, breakdown }); @@ -40,7 +40,7 @@ add_task(function* () { let threw = false; try { - yield client.getDominatorTree({ + await client.getDominatorTree({ dominatorTreeId: savedSnapshots[1].dominatorTreeId, breakdown }); @@ -49,7 +49,7 @@ add_task(function* () { } ok(threw, "getDominatorTree on a deleted snapshot should throw an error"); - tree = yield client.getDominatorTree({ + tree = await client.getDominatorTree({ dominatorTreeId: savedSnapshots[2].dominatorTreeId, breakdown }); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCensusIndividuals_01.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCensusIndividuals_01.js index 5e59d0d17bc1..43f38f70c097 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCensusIndividuals_01.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCensusIndividuals_01.js @@ -21,28 +21,28 @@ const LABEL_BREAKDOWN = { const MAX_INDIVIDUALS = 10; -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); - const dominatorTreeId = yield client.computeDominatorTree(snapshotFilePath); + const dominatorTreeId = await client.computeDominatorTree(snapshotFilePath); ok(true, "Should have computed dominator tree"); - const { report } = yield client.takeCensus(snapshotFilePath, + const { report } = await client.takeCensus(snapshotFilePath, { breakdown: CENSUS_BREAKDOWN }, { asTreeNode: true }); ok(report, "Should get a report"); let nodesWithLeafIndicesFound = 0; - yield* (function* assertCanGetIndividuals(censusNode) { + await (async function assertCanGetIndividuals(censusNode) { if (censusNode.reportLeafIndex !== undefined) { nodesWithLeafIndicesFound++; - const response = yield client.getCensusIndividuals({ + const response = await client.getCensusIndividuals({ dominatorTreeId, indices: DevToolsUtils.isSet(censusNode.reportLeafIndex) ? censusNode.reportLeafIndex @@ -75,7 +75,7 @@ add_task(function* () { if (censusNode.children) { for (let child of censusNode.children) { - yield* assertCanGetIndividuals(child); + await assertCanGetIndividuals(child); } } }(report)); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCreationTime_01.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCreationTime_01.js index 5858908f19cb..cdd060ebf274 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCreationTime_01.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getCreationTime_01.js @@ -17,7 +17,7 @@ const BREAKDOWN = { then: { by: "count", count: true, bytes: true } }; -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const start = Date.now() * 1000; @@ -29,12 +29,12 @@ add_task(function* () { waitForThirtyMilliseconds(); const end = Date.now() * 1000; - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); let threw = false; try { - yield client.getCreationTime("/not/a/real/path", { + await client.getCreationTime("/not/a/real/path", { breakdown: BREAKDOWN }); } catch (_) { @@ -42,7 +42,7 @@ add_task(function* () { } ok(threw, "getCreationTime should throw when snapshot does not exist"); - let time = yield client.getCreationTime(snapshotFilePath, { + let time = await client.getCreationTime(snapshotFilePath, { breakdown: BREAKDOWN }); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getDominatorTree_01.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getDominatorTree_01.js index cc0c29154c37..5a396ee2532d 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getDominatorTree_01.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getDominatorTree_01.js @@ -12,18 +12,18 @@ const breakdown = { other: { by: "count", count: true, bytes: true }, }; -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); - const dominatorTreeId = yield client.computeDominatorTree(snapshotFilePath); + const dominatorTreeId = await client.computeDominatorTree(snapshotFilePath); equal(typeof dominatorTreeId, "number", "should get a dominator tree id, and it should be a number"); - const partialTree = yield client.getDominatorTree({ + const partialTree = await client.getDominatorTree({ dominatorTreeId, breakdown }); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getDominatorTree_02.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getDominatorTree_02.js index 78145019c524..83a7cbbd3d16 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getDominatorTree_02.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getDominatorTree_02.js @@ -13,12 +13,12 @@ const breakdown = { other: { by: "count", count: true, bytes: true }, }; -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); let threw = false; try { - yield client.getDominatorTree({ dominatorTreeId: 42, breakdown }); + await client.getDominatorTree({ dominatorTreeId: 42, breakdown }); } catch (_) { threw = true; } diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getImmediatelyDominated_01.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getImmediatelyDominated_01.js index 73bacc301018..ae91d5540aee 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getImmediatelyDominated_01.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_getImmediatelyDominated_01.js @@ -12,14 +12,14 @@ const breakdown = { other: { by: "count", count: true, bytes: true }, }; -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); - const dominatorTreeId = yield client.computeDominatorTree(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); + const dominatorTreeId = await client.computeDominatorTree(snapshotFilePath); - const partialTree = yield client.getDominatorTree({ + const partialTree = await client.getDominatorTree({ dominatorTreeId, breakdown }); @@ -27,7 +27,7 @@ add_task(function* () { "root should immediately dominate some nodes"); // First, test getting a subset of children available. - const response = yield client.getImmediatelyDominated({ + const response = await client.getImmediatelyDominated({ dominatorTreeId, breakdown, nodeId: partialTree.nodeId, @@ -51,7 +51,7 @@ add_task(function* () { } // Next, test getting a subset of children available. - const secondResponse = yield client.getImmediatelyDominated({ + const secondResponse = await client.getImmediatelyDominated({ dominatorTreeId, breakdown, nodeId: partialTree.nodeId, diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_readHeapSnapshot_01.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_readHeapSnapshot_01.js index a5854e1ee5a2..dea8269a9288 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_readHeapSnapshot_01.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_readHeapSnapshot_01.js @@ -4,11 +4,11 @@ // Test that the HeapAnalyses{Client,Worker} can read heap snapshots. -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); client.destroy(); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensusDiff_01.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensusDiff_01.js index 32ed715e179c..f54e7c53c9f1 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensusDiff_01.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensusDiff_01.js @@ -10,7 +10,7 @@ const BREAKDOWN = { other: { by: "count", count: true, bytes: false }, }; -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const markers = [allocationMarker()]; @@ -23,18 +23,18 @@ add_task(function* () { const secondSnapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(firstSnapshotFilePath); - yield client.readHeapSnapshot(secondSnapshotFilePath); + await client.readHeapSnapshot(firstSnapshotFilePath); + await client.readHeapSnapshot(secondSnapshotFilePath); ok(true, "Should have read both heap snapshot files"); - const { delta } = yield client.takeCensusDiff(firstSnapshotFilePath, + const { delta } = await client.takeCensusDiff(firstSnapshotFilePath, secondSnapshotFilePath, { breakdown: BREAKDOWN }); equal(delta.AllocationMarker.count, 1, "There exists one new AllocationMarker in the second heap snapshot"); - const { delta: deltaTreeNode } = yield client.takeCensusDiff(firstSnapshotFilePath, + const { delta: deltaTreeNode } = await client.takeCensusDiff(firstSnapshotFilePath, secondSnapshotFilePath, { breakdown: BREAKDOWN }, { asTreeNode: true }); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensusDiff_02.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensusDiff_02.js index db016d6fc760..1a4ca870923f 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensusDiff_02.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensusDiff_02.js @@ -26,22 +26,22 @@ const BREAKDOWN = { }, }; -add_task(function* () { +add_task(async function () { const firstSnapshotFilePath = saveNewHeapSnapshot(); const secondSnapshotFilePath = saveNewHeapSnapshot(); const client = new HeapAnalysesClient(); - yield client.readHeapSnapshot(firstSnapshotFilePath); - yield client.readHeapSnapshot(secondSnapshotFilePath); + await client.readHeapSnapshot(firstSnapshotFilePath); + await client.readHeapSnapshot(secondSnapshotFilePath); ok(true, "Should have read both heap snapshot files"); - const { delta } = yield client.takeCensusDiff(firstSnapshotFilePath, + const { delta } = await client.takeCensusDiff(firstSnapshotFilePath, secondSnapshotFilePath, { breakdown: BREAKDOWN }); const { delta: deltaTreeNode } - = yield client.takeCensusDiff(firstSnapshotFilePath, + = await client.takeCensusDiff(firstSnapshotFilePath, secondSnapshotFilePath, { breakdown: BREAKDOWN }, { asInvertedTreeNode: true }); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_01.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_01.js index c7af28f65bfa..55da2bf4b82a 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_01.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_01.js @@ -4,14 +4,14 @@ // Test that the HeapAnalyses{Client,Worker} can take censuses. -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); - const { report } = yield client.takeCensus(snapshotFilePath); + const { report } = await client.takeCensus(snapshotFilePath); ok(report, "Should get a report"); equal(typeof report, "object", "report should be an object"); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_02.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_02.js index 2f8c41815d69..a9c95c070aef 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_02.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_02.js @@ -5,14 +5,14 @@ // Test that the HeapAnalyses{Client,Worker} can take censuses with breakdown // options. -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); - const { report } = yield client.takeCensus(snapshotFilePath, { + const { report } = await client.takeCensus(snapshotFilePath, { breakdown: { by: "count", count: true, bytes: true } }); diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_03.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_03.js index 0a79562e606c..cff379868a00 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_03.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_03.js @@ -5,13 +5,13 @@ // Test that the HeapAnalyses{Client,Worker} bubbles errors properly when things // go wrong. -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); // Snapshot file path to a file that doesn't exist. let failed = false; try { - yield client.readHeapSnapshot(getFilePath("foo-bar-baz" + Math.random(), true)); + await client.readHeapSnapshot(getFilePath("foo-bar-baz" + Math.random(), true)); } catch (e) { failed = true; } @@ -20,7 +20,7 @@ add_task(function* () { // Snapshot file path to a file that is not a heap snapshot. failed = false; try { - yield client.readHeapSnapshot(getFilePath("test_HeapAnalyses_takeCensus_03.js")); + await client.readHeapSnapshot(getFilePath("test_HeapAnalyses_takeCensus_03.js")); } catch (e) { failed = true; } @@ -28,13 +28,13 @@ add_task(function* () { + "that is not a heap snapshot as a heap snapshot"); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); // Bad census breakdown options. failed = false; try { - yield client.takeCensus(snapshotFilePath, { + await client.takeCensus(snapshotFilePath, { breakdown: { by: "some classification that we do not have" } }); } catch (e) { diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_05.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_05.js index c1a068c5c403..73c2ec3c0fa6 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_05.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_05.js @@ -10,18 +10,18 @@ const BREAKDOWN = { then: { by: "count", count: true, bytes: true } }; -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); - const { report } = yield client.takeCensus(snapshotFilePath, { + const { report } = await client.takeCensus(snapshotFilePath, { breakdown: BREAKDOWN }); - const { report: treeNode } = yield client.takeCensus(snapshotFilePath, { + const { report: treeNode } = await client.takeCensus(snapshotFilePath, { breakdown: BREAKDOWN }, { asTreeNode: true diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_06.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_06.js index 2449d207e9c9..cfda9f8c41dc 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_06.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_06.js @@ -15,7 +15,7 @@ const BREAKDOWN = { other: { by: "count", count: true, bytes: true } }; -add_task(function* () { +add_task(async function () { const g = newGlobal(); const dbg = new Debugger(g); @@ -53,14 +53,14 @@ add_task(function* () { const snapshotFilePath = saveNewHeapSnapshot({ debugger: dbg }); const client = new HeapAnalysesClient(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); - const { report } = yield client.takeCensus(snapshotFilePath, { + const { report } = await client.takeCensus(snapshotFilePath, { breakdown: BREAKDOWN }); - const { report: treeNode } = yield client.takeCensus(snapshotFilePath, { + const { report: treeNode } = await client.takeCensus(snapshotFilePath, { breakdown: BREAKDOWN }, { asTreeNode: true diff --git a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_07.js b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_07.js index 81d0ebfc0a7e..091b9ad30ea6 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_07.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_HeapAnalyses_takeCensus_07.js @@ -26,18 +26,18 @@ const BREAKDOWN = { }, }; -add_task(function* () { +add_task(async function () { const client = new HeapAnalysesClient(); const snapshotFilePath = saveNewHeapSnapshot(); - yield client.readHeapSnapshot(snapshotFilePath); + await client.readHeapSnapshot(snapshotFilePath); ok(true, "Should have read the heap snapshot"); - const { report } = yield client.takeCensus(snapshotFilePath, { + const { report } = await client.takeCensus(snapshotFilePath, { breakdown: BREAKDOWN }); - const { report: treeNode } = yield client.takeCensus(snapshotFilePath, { + const { report: treeNode } = await client.takeCensus(snapshotFilePath, { breakdown: BREAKDOWN }, { asInvertedTreeNode: true diff --git a/devtools/shared/heapsnapshot/tests/unit/test_ReadHeapSnapshot_worker.js b/devtools/shared/heapsnapshot/tests/unit/test_ReadHeapSnapshot_worker.js index d782a67ac68f..d86b7aa4dbc6 100644 --- a/devtools/shared/heapsnapshot/tests/unit/test_ReadHeapSnapshot_worker.js +++ b/devtools/shared/heapsnapshot/tests/unit/test_ReadHeapSnapshot_worker.js @@ -3,7 +3,7 @@ // Test that we can read core dumps into HeapSnapshot instances in a worker. // eslint-disable-next-line -add_task(function* () { +add_task(async function () { const worker = new ChromeWorker("resource://test/heap-snapshot-worker.js"); worker.postMessage({}); @@ -17,7 +17,7 @@ add_task(function* () { assertionCount++; }; - yield waitForDone(worker); + await waitForDone(worker); ok(assertionCount > 0); worker.terminate(); diff --git a/devtools/shared/qrcode/tests/mochitest/test_decode.html b/devtools/shared/qrcode/tests/mochitest/test_decode.html index aa8889c81aa3..5c7515747d8f 100644 --- a/devtools/shared/qrcode/tests/mochitest/test_decode.html +++ b/devtools/shared/qrcode/tests/mochitest/test_decode.html @@ -27,7 +27,7 @@ window.onload = function() { "t3jVw2dwTPwJq1KYG3gAklCgu37yGxeScYKyiCc+7DR34hPVQiuQ7UhJMagyEb" + "lymmzJk0a9q8iTOnzp0NCgAAOw=="; - (async function() { + (async function () { let result = await QR.decodeFromURI(testImage); is(result, "HELLO", "Decoded data URI result matches"); let canvas = await drawToCanvas(testImage); diff --git a/devtools/shared/security/auth.js b/devtools/shared/security/auth.js index cfc13ef5432a..2b18c2ef18e8 100644 --- a/devtools/shared/security/auth.js +++ b/devtools/shared/security/auth.js @@ -17,7 +17,6 @@ loader.lazyRequireGetter(this, "cert", "devtools/shared/security/cert"); loader.lazyRequireGetter(this, "asyncStorage", "devtools/shared/async-storage"); -const { Task } = require("devtools/shared/task"); /** * A simple enum-like object with keys mirrored to values. @@ -343,14 +342,14 @@ OOBCert.Client.prototype = { }; transport.hooks = { - onPacket: Task.async(function* (packet) { + onPacket: async (packet) => { closeDialog(); let { authResult } = packet; switch (authResult) { case AuthenticationResult.PENDING: // Step B.8 // Client creates hash(ClientCert) + K(random 128-bit number) - oobData = yield this._createOOB(); + oobData = await this._createOOB(); activeSendDialog = this.sendOOB({ host, port, @@ -382,7 +381,7 @@ OOBCert.Client.prototype = { transport.close(new Error("Invalid auth result: " + authResult)); break; } - }.bind(this)), + }, onClosed(reason) { closeDialog(); // Transport died before auth completed @@ -398,13 +397,13 @@ OOBCert.Client.prototype = { * Create the package of data that needs to be transferred across the OOB * channel. */ - _createOOB: Task.async(function* () { - let clientCert = yield cert.local.getOrCreate(); + async _createOOB() { + let clientCert = await cert.local.getOrCreate(); return { sha256: clientCert.sha256Fingerprint, k: this._createRandom() }; - }), + }, _createRandom() { // 16 bytes / 128 bits @@ -511,11 +510,11 @@ OOBCert.Server.prototype = { * @return An AuthenticationResult value. * A promise that will be resolved to the above is also allowed. */ - authenticate: Task.async(function* ({ client, server, transport }) { + async authenticate({ client, server, transport }) { // Step B.3 / C.3 // TLS connection established, authentication begins const storageKey = `devtools.auth.${this.mode}.approved-clients`; - let approvedClients = (yield asyncStorage.getItem(storageKey)) || {}; + let approvedClients = (await asyncStorage.getItem(storageKey)) || {}; // Step C.4 // Server sees that ClientCert is from a known client via hash(ClientCert) if (approvedClients[client.cert.sha256]) { @@ -536,7 +535,7 @@ OOBCert.Server.prototype = { // Step B.5 // User is shown a Allow / Deny / Always Allow prompt on the Server // with Client name and hash(ClientCert) - let authResult = yield this.allowConnection({ + let authResult = await this.allowConnection({ authentication: this.mode, client, server @@ -553,7 +552,7 @@ OOBCert.Server.prototype = { } // Examine additional data for authentication - let oob = yield this.receiveOOB(); + let oob = await this.receiveOOB(); if (!oob) { dumpn("Invalid OOB data received"); return AuthenticationResult.DENY; @@ -583,7 +582,7 @@ OOBCert.Server.prototype = { // Persist Client if we want to always allow in the future if (authResult === AuthenticationResult.ALLOW_PERSIST) { approvedClients[client.cert.sha256] = true; - yield asyncStorage.setItem(storageKey, approvedClients); + await asyncStorage.setItem(storageKey, approvedClients); } // Client may decide to abort if K does not match. @@ -592,7 +591,7 @@ OOBCert.Server.prototype = { // Step B.13 // Debugging begins return authResult; - }), + }, /** * Prompt the user to accept or decline the incoming connection. The default diff --git a/devtools/shared/security/socket.js b/devtools/shared/security/socket.js index 925d6efeaad5..446620be9c48 100644 --- a/devtools/shared/security/socket.js +++ b/devtools/shared/security/socket.js @@ -52,8 +52,6 @@ DevToolsUtils.defineLazyGetter(this, "nssErrorsService", () => { .getService(Ci.nsINSSErrorsService); }); -const { Task } = require("devtools/shared/task"); - var DebuggerSocket = {}; /** @@ -75,15 +73,15 @@ var DebuggerSocket = {}; * @return promise * Resolved to a DebuggerTransport instance. */ -DebuggerSocket.connect = Task.async(function* (settings) { +DebuggerSocket.connect = async function (settings) { // Default to PROMPT |Authenticator| instance if not supplied if (!settings.authenticator) { settings.authenticator = new (Authenticators.get().Client)(); } _validateSettings(settings); let { host, port, encryption, authenticator, cert } = settings; - let transport = yield _getTransport(settings); - yield authenticator.authenticate({ + let transport = await _getTransport(settings); + await authenticator.authenticate({ host, port, encryption, @@ -92,7 +90,7 @@ DebuggerSocket.connect = Task.async(function* (settings) { }); transport.connectionSettings = settings; return transport; -}); +}; /** * Validate that the connection settings have been set to a supported configuration. @@ -127,12 +125,12 @@ function _validateSettings(settings) { * A possible DevTools transport (if connection succeeded and streams * are actually alive and working) */ -var _getTransport = Task.async(function* (settings) { +var _getTransport = async function (settings) { let { host, port, encryption, webSocket } = settings; if (webSocket) { // Establish a connection and wait until the WebSocket is ready to send and receive - let socket = yield new Promise((resolve, reject) => { + let socket = await new Promise((resolve, reject) => { let s = new WebSocket(`ws://${host}:${port}`); s.onopen = () => resolve(s); s.onerror = err => reject(err); @@ -141,7 +139,7 @@ var _getTransport = Task.async(function* (settings) { return new WebSocketDebuggerTransport(socket); } - let attempt = yield _attemptTransport(settings); + let attempt = await _attemptTransport(settings); if (attempt.transport) { // Success return attempt.transport; @@ -155,14 +153,14 @@ var _getTransport = Task.async(function* (settings) { throw new Error("Connection failed"); } - attempt = yield _attemptTransport(settings); + attempt = await _attemptTransport(settings); if (attempt.transport) { // Success return attempt.transport; } throw new Error("Connection failed even after cert override"); -}); +}; /** * Make a single attempt to connect and create a DevTools transport. This could @@ -189,17 +187,17 @@ var _getTransport = Task.async(function* (settings) { * @return s nsISocketTransport * Underlying socket transport, in case more details are needed. */ -var _attemptTransport = Task.async(function* (settings) { +var _attemptTransport = async function (settings) { let { authenticator } = settings; // _attemptConnect only opens the streams. Any failures at that stage // aborts the connection process immedidately. - let { s, input, output } = yield _attemptConnect(settings); + let { s, input, output } = await _attemptConnect(settings); // Check if the input stream is alive. If encryption is enabled, we need to // watch out for cert errors by testing the input stream. let alive, certError; try { - let results = yield _isInputAlive(input); + let results = await _isInputAlive(input); alive = results.alive; certError = results.certError; } catch (e) { @@ -231,7 +229,7 @@ var _attemptTransport = Task.async(function* (settings) { } return { transport, certError, s }; -}); +}; /** * Try to connect to a remote server socket. @@ -247,7 +245,7 @@ var _attemptTransport = Task.async(function* (settings) { * @return output nsIAsyncOutputStream * The socket's output stream. */ -var _attemptConnect = Task.async(function* ({ host, port, encryption }) { +var _attemptConnect = async function ({ host, port, encryption }) { let s; if (encryption) { s = socketTransportService.createTransport(["ssl"], 1, host, port, null); @@ -263,7 +261,7 @@ var _attemptConnect = Task.async(function* ({ host, port, encryption }) { // right time. let clientCert; if (encryption) { - clientCert = yield cert.local.getOrCreate(); + clientCert = await cert.local.getOrCreate(); } let deferred = defer(); @@ -315,7 +313,7 @@ var _attemptConnect = Task.async(function* ({ host, port, encryption }) { }); return deferred.promise; -}); +}; /** * Check if the input stream is alive. For an encrypted connection, it may not @@ -430,7 +428,7 @@ SocketListener.prototype = { } let self = this; - return Task.spawn(function* () { + return (async function () { let backlog = 4; self._socket = self._createSocketInstance(); if (self.isPortBased) { @@ -443,10 +441,10 @@ SocketListener.prototype = { } self._socket.initWithFilename(file, parseInt("666", 8), backlog); } - yield self._setAdditionalSocketOptions(); + await self._setAdditionalSocketOptions(); self._socket.asyncListen(self); dumpn("Socket listening on: " + (self.port || self.portOrPath)); - }).then(() => { + })().then(() => { this._advertise(); }).catch(e => { dumpn("Could not start debugging listener on '" + this.portOrPath + @@ -479,16 +477,16 @@ SocketListener.prototype = { .createInstance(Ci.nsIServerSocket); }, - _setAdditionalSocketOptions: Task.async(function* () { + async _setAdditionalSocketOptions() { if (this.encryption) { - this._socket.serverCert = yield cert.local.getOrCreate(); + this._socket.serverCert = await cert.local.getOrCreate(); this._socket.setSessionCache(false); this._socket.setSessionTickets(false); let requestCert = Ci.nsITLSServerSocket.REQUEST_NEVER; this._socket.setRequestClientCertificate(requestCert); } this.authenticator.augmentSocketOptions(this, this._socket); - }), + }, /** * Closes the SocketListener. Notifies the server to remove the listener from @@ -629,24 +627,24 @@ ServerSocketConnection.prototype = { _handle() { dumpn("Debugging connection starting authentication on " + this.address); let self = this; - Task.spawn(function* () { + (async function () { self._listenForTLSHandshake(); - yield self._createTransport(); - yield self._awaitTLSHandshake(); - yield self._authenticate(); - }).then(() => this.allow()).catch(e => this.deny(e)); + await self._createTransport(); + await self._awaitTLSHandshake(); + await self._authenticate(); + })().then(() => this.allow()).catch(e => this.deny(e)); }, /** * We need to open the streams early on, as that is required in the case of * TLS sockets to keep the handshake moving. */ - _createTransport: Task.async(function* () { + async _createTransport() { let input = this._socketTransport.openInputStream(0, 0, 0); let output = this._socketTransport.openOutputStream(0, 0, 0); if (this._listener.webSocket) { - let socket = yield WebSocketServer.accept(this._socketTransport, input, output); + let socket = await WebSocketServer.accept(this._socketTransport, input, output); this._transport = new WebSocketDebuggerTransport(socket); } else { this._transport = new DebuggerTransport(input, output); @@ -660,7 +658,7 @@ ServerSocketConnection.prototype = { } }; this._transport.ready(); - }), + }, /** * Set the socket's security observer, which receives an event via the @@ -725,8 +723,8 @@ ServerSocketConnection.prototype = { this._handshakeDeferred.resolve(); }, - _authenticate: Task.async(function* () { - let result = yield this._listener.authenticator.authenticate({ + async _authenticate() { + let result = await this._listener.authenticator.authenticate({ client: this.client, server: this.server, transport: this._transport @@ -744,7 +742,7 @@ ServerSocketConnection.prototype = { default: return promise.reject(Cr.NS_ERROR_CONNECTION_REFUSED); } - }), + }, deny(result) { if (this._destroyed) { diff --git a/devtools/shared/security/tests/chrome/test_websocket-transport.html b/devtools/shared/security/tests/chrome/test_websocket-transport.html index d7618c22590a..d2f1d86e4314 100644 --- a/devtools/shared/security/tests/chrome/test_websocket-transport.html +++ b/devtools/shared/security/tests/chrome/test_websocket-transport.html @@ -25,7 +25,7 @@ window.onload = function () { Services.prefs.clearUserPref("devtools.debugger.prompt-connection"); }); - add_task(function* () { + add_task(async function () { DebuggerServer.init(); DebuggerServer.registerAllActors(); @@ -35,10 +35,10 @@ window.onload = function () { ok(listener, "Socket listener created"); listener.portOrPath = -1; listener.webSocket = true; - yield listener.open(); + await listener.open(); is(DebuggerServer.listeningSockets, 1, "1 listening socket"); - let transport = yield DebuggerClient.socketConnect({ + let transport = await DebuggerClient.socketConnect({ host: "127.0.0.1", port: listener.port, webSocket: true @@ -51,12 +51,12 @@ window.onload = function () { }; client.addListener("closed", onUnexpectedClose); - yield client.connect(); - yield client.listTabs(); + await client.connect(); + await client.listTabs(); // Send a message the server that will echo back let message = "message"; - let reply = yield client.request({ + let reply = await client.request({ to: "root", type: "echo", message diff --git a/devtools/shared/security/tests/unit/test_encryption.js b/devtools/shared/security/tests/unit/test_encryption.js index eb0c2235c3c0..76bf10b124d5 100644 --- a/devtools/shared/security/tests/unit/test_encryption.js +++ b/devtools/shared/security/tests/unit/test_encryption.js @@ -16,12 +16,12 @@ function connectClient(client) { return client.connect(() => client.listTabs()); } -add_task(function* () { +add_task(async function () { initTestDebuggerServer(); }); // Client w/ encryption connects successfully to server w/ encryption -add_task(function* () { +add_task(async function () { equal(DebuggerServer.listeningSockets, 0, "0 listening sockets"); let AuthenticatorType = DebuggerServer.Authenticators.get("PROMPT"); @@ -35,10 +35,10 @@ add_task(function* () { listener.portOrPath = -1; listener.authenticator = authenticator; listener.encryption = true; - yield listener.open(); + await listener.open(); equal(DebuggerServer.listeningSockets, 1, "1 listening socket"); - let transport = yield DebuggerClient.socketConnect({ + let transport = await DebuggerClient.socketConnect({ host: "127.0.0.1", port: listener.port, encryption: true @@ -50,11 +50,11 @@ add_task(function* () { do_throw("Closed unexpectedly"); }; client.addListener("closed", onUnexpectedClose); - yield connectClient(client); + await connectClient(client); // Send a message the server will echo back let message = "secrets"; - let reply = yield client.request({ + let reply = await client.request({ to: "root", type: "echo", message @@ -68,7 +68,7 @@ add_task(function* () { }); // Client w/o encryption fails to connect to server w/ encryption -add_task(function* () { +add_task(async function () { equal(DebuggerServer.listeningSockets, 0, "0 listening sockets"); let AuthenticatorType = DebuggerServer.Authenticators.get("PROMPT"); @@ -82,11 +82,11 @@ add_task(function* () { listener.portOrPath = -1; listener.authenticator = authenticator; listener.encryption = true; - yield listener.open(); + await listener.open(); equal(DebuggerServer.listeningSockets, 1, "1 listening socket"); try { - yield DebuggerClient.socketConnect({ + await DebuggerClient.socketConnect({ host: "127.0.0.1", port: listener.port // encryption: false is the default @@ -101,6 +101,6 @@ add_task(function* () { do_throw("Connection unexpectedly succeeded"); }); -add_task(function* () { +add_task(async function () { DebuggerServer.destroy(); }); diff --git a/devtools/shared/security/tests/unit/test_oob_cert_auth.js b/devtools/shared/security/tests/unit/test_oob_cert_auth.js index e4f061d56689..bd4fb84a53b7 100644 --- a/devtools/shared/security/tests/unit/test_oob_cert_auth.js +++ b/devtools/shared/security/tests/unit/test_oob_cert_auth.js @@ -21,16 +21,16 @@ function connectClient(client) { }); } -add_task(function* () { +add_task(async function () { initTestDebuggerServer(); }); // Client w/ OOB_CERT auth connects successfully to server w/ OOB_CERT auth -add_task(function* () { +add_task(async function () { equal(DebuggerServer.listeningSockets, 0, "0 listening sockets"); // Grab our cert, instead of relying on a discovery advertisement - let serverCert = yield cert.local.getOrCreate(); + let serverCert = await cert.local.getOrCreate(); let oobData = defer(); let AuthenticatorType = DebuggerServer.Authenticators.get("OOB_CERT"); @@ -46,7 +46,7 @@ add_task(function* () { listener.portOrPath = -1; listener.encryption = true; listener.authenticator = serverAuth; - yield listener.open(); + await listener.open(); equal(DebuggerServer.listeningSockets, 1, "1 listening socket"); let clientAuth = new AuthenticatorType.Client(); @@ -56,7 +56,7 @@ add_task(function* () { oobData.resolve(oob); }; - let transport = yield DebuggerClient.socketConnect({ + let transport = await DebuggerClient.socketConnect({ host: "127.0.0.1", port: listener.port, encryption: true, @@ -72,11 +72,11 @@ add_task(function* () { do_throw("Closed unexpectedly"); }; client.addListener("closed", onUnexpectedClose); - yield connectClient(client); + await connectClient(client); // Send a message the server will echo back let message = "secrets"; - let reply = yield client.request({ + let reply = await client.request({ to: "root", type: "echo", message @@ -90,7 +90,7 @@ add_task(function* () { }); // Client w/o OOB_CERT auth fails to connect to server w/ OOB_CERT auth -add_task(function* () { +add_task(async function () { equal(DebuggerServer.listeningSockets, 0, "0 listening sockets"); let oobData = defer(); @@ -107,12 +107,12 @@ add_task(function* () { listener.portOrPath = -1; listener.encryption = true; listener.authenticator = serverAuth; - yield listener.open(); + await listener.open(); equal(DebuggerServer.listeningSockets, 1, "1 listening socket"); // This will succeed, but leaves the client in confused state, and no data is // actually accessible - let transport = yield DebuggerClient.socketConnect({ + let transport = await DebuggerClient.socketConnect({ host: "127.0.0.1", port: listener.port, encryption: true @@ -129,12 +129,12 @@ add_task(function* () { deferred.resolve(); }; client.connect(); - yield deferred.promise; + await deferred.promise; // Try to send a message the server will echo back let message = "secrets"; try { - yield client.request({ + await client.request({ to: "root", type: "echo", message @@ -151,11 +151,11 @@ add_task(function* () { }); // Client w/ invalid K value fails to connect -add_task(function* () { +add_task(async function () { equal(DebuggerServer.listeningSockets, 0, "0 listening sockets"); // Grab our cert, instead of relying on a discovery advertisement - let serverCert = yield cert.local.getOrCreate(); + let serverCert = await cert.local.getOrCreate(); let oobData = defer(); let AuthenticatorType = DebuggerServer.Authenticators.get("OOB_CERT"); @@ -182,11 +182,11 @@ add_task(function* () { listener.portOrPath = -1; listener.encryption = true; listener.authenticator = serverAuth; - yield listener.open(); + await listener.open(); equal(DebuggerServer.listeningSockets, 1, "1 listening socket"); try { - yield DebuggerClient.socketConnect({ + await DebuggerClient.socketConnect({ host: "127.0.0.1", port: listener.port, encryption: true, @@ -206,11 +206,11 @@ add_task(function* () { }); // Client w/ invalid cert hash fails to connect -add_task(function* () { +add_task(async function () { equal(DebuggerServer.listeningSockets, 0, "0 listening sockets"); // Grab our cert, instead of relying on a discovery advertisement - let serverCert = yield cert.local.getOrCreate(); + let serverCert = await cert.local.getOrCreate(); let oobData = defer(); let AuthenticatorType = DebuggerServer.Authenticators.get("OOB_CERT"); @@ -237,11 +237,11 @@ add_task(function* () { listener.portOrPath = -1; listener.encryption = true; listener.authenticator = serverAuth; - yield listener.open(); + await listener.open(); equal(DebuggerServer.listeningSockets, 1, "1 listening socket"); try { - yield DebuggerClient.socketConnect({ + await DebuggerClient.socketConnect({ host: "127.0.0.1", port: listener.port, encryption: true, @@ -260,6 +260,6 @@ add_task(function* () { do_throw("Connection unexpectedly succeeded"); }); -add_task(function* () { +add_task(async function () { DebuggerServer.destroy(); }); diff --git a/devtools/shared/system.js b/devtools/shared/system.js index 4d80972c2f32..fc6c6261e061 100644 --- a/devtools/shared/system.js +++ b/devtools/shared/system.js @@ -4,7 +4,6 @@ "use strict"; const { Cc, Ci } = require("chrome"); -const { Task } = require("devtools/shared/task"); loader.lazyRequireGetter(this, "Services"); loader.lazyRequireGetter(this, "promise"); @@ -47,7 +46,7 @@ const APP_MAP = { var CACHED_INFO = null; -function* getSystemInfo() { +async function getSystemInfo() { if (CACHED_INFO) { return CACHED_INFO; } @@ -75,8 +74,8 @@ function* getSystemInfo() { // `getSetting` does not work in child processes on b2g. // TODO bug 1205797, make this work in child processes. try { - hardware = yield exports.getSetting("deviceinfo.hardware"); - version = yield exports.getSetting("deviceinfo.os"); + hardware = await exports.getSetting("deviceinfo.hardware"); + version = await exports.getSetting("deviceinfo.os"); } catch (e) { // Ignore. } @@ -324,7 +323,7 @@ function getSetting(name) { return deferred.promise; } -exports.getSystemInfo = Task.async(getSystemInfo); +exports.getSystemInfo = getSystemInfo; exports.getSetting = getSetting; exports.getScreenDimensions = getScreenDimensions; exports.getOSCPU = getOSCPU; diff --git a/devtools/shared/tests/browser/browser_async_storage.js b/devtools/shared/tests/browser/browser_async_storage.js index 141965cf00b4..0422c6eb68ec 100644 --- a/devtools/shared/tests/browser/browser_async_storage.js +++ b/devtools/shared/tests/browser/browser_async_storage.js @@ -8,7 +8,7 @@ // Adapted from https://github.com/mozilla-b2g/gaia/blob/f09993563fb5fec4393eb71816ce76cb00463190/apps/sharedtest/test/unit/async_storage_test.js. const asyncStorage = require("devtools/shared/async-storage"); -add_task(function* () { +add_task(async function () { is(typeof asyncStorage.length, "function", "API exists."); is(typeof asyncStorage.key, "function", "API exists."); is(typeof asyncStorage.getItem, "function", "API exists."); @@ -17,61 +17,61 @@ add_task(function* () { is(typeof asyncStorage.clear, "function", "API exists."); }); -add_task(function* () { - yield asyncStorage.setItem("foo", "bar"); - let value = yield asyncStorage.getItem("foo"); +add_task(async function () { + await asyncStorage.setItem("foo", "bar"); + let value = await asyncStorage.getItem("foo"); is(value, "bar", "value is correct"); - yield asyncStorage.setItem("foo", "overwritten"); - value = yield asyncStorage.getItem("foo"); + await asyncStorage.setItem("foo", "overwritten"); + value = await asyncStorage.getItem("foo"); is(value, "overwritten", "value is correct"); - yield asyncStorage.removeItem("foo"); - value = yield asyncStorage.getItem("foo"); + await asyncStorage.removeItem("foo"); + value = await asyncStorage.getItem("foo"); is(value, null, "value is correct"); }); -add_task(function* () { +add_task(async function () { let object = { x: 1, y: "foo", z: true }; - yield asyncStorage.setItem("myobj", object); - let value = yield asyncStorage.getItem("myobj"); + await asyncStorage.setItem("myobj", object); + let value = await asyncStorage.getItem("myobj"); is(object.x, value.x, "value is correct"); is(object.y, value.y, "value is correct"); is(object.z, value.z, "value is correct"); - yield asyncStorage.removeItem("myobj"); - value = yield asyncStorage.getItem("myobj"); + await asyncStorage.removeItem("myobj"); + value = await asyncStorage.getItem("myobj"); is(value, null, "value is correct"); }); -add_task(function* () { - yield asyncStorage.clear(); - let len = yield asyncStorage.length(); +add_task(async function () { + await asyncStorage.clear(); + let len = await asyncStorage.length(); is(len, 0, "length is correct"); - yield asyncStorage.setItem("key1", "value1"); - len = yield asyncStorage.length(); + await asyncStorage.setItem("key1", "value1"); + len = await asyncStorage.length(); is(len, 1, "length is correct"); - yield asyncStorage.setItem("key2", "value2"); - len = yield asyncStorage.length(); + await asyncStorage.setItem("key2", "value2"); + len = await asyncStorage.length(); is(len, 2, "length is correct"); - yield asyncStorage.setItem("key3", "value3"); - len = yield asyncStorage.length(); + await asyncStorage.setItem("key3", "value3"); + len = await asyncStorage.length(); is(len, 3, "length is correct"); - let key = yield asyncStorage.key(0); + let key = await asyncStorage.key(0); is(key, "key1", "key is correct"); - key = yield asyncStorage.key(1); + key = await asyncStorage.key(1); is(key, "key2", "key is correct"); - key = yield asyncStorage.key(2); + key = await asyncStorage.key(2); is(key, "key3", "key is correct"); - key = yield asyncStorage.key(3); + key = await asyncStorage.key(3); is(key, null, "key is correct"); - yield asyncStorage.clear(); - key = yield asyncStorage.key(0); + await asyncStorage.clear(); + key = await asyncStorage.key(0); is(key, null, "key is correct"); - len = yield asyncStorage.length(); + len = await asyncStorage.length(); is(len, 0, "length is correct"); }); diff --git a/devtools/shared/tests/mochitest/test_eventemitter_basic.html b/devtools/shared/tests/mochitest/test_eventemitter_basic.html index 38ce756d3c9b..43246e40eca3 100644 --- a/devtools/shared/tests/mochitest/test_eventemitter_basic.html +++ b/devtools/shared/tests/mochitest/test_eventemitter_basic.html @@ -24,14 +24,13 @@ const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {}); const promise = require("promise"); const EventEmitter = require("devtools/shared/old-event-emitter"); - const { Task } = require("devtools/shared/task"); SimpleTest.waitForExplicitFinish(); testEmitter(); testEmitter({}); - Task.spawn(testPromise) + testPromise() .catch(ok.bind(null, false)) .then(SimpleTest.finish); diff --git a/devtools/shared/tests/unit/test_defer.js b/devtools/shared/tests/unit/test_defer.js index c0babe961893..aa25378465a9 100644 --- a/devtools/shared/tests/unit/test_defer.js +++ b/devtools/shared/tests/unit/test_defer.js @@ -17,13 +17,13 @@ function testReject() { return deferred.promise; } -add_task(function* () { - const success = yield testResolve(); +add_task(async function () { + const success = await testResolve(); equal(success, "success"); let error; try { - yield testReject(); + await testReject(); } catch (e) { error = e; } diff --git a/devtools/shared/tests/unit/test_executeSoon.js b/devtools/shared/tests/unit/test_executeSoon.js index 933b5f2c6f97..1fd5f5db2e6f 100644 --- a/devtools/shared/tests/unit/test_executeSoon.js +++ b/devtools/shared/tests/unit/test_executeSoon.js @@ -21,10 +21,10 @@ registerCleanupFunction(() => { asyncStackEnabled); }); -add_task(function* () { +add_task(async function () { Services.prefs.setBoolPref("javascript.options.asyncstack", true); - yield waitForTick(); + await waitForTick(); let stack = Components.stack; while (stack) { diff --git a/devtools/shared/tests/unit/test_fetch-bom.js b/devtools/shared/tests/unit/test_fetch-bom.js index e1d526eb65be..eb0189fdd9ff 100644 --- a/devtools/shared/tests/unit/test_fetch-bom.js +++ b/devtools/shared/tests/unit/test_fetch-bom.js @@ -61,16 +61,16 @@ registerCleanupFunction(() => { return new Promise(resolve => server.stop(resolve)); }); -add_task(function* () { - yield test_one(serverURL + "/u8", "UTF-8"); - yield test_one(serverURL + "/u16be", "UTF-16BE"); - yield test_one(serverURL + "/u16le", "UTF-16LE"); +add_task(async function () { + await test_one(serverURL + "/u8", "UTF-8"); + await test_one(serverURL + "/u16be", "UTF-16BE"); + await test_one(serverURL + "/u16le", "UTF-16LE"); }); -function* test_one(url, encoding) { +async function test_one(url, encoding) { // Be sure to set the encoding to something that will yield an // invalid result if BOM sniffing is not done. - yield DevToolsUtils.fetch(url, { charset: "ISO-8859-1" }).then(({content}) => { + await DevToolsUtils.fetch(url, { charset: "ISO-8859-1" }).then(({content}) => { Assert.equal(content, "hı", "The content looks correct for " + encoding); }); } diff --git a/devtools/shared/tests/unit/test_fetch-chrome.js b/devtools/shared/tests/unit/test_fetch-chrome.js index f8bc882d20f2..559704a83f08 100644 --- a/devtools/shared/tests/unit/test_fetch-chrome.js +++ b/devtools/shared/tests/unit/test_fetch-chrome.js @@ -11,8 +11,8 @@ const URL_NOT_FOUND = "chrome://this/is/not/here.js"; /** * Test that non-existent files are handled correctly. */ -add_task(function* test_missing() { - yield DevToolsUtils.fetch(URL_NOT_FOUND).then(result => { +add_task(async function test_missing() { + await DevToolsUtils.fetch(URL_NOT_FOUND).then(result => { info(result); ok(false, "fetch resolved unexpectedly for non-existent chrome:// URI"); }, () => { @@ -23,8 +23,8 @@ add_task(function* test_missing() { /** * Tests that existing files are handled correctly. */ -add_task(function* test_normal() { - yield DevToolsUtils.fetch(URL_FOUND).then(result => { +add_task(async function test_normal() { + await DevToolsUtils.fetch(URL_FOUND).then(result => { notDeepEqual(result.content, "", "chrome:// URI seems to be read correctly."); }); diff --git a/devtools/shared/tests/unit/test_fetch-file.js b/devtools/shared/tests/unit/test_fetch-file.js index e70e26b50d74..061a9eb403a0 100644 --- a/devtools/shared/tests/unit/test_fetch-file.js +++ b/devtools/shared/tests/unit/test_fetch-file.js @@ -21,12 +21,12 @@ const ISO_8859_1_BUFFER = new Uint8Array([0x61, 0xe9, 0x64]); * (bug 808960). For example 'resource://gre/modules/XPIProvider.jsm -> * file://l10n.js' should load 'file://l10n.js'. */ -add_task(function* test_arrow_urls() { +add_task(async function test_arrow_urls() { let { path } = createTemporaryFile(".js"); let url = "resource://gre/modules/XPIProvider.jsm -> file://" + path; - yield OS.File.writeAtomic(path, TEST_CONTENT, { encoding: "utf-8" }); - let { content } = yield DevToolsUtils.fetch(url); + await OS.File.writeAtomic(path, TEST_CONTENT, { encoding: "utf-8" }); + let { content } = await DevToolsUtils.fetch(url); deepEqual(content, TEST_CONTENT, "The file contents were correctly read."); }); @@ -34,20 +34,20 @@ add_task(function* test_arrow_urls() { /** * Tests that empty files are read correctly. */ -add_task(function* test_empty() { +add_task(async function test_empty() { let { path } = createTemporaryFile(); - let { content } = yield DevToolsUtils.fetch("file://" + path); + let { content } = await DevToolsUtils.fetch("file://" + path); deepEqual(content, "", "The empty file was read correctly."); }); /** * Tests that UTF-8 encoded files are correctly read. */ -add_task(function* test_encoding_utf8() { +add_task(async function test_encoding_utf8() { let { path } = createTemporaryFile(); - yield OS.File.writeAtomic(path, UTF8_TEST_BUFFER); + await OS.File.writeAtomic(path, UTF8_TEST_BUFFER); - let { content } = yield DevToolsUtils.fetch(path); + let { content } = await DevToolsUtils.fetch(path); deepEqual(content, TEST_CONTENT, "The UTF-8 encoded file was correctly read."); }); @@ -55,11 +55,11 @@ add_task(function* test_encoding_utf8() { /** * Tests that ISO 8859-1 (Latin-1) encoded files are correctly read. */ -add_task(function* test_encoding_iso_8859_1() { +add_task(async function test_encoding_iso_8859_1() { let { path } = createTemporaryFile(); - yield OS.File.writeAtomic(path, ISO_8859_1_BUFFER); + await OS.File.writeAtomic(path, ISO_8859_1_BUFFER); - let { content } = yield DevToolsUtils.fetch(path); + let { content } = await DevToolsUtils.fetch(path); deepEqual(content, TEST_CONTENT, "The ISO 8859-1 encoded file was correctly read."); }); @@ -67,8 +67,8 @@ add_task(function* test_encoding_iso_8859_1() { /** * Test that non-existent files are handled correctly. */ -add_task(function* test_missing() { - yield DevToolsUtils.fetch("file:///file/not/found.right").then(result => { +add_task(async function test_missing() { + await DevToolsUtils.fetch("file:///file/not/found.right").then(result => { info(result); ok(false, "Fetch resolved unexpectedly when the file was not found."); }, () => { @@ -79,12 +79,12 @@ add_task(function* test_missing() { /** * Test that URLs without file:// scheme work. */ -add_task(function* test_schemeless_files() { +add_task(async function test_schemeless_files() { let { path } = createTemporaryFile(); - yield OS.File.writeAtomic(path, TEST_CONTENT, { encoding: "utf-8" }); + await OS.File.writeAtomic(path, TEST_CONTENT, { encoding: "utf-8" }); - let { content } = yield DevToolsUtils.fetch(path); + let { content } = await DevToolsUtils.fetch(path); deepEqual(content, TEST_CONTENT, "The content was correct."); }); diff --git a/devtools/shared/tests/unit/test_fetch-http.js b/devtools/shared/tests/unit/test_fetch-http.js index 7aba27c93adc..365e69411bf8 100644 --- a/devtools/shared/tests/unit/test_fetch-http.js +++ b/devtools/shared/tests/unit/test_fetch-http.js @@ -31,30 +31,30 @@ registerCleanupFunction(() => { return new Promise(resolve => server.stop(resolve)); }); -add_task(function* test_normal() { - yield DevToolsUtils.fetch(NORMAL_URL).then(({content}) => { +add_task(async function test_normal() { + await DevToolsUtils.fetch(NORMAL_URL).then(({content}) => { ok(content.includes("The content looks correct."), "The content looks correct."); }); }); -add_task(function* test_caching() { +add_task(async function test_caching() { let initialContent = null; info("Performing the first request."); - yield DevToolsUtils.fetch(CACHED_URL).then(({content}) => { + await DevToolsUtils.fetch(CACHED_URL).then(({content}) => { info("Got the first response: " + content); initialContent = content; }); info("Performing another request, expecting to get cached response."); - yield DevToolsUtils.fetch(CACHED_URL).then(({content}) => { + await DevToolsUtils.fetch(CACHED_URL).then(({content}) => { deepEqual(content, initialContent, "The content was loaded from cache."); }); info("Performing a third request with cache bypassed."); let opts = { loadFromCache: false }; - yield DevToolsUtils.fetch(CACHED_URL, opts).then(({content}) => { + await DevToolsUtils.fetch(CACHED_URL, opts).then(({content}) => { notDeepEqual(content, initialContent, "The URL wasn't loaded from cache with loadFromCache: false."); }); diff --git a/devtools/shared/tests/unit/test_fetch-resource.js b/devtools/shared/tests/unit/test_fetch-resource.js index bbf25f57c1d1..dd67bbd4ebce 100644 --- a/devtools/shared/tests/unit/test_fetch-resource.js +++ b/devtools/shared/tests/unit/test_fetch-resource.js @@ -11,8 +11,8 @@ const URL_NOT_FOUND = "resource://devtools/this/is/not/here.js"; /** * Test that non-existent files are handled correctly. */ -add_task(function* test_missing() { - yield DevToolsUtils.fetch(URL_NOT_FOUND).then(result => { +add_task(async function test_missing() { + await DevToolsUtils.fetch(URL_NOT_FOUND).then(result => { info(result); ok(false, "fetch resolved unexpectedly for non-existent resource:// URI"); }, () => { @@ -23,8 +23,8 @@ add_task(function* test_missing() { /** * Tests that existing files are handled correctly. */ -add_task(function* test_normal() { - yield DevToolsUtils.fetch(URL_FOUND).then(result => { +add_task(async function test_normal() { + await DevToolsUtils.fetch(URL_FOUND).then(result => { notDeepEqual(result.content, "", "resource:// URI seems to be read correctly."); }); diff --git a/devtools/shared/transport/tests/unit/head_dbg.js b/devtools/shared/transport/tests/unit/head_dbg.js index bf2a03c34d31..40abc45346aa 100644 --- a/devtools/shared/transport/tests/unit/head_dbg.js +++ b/devtools/shared/transport/tests/unit/head_dbg.js @@ -14,7 +14,6 @@ const { require } = const { NetUtil } = require("resource://gre/modules/NetUtil.jsm"); const promise = require("promise"); const defer = require("devtools/shared/defer"); -const { Task } = require("devtools/shared/task"); const Services = require("Services"); @@ -130,7 +129,7 @@ function writeTestTempFile(fileName, content) { /** * Transport Factories ***/ -var socket_transport = Task.async(function* () { +var socket_transport = async function () { if (!DebuggerServer.listeningSockets) { let AuthenticatorType = DebuggerServer.Authenticators.get("PROMPT"); let authenticator = new AuthenticatorType.Server(); @@ -140,12 +139,12 @@ var socket_transport = Task.async(function* () { let debuggerListener = DebuggerServer.createListener(); debuggerListener.portOrPath = -1; debuggerListener.authenticator = authenticator; - yield debuggerListener.open(); + await debuggerListener.open(); } let port = DebuggerServer._listeners[0].port; info("Debugger server port is " + port); return DebuggerClient.socketConnect({ host: "127.0.0.1", port }); -}); +}; function local_transport() { return promise.resolve(DebuggerServer.connectPipe()); diff --git a/devtools/shared/transport/tests/unit/test_bulk_error.js b/devtools/shared/transport/tests/unit/test_bulk_error.js index 74772735defb..4c1ad7d1dfaf 100644 --- a/devtools/shared/transport/tests/unit/test_bulk_error.js +++ b/devtools/shared/transport/tests/unit/test_bulk_error.js @@ -7,9 +7,9 @@ function run_test() { initTestDebuggerServer(); add_test_bulk_actor(); - add_task(function* () { - yield test_string_error(socket_transport, json_reply); - yield test_string_error(local_transport, json_reply); + add_task(async function () { + await test_string_error(socket_transport, json_reply); + await test_string_error(local_transport, json_reply); DebuggerServer.destroy(); }); @@ -44,8 +44,8 @@ function add_test_bulk_actor() { /** * Tests ***/ -var test_string_error = Task.async(function* (transportFactory, onReady) { - let transport = yield transportFactory(); +var test_string_error = async function (transportFactory, onReady) { + let transport = await transportFactory(); let client = new DebuggerClient(transport); return client.connect().then(([app, traits]) => { @@ -57,7 +57,7 @@ var test_string_error = Task.async(function* (transportFactory, onReady) { client.close(); transport.close(); }); -}); +}; /** * Reply Types ***/ diff --git a/devtools/shared/transport/tests/unit/test_client_server_bulk.js b/devtools/shared/transport/tests/unit/test_client_server_bulk.js index a13f6dca0b0b..c601b2649425 100644 --- a/devtools/shared/transport/tests/unit/test_client_server_bulk.js +++ b/devtools/shared/transport/tests/unit/test_client_server_bulk.js @@ -10,13 +10,13 @@ function run_test() { initTestDebuggerServer(); add_test_bulk_actor(); - add_task(function* () { - yield test_bulk_request_cs(socket_transport, "jsonReply", "json"); - yield test_bulk_request_cs(local_transport, "jsonReply", "json"); - yield test_bulk_request_cs(socket_transport, "bulkEcho", "bulk"); - yield test_bulk_request_cs(local_transport, "bulkEcho", "bulk"); - yield test_json_request_cs(socket_transport, "bulkReply", "bulk"); - yield test_json_request_cs(local_transport, "bulkReply", "bulk"); + add_task(async function () { + await test_bulk_request_cs(socket_transport, "jsonReply", "json"); + await test_bulk_request_cs(local_transport, "jsonReply", "json"); + await test_bulk_request_cs(socket_transport, "bulkEcho", "bulk"); + await test_bulk_request_cs(local_transport, "bulkEcho", "bulk"); + await test_json_request_cs(socket_transport, "bulkReply", "bulk"); + await test_json_request_cs(local_transport, "bulkReply", "bulk"); DebuggerServer.destroy(); }); @@ -133,7 +133,7 @@ var replyHandlers = { /** * Tests ***/ -var test_bulk_request_cs = Task.async(function* (transportFactory, actorType, replyType) { +var test_bulk_request_cs = async function (transportFactory, actorType, replyType) { // Ensure test files are not present from a failed run cleanup_files(); writeTestTempFile("bulk-input", really_long()); @@ -142,7 +142,7 @@ var test_bulk_request_cs = Task.async(function* (transportFactory, actorType, re let serverDeferred = defer(); let bulkCopyDeferred = defer(); - let transport = yield transportFactory(); + let transport = await transportFactory(); let client = new DebuggerClient(transport); client.connect().then(([app, traits]) => { @@ -190,9 +190,9 @@ var test_bulk_request_cs = Task.async(function* (transportFactory, actorType, re bulkCopyDeferred.promise, serverDeferred.promise ]); -}); +}; -var test_json_request_cs = Task.async(function* (transportFactory, actorType, replyType) { +var test_json_request_cs = async function (transportFactory, actorType, replyType) { // Ensure test files are not present from a failed run cleanup_files(); writeTestTempFile("bulk-input", really_long()); @@ -200,7 +200,7 @@ var test_json_request_cs = Task.async(function* (transportFactory, actorType, re let clientDeferred = defer(); let serverDeferred = defer(); - let transport = yield transportFactory(); + let transport = await transportFactory(); let client = new DebuggerClient(transport); client.connect((app, traits) => { @@ -231,7 +231,7 @@ var test_json_request_cs = Task.async(function* (transportFactory, actorType, re clientDeferred.promise, serverDeferred.promise ]); -}); +}; /** * Test Utils ***/ diff --git a/devtools/shared/transport/tests/unit/test_dbgsocket.js b/devtools/shared/transport/tests/unit/test_dbgsocket.js index 0331a7645d92..6a2b8b523b11 100644 --- a/devtools/shared/transport/tests/unit/test_dbgsocket.js +++ b/devtools/shared/transport/tests/unit/test_dbgsocket.js @@ -16,7 +16,7 @@ function run_test() { run_next_test(); } -function* test_socket_conn() { +async function test_socket_conn() { Assert.equal(DebuggerServer.listeningSockets, 0); let AuthenticatorType = DebuggerServer.Authenticators.get("PROMPT"); let authenticator = new AuthenticatorType.Server(); @@ -40,7 +40,7 @@ function* test_socket_conn() { info("Starting long and unicode tests at " + new Date().toTimeString()); let unicodeString = "(╯°□°)╯︵ ┻━┻"; - let transport = yield DebuggerClient.socketConnect({ + let transport = await DebuggerClient.socketConnect({ host: "127.0.0.1", port: gPort }); @@ -73,7 +73,7 @@ function* test_socket_conn() { return closedDeferred.promise; } -function* test_socket_shutdown() { +async function test_socket_shutdown() { Assert.equal(DebuggerServer.listeningSockets, 2); gExtraListener.close(); Assert.equal(DebuggerServer.listeningSockets, 1); @@ -85,7 +85,7 @@ function* test_socket_shutdown() { info("Connecting to a server socket at " + new Date().toTimeString()); try { - yield DebuggerClient.socketConnect({ + await DebuggerClient.socketConnect({ host: "127.0.0.1", port: gPort }); diff --git a/devtools/shared/transport/tests/unit/test_dbgsocket_connection_drop.js b/devtools/shared/transport/tests/unit/test_dbgsocket_connection_drop.js index 35178f464fc9..7755f30fe689 100644 --- a/devtools/shared/transport/tests/unit/test_dbgsocket_connection_drop.js +++ b/devtools/shared/transport/tests/unit/test_dbgsocket_connection_drop.js @@ -44,7 +44,7 @@ function test_socket_conn_drops_after_too_long_header() { return test_helper(rawPacket + ":"); } -var test_helper = Task.async(function* (payload) { +var test_helper = async function (payload) { let AuthenticatorType = DebuggerServer.Authenticators.get("PROMPT"); let authenticator = new AuthenticatorType.Server(); authenticator.allowConnection = () => { @@ -56,7 +56,7 @@ var test_helper = Task.async(function* (payload) { listener.authenticator = authenticator; listener.open(); - let transport = yield DebuggerClient.socketConnect({ + let transport = await DebuggerClient.socketConnect({ host: "127.0.0.1", port: listener.port }); @@ -79,4 +79,4 @@ var test_helper = Task.async(function* (payload) { }; transport.ready(); return closedDeferred.promise; -}); +}; diff --git a/devtools/shared/transport/tests/unit/test_delimited_read.js b/devtools/shared/transport/tests/unit/test_delimited_read.js index aec21741f392..ead13341da30 100644 --- a/devtools/shared/transport/tests/unit/test_delimited_read.js +++ b/devtools/shared/transport/tests/unit/test_delimited_read.js @@ -8,11 +8,11 @@ const StringInputStream = CC("@mozilla.org/io/string-input-stream;1", "nsIStringInputStream", "setData"); function run_test() { - add_task(function* () { - yield test_delimited_read("0123:", "0123:"); - yield test_delimited_read("0123:4567:", "0123:"); - yield test_delimited_read("012345678901:", "0123456789"); - yield test_delimited_read("0123/0123", "0123/0123"); + add_task(async function () { + await test_delimited_read("0123:", "0123:"); + await test_delimited_read("0123:4567:", "0123:"); + await test_delimited_read("012345678901:", "0123456789"); + await test_delimited_read("0123/0123", "0123/0123"); }); run_next_test(); diff --git a/devtools/shared/transport/tests/unit/test_no_bulk.js b/devtools/shared/transport/tests/unit/test_no_bulk.js index 480ffa02cf8a..f238f271b8e2 100644 --- a/devtools/shared/transport/tests/unit/test_no_bulk.js +++ b/devtools/shared/transport/tests/unit/test_no_bulk.js @@ -8,9 +8,9 @@ function run_test() { // Allow incoming connections. DebuggerServer.init(); - add_task(function* () { - yield test_bulk_send_error(socket_transport); - yield test_bulk_send_error(local_transport); + add_task(async function () { + await test_bulk_send_error(socket_transport); + await test_bulk_send_error(local_transport); DebuggerServer.destroy(); }); @@ -19,8 +19,8 @@ function run_test() { /** * Tests ***/ -var test_bulk_send_error = Task.async(function* (transportFactory) { - let transport = yield transportFactory(); +var test_bulk_send_error = async function (transportFactory) { + let transport = await transportFactory(); let client = new DebuggerClient(transport); return client.connect().then(([app, traits]) => { @@ -33,4 +33,4 @@ var test_bulk_send_error = Task.async(function* (transportFactory) { Assert.ok(true); } }); -}); +}; diff --git a/devtools/shared/transport/tests/unit/test_queue.js b/devtools/shared/transport/tests/unit/test_queue.js index dee77156bd45..bf406713c6d6 100644 --- a/devtools/shared/transport/tests/unit/test_queue.js +++ b/devtools/shared/transport/tests/unit/test_queue.js @@ -13,9 +13,9 @@ var { FileUtils } = ChromeUtils.import("resource://gre/modules/FileUtils.jsm", { function run_test() { initTestDebuggerServer(); - add_task(function* () { - yield test_transport(socket_transport); - yield test_transport(local_transport); + add_task(async function () { + await test_transport(socket_transport); + await test_transport(local_transport); DebuggerServer.destroy(); }); @@ -24,7 +24,7 @@ function run_test() { /** * Tests ***/ -var test_transport = Task.async(function* (transportFactory) { +var test_transport = async function (transportFactory) { let clientDeferred = defer(); let serverDeferred = defer(); @@ -35,7 +35,7 @@ var test_transport = Task.async(function* (transportFactory) { Assert.equal(Object.keys(DebuggerServer._connections).length, 0); - let transport = yield transportFactory(); + let transport = await transportFactory(); // Sending from client to server function write_data({copyFrom}) { @@ -135,7 +135,7 @@ var test_transport = Task.async(function* (transportFactory) { transport.ready(); return promise.all([clientDeferred.promise, serverDeferred.promise]); -}); +}; /** * Test Utils ***/ diff --git a/devtools/shared/transport/tests/unit/test_transport_bulk.js b/devtools/shared/transport/tests/unit/test_transport_bulk.js index eccecbe7379e..c063b5468c56 100644 --- a/devtools/shared/transport/tests/unit/test_transport_bulk.js +++ b/devtools/shared/transport/tests/unit/test_transport_bulk.js @@ -8,9 +8,9 @@ var { FileUtils } = ChromeUtils.import("resource://gre/modules/FileUtils.jsm", { function run_test() { initTestDebuggerServer(); - add_task(function* () { - yield test_bulk_transfer_transport(socket_transport); - yield test_bulk_transfer_transport(local_transport); + add_task(async function () { + await test_bulk_transfer_transport(socket_transport); + await test_bulk_transfer_transport(local_transport); DebuggerServer.destroy(); }); @@ -22,7 +22,7 @@ function run_test() { /** * This tests a one-way bulk transfer at the transport layer. */ -var test_bulk_transfer_transport = Task.async(function* (transportFactory) { +var test_bulk_transfer_transport = async function (transportFactory) { info("Starting bulk transfer test at " + new Date().toTimeString()); let clientDeferred = defer(); @@ -35,7 +35,7 @@ var test_bulk_transfer_transport = Task.async(function* (transportFactory) { Assert.equal(Object.keys(DebuggerServer._connections).length, 0); - let transport = yield transportFactory(); + let transport = await transportFactory(); // Sending from client to server function write_data({copyFrom}) { @@ -106,7 +106,7 @@ var test_bulk_transfer_transport = Task.async(function* (transportFactory) { transport.ready(); return promise.all([clientDeferred.promise, serverDeferred.promise]); -}); +}; /** * Test Utils ***/ diff --git a/devtools/shared/transport/tests/unit/test_transport_events.js b/devtools/shared/transport/tests/unit/test_transport_events.js index 30d898ee01ca..93c99a884db3 100644 --- a/devtools/shared/transport/tests/unit/test_transport_events.js +++ b/devtools/shared/transport/tests/unit/test_transport_events.js @@ -6,21 +6,21 @@ function run_test() { initTestDebuggerServer(); - add_task(function* () { - yield test_transport_events("socket", socket_transport); - yield test_transport_events("local", local_transport); + add_task(async function () { + await test_transport_events("socket", socket_transport); + await test_transport_events("local", local_transport); DebuggerServer.destroy(); }); run_next_test(); } -function* test_transport_events(name, transportFactory) { +async function test_transport_events(name, transportFactory) { info(`Started testing of transport: ${name}`); Assert.equal(Object.keys(DebuggerServer._connections).length, 0); - let transport = yield transportFactory(); + let transport = await transportFactory(); // Transport expects the hooks to be not null transport.hooks = { @@ -35,7 +35,7 @@ function* test_transport_events(name, transportFactory) { }); transport.ready(); - yield rootReceived; + await rootReceived; let echoSent = transport.once("send", (event, packet) => { info(`Send event: ${event} ${JSON.stringify(packet)}`); @@ -52,8 +52,8 @@ function* test_transport_events(name, transportFactory) { }); transport.send({ to: "root", type: "echo" }); - yield echoSent; - yield echoReceived; + await echoSent; + await echoReceived; let clientClosed = transport.once("close", (event) => { info(`Close event: ${event}`); @@ -68,8 +68,8 @@ function* test_transport_events(name, transportFactory) { transport.close(); - yield clientClosed; - yield serverClosed; + await clientClosed; + await serverClosed; info(`Finished testing of transport: ${name}`); } diff --git a/devtools/shared/webconsole/test/common.js b/devtools/shared/webconsole/test/common.js index 7a060b3ef85b..f2521c9eed96 100644 --- a/devtools/shared/webconsole/test/common.js +++ b/devtools/shared/webconsole/test/common.js @@ -13,7 +13,6 @@ // This gives logging to stdout for tests const {console} = ChromeUtils.import("resource://gre/modules/Console.jsm", {}); const {require} = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {}); -const {Task} = require("devtools/shared/task"); const {DebuggerServer} = require("devtools/server/main"); const {DebuggerClient} = require("devtools/shared/client/debugger-client"); const ObjectClient = require("devtools/shared/client/object-client"); @@ -52,7 +51,7 @@ function attachConsoleToWorker(listeners, callback) { _attachConsole(listeners, callback, true, true); } -var _attachConsole = Task.async(function* ( +var _attachConsole = async function ( listeners, callback, attachToTab, attachToWorker ) { function _onAttachConsole(state, response, webConsoleClient) { @@ -72,7 +71,7 @@ var _attachConsole = Task.async(function* ( }); } - let [state, response] = yield connectToDebugger(); + let [state, response] = await connectToDebugger(); if (response.error) { console.error("client.connect() failed: " + response.error + " " + response.message); @@ -81,15 +80,15 @@ var _attachConsole = Task.async(function* ( } if (!attachToTab) { - response = yield state.dbgClient.getProcess(); - yield state.dbgClient.attachTab(response.form.actor); + response = await state.dbgClient.getProcess(); + await state.dbgClient.attachTab(response.form.actor); let consoleActor = response.form.consoleActor; state.actor = consoleActor; state.dbgClient.attachConsole(consoleActor, listeners, _onAttachConsole.bind(null, state)); return; } - response = yield state.dbgClient.listTabs(); + response = await state.dbgClient.listTabs(); if (response.error) { console.error("listTabs failed: " + response.error + " " + response.message); @@ -97,7 +96,7 @@ var _attachConsole = Task.async(function* ( return; } let tab = response.tabs[response.selected]; - let [, tabClient] = yield state.dbgClient.attachTab(tab.actor); + let [, tabClient] = await state.dbgClient.attachTab(tab.actor); if (attachToWorker) { let workerName = "console-test-worker.js#" + new Date().getTime(); let worker = new Worker(workerName); @@ -105,22 +104,22 @@ var _attachConsole = Task.async(function* ( // GCd during the test (bug 1237492). // eslint-disable-next-line camelcase state._worker_ref = worker; - yield waitForMessage(worker); + await waitForMessage(worker); - let { workers } = yield tabClient.listWorkers(); + let { workers } = await tabClient.listWorkers(); let workerActor = workers.filter(w => w.url == workerName)[0].actor; if (!workerActor) { console.error("listWorkers failed. Unable to find the " + "worker actor\n"); return; } - let [workerResponse, workerClient] = yield tabClient.attachWorker(workerActor); + let [workerResponse, workerClient] = await tabClient.attachWorker(workerActor); if (!workerClient || workerResponse.error) { console.error("attachWorker failed. No worker client or " + " error: " + workerResponse.error); return; } - yield workerClient.attachThread({}); + await workerClient.attachThread({}); state.actor = workerClient.consoleActor; state.dbgClient.attachConsole(workerClient.consoleActor, listeners, _onAttachConsole.bind(null, state)); @@ -129,7 +128,7 @@ var _attachConsole = Task.async(function* ( state.dbgClient.attachConsole(tab.consoleActor, listeners, _onAttachConsole.bind(null, state)); } -}); +}; function closeDebugger(state, callback) { state.dbgClient.close().then(callback); diff --git a/devtools/shared/webconsole/test/test_commands_other.html b/devtools/shared/webconsole/test/test_commands_other.html index 94f9a61f212c..a1f35d55620f 100644 --- a/devtools/shared/webconsole/test/test_commands_other.html +++ b/devtools/shared/webconsole/test/test_commands_other.html @@ -35,8 +35,8 @@ function startTest() { } tests = [ - Task.async(function* keys() { - let response = yield evaluateJS("keys({foo: 'bar'})"); + async function keys() { + let response = await evaluateJS("keys({foo: 'bar'})"); checkObject(response, { from: gState.actor, result: { @@ -47,9 +47,9 @@ tests = [ } }); nextTest(); - }), - Task.async(function* values() { - let response = yield evaluateJS("values({foo: 'bar'})"); + }, + async function values() { + let response = await evaluateJS("values({foo: 'bar'})"); checkObject(response, { from: gState.actor, result: { @@ -60,7 +60,7 @@ tests = [ } }); nextTest(); - }), + }, ]; function testEnd() { @@ -72,10 +72,10 @@ function testEnd() { }); } -let load = Task.async(function*() { +let load = async function () { removeEventListener("load", load); - yield new Promise(resolve => { + await new Promise(resolve => { SpecialPowers.pushPrefEnv({"set": [ ["security.data_uri.unique_opaque_origin", false], ]}, resolve); @@ -85,7 +85,7 @@ let load = Task.async(function*() { gWin = window.open("data:text/html,"); info ("Waiting for content window to load"); gWin.onload = startTest; -}); +}; addEventListener("load", load); diff --git a/devtools/shared/webconsole/test/test_commands_registration.html b/devtools/shared/webconsole/test/test_commands_registration.html index 364de6c6fc04..27428bc51a10 100644 --- a/devtools/shared/webconsole/test/test_commands_registration.html +++ b/devtools/shared/webconsole/test/test_commands_registration.html @@ -24,8 +24,8 @@ function evaluateJS(input) { return new Promise((resolve) => gState.client.evaluateJS(input, resolve)); } -function* evaluateJSAndCheckResult(input, result) { - let response = yield evaluateJS(input); +async function evaluateJSAndCheckResult(input, result) { + let response = await evaluateJS(input); checkObject(response, {result}); } @@ -44,7 +44,7 @@ function onAttach(aState, aResponse) } tests = [ - Task.async(function* registerNewCommand() { + async function registerNewCommand() { let win; WebConsoleCommands.register("setFoo", (owner, value) => { owner.window.foo = value; @@ -55,7 +55,7 @@ tests = [ "The command should be registered"); let command = "setFoo('bar')"; - let response = yield evaluateJS(command); + let response = await evaluateJS(command); checkObject(response, { from: gState.actor, @@ -64,9 +64,9 @@ tests = [ }); is(top.foo, "bar", "top.foo should equal to 'bar'"); nextTest(); - }), + }, - Task.async(function* wrapCommand() { + async function wrapCommand() { let origKeys = WebConsoleCommands.getCommand("keys"); let newKeys = (...args) => { @@ -83,13 +83,13 @@ tests = [ is(WebConsoleCommands.getCommand("keys"), newKeys, "the keys() command should have been replaced"); - let response = yield evaluateJS("keys('>o_/')"); + let response = await evaluateJS("keys('>o_/')"); checkObject(response, { from: gState.actor, result: "bang!" }); - response = yield evaluateJS("keys({foo: 'bar'})"); + response = await evaluateJS("keys({foo: 'bar'})"); checkObject(response, { from: gState.actor, result: { @@ -104,12 +104,12 @@ tests = [ is(WebConsoleCommands.getCommand("keys"), origKeys, "the keys() command should be restored"); nextTest(); - }), + }, - Task.async(function* unregisterCommand() { + async function unregisterCommand() { WebConsoleCommands.unregister("setFoo"); - let response = yield evaluateJS("setFoo"); + let response = await evaluateJS("setFoo"); checkObject(response, { from: gState.actor, @@ -120,9 +120,9 @@ tests = [ exceptionMessage: /setFoo is not defined/ }); nextTest(); - }), + }, - Task.async(function* registerAccessor() { + async function registerAccessor() { WebConsoleCommands.register("$foo", { get(owner) { let foo = owner.window.frames[0].window.document.getElementById("quack"); @@ -130,7 +130,7 @@ tests = [ } }); let command = "$foo.textContent = '>o_/'"; - let response = yield evaluateJS(command); + let response = await evaluateJS(command); checkObject(response, { from: gState.actor, @@ -142,12 +142,12 @@ tests = [ WebConsoleCommands.unregister("$foo"); ok(!WebConsoleCommands.hasCommand("$foo"), "$foo should be unregistered"); nextTest(); - }), + }, - Task.async(function* unregisterAfterOverridingTwice() { + async function unregisterAfterOverridingTwice() { WebConsoleCommands.register("keys", (owner, obj) => "command 1"); info("checking the value of the first override"); - yield evaluateJSAndCheckResult("keys('foo');", "command 1"); + await evaluateJSAndCheckResult("keys('foo');", "command 1"); let orig = WebConsoleCommands.getCommand("keys"); WebConsoleCommands.register("keys", (owner, obj) => { @@ -157,20 +157,20 @@ tests = [ }); info("checking the values after the second override"); - yield evaluateJSAndCheckResult("keys({});", "command 1"); - yield evaluateJSAndCheckResult("keys('quack');", "bang!"); + await evaluateJSAndCheckResult("keys({});", "command 1"); + await evaluateJSAndCheckResult("keys('quack');", "bang!"); WebConsoleCommands.unregister("keys"); info("checking the value after unregistration (should restore " + "the original command)"); - yield evaluateJSAndCheckResult("keys({});", { + await evaluateJSAndCheckResult("keys({});", { class: "Array", preview: {items: []} }); nextTest(); - }) + } ]; function testEnd() diff --git a/devtools/shared/webconsole/test/test_console_serviceworker.html b/devtools/shared/webconsole/test/test_console_serviceworker.html index 011f7a111e75..7e89c7975dc8 100644 --- a/devtools/shared/webconsole/test/test_console_serviceworker.html +++ b/devtools/shared/webconsole/test/test_console_serviceworker.html @@ -100,10 +100,10 @@ let expectedConsoleCalls = [ ]; let consoleCalls = []; -let startTest = Task.async(function*() { +let startTest = async function () { removeEventListener("load", startTest); - yield new Promise(resolve => { + await new Promise(resolve => { SpecialPowers.pushPrefEnv({"set": [ ["dom.serviceWorkers.enabled", true], ["devtools.webconsole.filter.serviceworkers", true] @@ -111,10 +111,10 @@ let startTest = Task.async(function*() { }); attachConsoleToTab(["ConsoleAPI"], onAttach); -}); +}; addEventListener("load", startTest); -let onAttach = Task.async(function*(state, response) { +let onAttach = async function (state, response) { onConsoleAPICall = onConsoleAPICall.bind(null, state); state.dbgClient.addListener("consoleAPICall", onConsoleAPICall); @@ -123,7 +123,7 @@ let onAttach = Task.async(function*(state, response) { // First, we need a frame from which to register our script. This // will not trigger any console calls. info("Loading a non-scope frame from which to register a service worker."); - currentFrame = yield withFrame(NONSCOPE_FRAME_URL); + currentFrame = await withFrame(NONSCOPE_FRAME_URL); // Now register the service worker and wait for it to become // activate. This should trigger 3 console calls; 1 for script @@ -131,7 +131,7 @@ let onAttach = Task.async(function*(state, response) { // event. These console calls are received because we called // register(), not because we are in scope for the worker. info("Registering the service worker"); - yield withActiveServiceWorker(currentFrame.contentWindow, + await withActiveServiceWorker(currentFrame.contentWindow, SERVICE_WORKER_URL, SCOPE); ok(!currentFrame.contentWindow.navigator.serviceWorker.controller, 'current frame should not be controlled'); @@ -139,14 +139,14 @@ let onAttach = Task.async(function*(state, response) { // Now that the service worker is activate, lets navigate our frame. // This will trigger 1 more console call for the fetch event. info("Service worker registered. Navigating frame."); - yield navigateFrame(currentFrame, SCOPE_FRAME_URL); + await navigateFrame(currentFrame, SCOPE_FRAME_URL); ok(currentFrame.contentWindow.navigator.serviceWorker.controller, 'navigated frame should be controlled'); // We now have a controlled frame. Lets perform a non-navigation fetch. // This should produce another console call for the fetch event. info("Frame navigated. Calling fetch()."); - yield currentFrame.contentWindow.fetch(SCOPE_FRAME_URL2); + await currentFrame.contentWindow.fetch(SCOPE_FRAME_URL2); // Now force refresh our controlled frame. This will cause the frame // to bypass the service worker and become an uncontrolled frame. It @@ -156,7 +156,7 @@ let onAttach = Task.async(function*(state, response) { // that matches our service worker scope so we can provide its not // incorrectly getting console calls. info("Completed fetch(). Force refreshing to get uncontrolled frame."); - yield forceReloadFrame(currentFrame); + await forceReloadFrame(currentFrame); ok(!currentFrame.contentWindow.navigator.serviceWorker.controller, 'current frame should not be controlled after force refresh'); is(currentFrame.contentWindow.location.toString(), SCOPE_FRAME_URL, @@ -168,10 +168,10 @@ let onAttach = Task.async(function*(state, response) { // case, though, we should not get any console calls because we don't // have a controlled or registering document. info("Completed force refresh. Messaging service worker."); - yield messageServiceWorker(currentFrame.contentWindow, SCOPE, MESSAGE); + await messageServiceWorker(currentFrame.contentWindow, SCOPE, MESSAGE); info("Done messaging service worker. Unregistering service worker."); - yield unregisterServiceWorker(currentFrame.contentWindow); + await unregisterServiceWorker(currentFrame.contentWindow); info('Service worker unregistered. Checking console calls.'); state.dbgClient.removeListener("consoleAPICall", onConsoleAPICall); @@ -188,7 +188,7 @@ let onAttach = Task.async(function*(state, response) { SimpleTest.finish(); }); } -}); +}; function onConsoleAPICall(state, type, packet) { info("received message level: " + packet.message.level); diff --git a/devtools/shared/webconsole/test/test_console_serviceworker_cached.html b/devtools/shared/webconsole/test/test_console_serviceworker_cached.html index 43ff727a695a..3f5cae60e22d 100644 --- a/devtools/shared/webconsole/test/test_console_serviceworker_cached.html +++ b/devtools/shared/webconsole/test/test_console_serviceworker_cached.html @@ -44,10 +44,10 @@ let secondTabExpectedCalls = [ } ]; -let startTest = Task.async(function*() { +let startTest = async function () { removeEventListener("load", startTest); - yield new Promise(resolve => { + await new Promise(resolve => { SpecialPowers.pushPrefEnv({"set": [ ["dom.serviceWorkers.enabled", true], ["devtools.webconsole.filter.serviceworkers", true] @@ -55,11 +55,11 @@ let startTest = Task.async(function*() { }); info("Adding a tab and attaching a service worker"); - let tab1 = yield addTab(FRAME_URL); - let swr = yield withActiveServiceWorker(tab1.linkedBrowser.contentWindow, + let tab1 = await addTab(FRAME_URL); + let swr = await withActiveServiceWorker(tab1.linkedBrowser.contentWindow, SERVICE_WORKER_URL); - yield new Promise(resolve => { + await new Promise(resolve => { info("Attaching console to tab 1"); attachConsoleToTab(["ConsoleAPI"], function(state) { state.client.getCachedMessages(["ConsoleAPI"], function(calls) { @@ -73,8 +73,8 @@ let startTest = Task.async(function*() { // they shouldn't show up in a call to getCachedMessages. // However, there is a fetch event which is logged due to loading the tab. info("Adding a new tab at the same URL"); - let tab2 = yield addTab(FRAME_URL); - yield new Promise(resolve => { + let tab2 = await addTab(FRAME_URL); + await new Promise(resolve => { info("Attaching console to tab 2"); attachConsoleToTab(["ConsoleAPI"], function(state) { state.client.getCachedMessages(["ConsoleAPI"], function(calls) { @@ -84,10 +84,10 @@ let startTest = Task.async(function*() { }); }); - yield swr.unregister(); + await swr.unregister(); SimpleTest.finish(); -}); +}; addEventListener("load", startTest); // This test needs to add tabs that are controlled by a service worker diff --git a/devtools/shared/webconsole/test/test_console_worker.html b/devtools/shared/webconsole/test/test_console_worker.html index ff1195b21ec5..d11a5387b200 100644 --- a/devtools/shared/webconsole/test/test_console_worker.html +++ b/devtools/shared/webconsole/test/test_console_worker.html @@ -29,22 +29,22 @@ let expectedConsoleAPICalls = [ }, ]; -window.onload = Task.async(function*() { - let {state,response} = yield new Promise(resolve => { +window.onload = async function () { + let {state,response} = await new Promise(resolve => { attachConsoleToWorker(["ConsoleAPI"], (state, response) => { resolve({state,response}) }); }); - yield testCachedMessages(state); - yield testConsoleAPI(state); + await testCachedMessages(state); + await testConsoleAPI(state); closeDebugger(state, function() { SimpleTest.finish(); }); -}); +}; -let testCachedMessages = Task.async(function*(state) { +let testCachedMessages = async function (state) { info("testCachedMessages entered"); return new Promise(resolve => { let onCachedConsoleAPI = (response) => { @@ -56,9 +56,9 @@ let testCachedMessages = Task.async(function*(state) { }; state.client.getCachedMessages(["ConsoleAPI"], onCachedConsoleAPI); }) -}); +}; -let testConsoleAPI = Task.async(function*(state) { +let testConsoleAPI = async function (state) { info("testConsoleAPI entered"); return new Promise(resolve => { let onConsoleAPICall = (type, packet) => { @@ -75,7 +75,7 @@ let testConsoleAPI = Task.async(function*(state) { state.client.evaluateJS("console.log('Log was requested from worker')", () => { }); }); -}); +}; diff --git a/devtools/shared/webconsole/test/test_jsterm.html b/devtools/shared/webconsole/test/test_jsterm.html index 90babf9636ad..1796b107cadb 100644 --- a/devtools/shared/webconsole/test/test_jsterm.html +++ b/devtools/shared/webconsole/test/test_jsterm.html @@ -65,16 +65,14 @@ function onAttach(aState, aResponse) let tests = [doSimpleEval, doWindowEval, doEvalWithException, doEvalWithHelper, doEvalString, doEvalLongString, doEvalWithBinding, doEvalWithBindingFrame, - forceLexicalInit].map(t => { - return Task.async(t); - }); + forceLexicalInit]; runTests(tests, testEnd); } -function* doSimpleEval() { +async function doSimpleEval() { info("test eval '2+2'"); - let response = yield evaluateJS("2+2"); + let response = await evaluateJS("2+2"); checkObject(response, { from: gState.actor, input: "2+2", @@ -87,9 +85,9 @@ function* doSimpleEval() { nextTest(); } -function* doWindowEval() { +async function doWindowEval() { info("test eval 'document'"); - let response = yield evaluateJS("document"); + let response = await evaluateJS("document"); checkObject(response, { from: gState.actor, input: "document", @@ -106,9 +104,9 @@ function* doWindowEval() { nextTest(); } -function* doEvalWithException() { +async function doEvalWithException() { info("test eval with exception"); - let response = yield evaluateJS("window.doTheImpossible()"); + let response = await evaluateJS("window.doTheImpossible()"); checkObject(response, { from: gState.actor, input: "window.doTheImpossible()", @@ -124,9 +122,9 @@ function* doEvalWithException() { nextTest(); } -function* doEvalWithHelper() { +async function doEvalWithHelper() { info("test eval with helper"); - let response = yield evaluateJS("clear()"); + let response = await evaluateJS("clear()"); checkObject(response, { from: gState.actor, input: "clear()", @@ -141,8 +139,8 @@ function* doEvalWithHelper() { nextTest(); } -function* doEvalString() { - let response = yield evaluateJS("window.foobarObject.strfoo"); +async function doEvalString() { + let response = await evaluateJS("window.foobarObject.strfoo"); checkObject(response, { from: gState.actor, input: "window.foobarObject.strfoo", @@ -152,8 +150,8 @@ function* doEvalString() { nextTest(); } -function* doEvalLongString() { - let response = yield evaluateJS("window.foobarObject.omgstr"); +async function doEvalLongString() { + let response = await evaluateJS("window.foobarObject.omgstr"); let str = top.foobarObject.omgstr; let initial = str.substring(0, DebuggerServer.LONG_STRING_INITIAL_LENGTH); @@ -170,12 +168,12 @@ function* doEvalLongString() { nextTest(); } -function* doEvalWithBinding() { - let response = yield evaluateJS("document;"); +async function doEvalWithBinding() { + let response = await evaluateJS("document;"); let documentActor = response.result.actor; info("running a command with _self as document using bindObjectActor"); - let bindObjectSame = yield evaluateJS("_self === document", { + let bindObjectSame = await evaluateJS("_self === document", { bindObjectActor: documentActor }); checkObject(bindObjectSame, { @@ -183,7 +181,7 @@ function* doEvalWithBinding() { }); info("running a command with _self as document using selectedObjectActor"); - let selectedObjectSame = yield evaluateJS("_self === document", { + let selectedObjectSame = await evaluateJS("_self === document", { selectedObjectActor: documentActor }); checkObject(selectedObjectSame, { @@ -193,17 +191,17 @@ function* doEvalWithBinding() { nextTest(); } -function* doEvalWithBindingFrame() { +async function doEvalWithBindingFrame() { let frameWin = top.document.querySelector("iframe").contentWindow; frameWin.fooFrame = { bar: 1 }; - let response = yield evaluateJS( + let response = await evaluateJS( "document.querySelector('iframe').contentWindow.fooFrame" ); let iframeObjectActor = response.result.actor; ok(iframeObjectActor, "There is an actor associated with the response"); - let bindObjectGlobal = yield evaluateJS("this.temp0 = _self;", { + let bindObjectGlobal = await evaluateJS("this.temp0 = _self;", { bindObjectActor: iframeObjectActor }); ok(!top.temp0, @@ -211,7 +209,7 @@ function* doEvalWithBindingFrame() { ok(frameWin.temp0 && frameWin.temp0.bar === 1, "Global matches the object's global with bindObjectActor"); - let selectedObjectGlobal = yield evaluateJS("this.temp1 = _self;", { + let selectedObjectGlobal = await evaluateJS("this.temp1 = _self;", { selectedObjectActor: iframeObjectActor }); ok(top.temp1 && top.temp1.bar === 1, @@ -222,7 +220,7 @@ function* doEvalWithBindingFrame() { nextTest() } -function* forceLexicalInit() { +async function forceLexicalInit() { info("test that failed let/const bindings are initialized to undefined"); const testData = [ @@ -265,7 +263,7 @@ function* forceLexicalInit() { ]; for (let data of testData) { - let response = yield evaluateJS(data.stmt); + let response = await evaluateJS(data.stmt); checkObject(response, { from: gState.actor, input: data.stmt, @@ -273,7 +271,7 @@ function* forceLexicalInit() { }); ok(response.exception, "expected exception"); for (let varName of data.vars) { - let response2 = yield evaluateJS(varName); + let response2 = await evaluateJS(varName); checkObject(response2, { from: gState.actor, input: varName, diff --git a/devtools/shared/webconsole/test/test_jsterm_autocomplete.html b/devtools/shared/webconsole/test/test_jsterm_autocomplete.html index 28545ca5b752..631c497f2cc6 100644 --- a/devtools/shared/webconsole/test/test_jsterm_autocomplete.html +++ b/devtools/shared/webconsole/test/test_jsterm_autocomplete.html @@ -40,7 +40,7 @@ function startTest({worker}) { } }; -let onAttach = Task.async(function*(aState, response) { +let onAttach = async function (aState, response) { gState = aState; let longStrLength = DebuggerServer.LONG_STRING_LENGTH; @@ -73,20 +73,18 @@ let onAttach = Task.async(function*(aState, response) { } `; - yield evaluateJS(script); + await evaluateJS(script); let tests = [doAutocomplete1, doAutocomplete2, doAutocomplete3, doAutocomplete4, doAutocompleteLarge1, - doAutocompleteLarge2].map(t => { - return Task.async(t); - }); + doAutocompleteLarge2]; runTests(tests, testEnd); -}); +}; -function* doAutocomplete1() { +async function doAutocomplete1() { info("test autocomplete for 'window.foo'"); - let response = yield autocompletePromise("window.foo", 10); + let response = await autocompletePromise("window.foo", 10); let matches = response.matches; is(response.matchProp, "foo", "matchProp"); @@ -96,9 +94,9 @@ function* doAutocomplete1() { nextTest(); } -function* doAutocomplete2() { +async function doAutocomplete2() { info("test autocomplete for 'window.foobarObject.'"); - let response = yield autocompletePromise("window.foobarObject.", 20); + let response = await autocompletePromise("window.foobarObject.", 20); let matches = response.matches; ok(!response.matchProp, "matchProp"); @@ -109,10 +107,10 @@ function* doAutocomplete2() { nextTest(); } -function* doAutocomplete3() { +async function doAutocomplete3() { // Check that completion suggestions are offered inside the string. info("test autocomplete for 'dump(window.foobarObject.)'"); - let response = yield autocompletePromise("dump(window.foobarObject.)", 25); + let response = await autocompletePromise("dump(window.foobarObject.)", 25); let matches = response.matches; ok(!response.matchProp, "matchProp"); @@ -123,21 +121,21 @@ function* doAutocomplete3() { nextTest(); } -function* doAutocomplete4() { +async function doAutocomplete4() { // Check that completion requests can have no suggestions. info("test autocomplete for 'dump(window.foobarObject.)'"); - let response = yield autocompletePromise("dump(window.foobarObject.)", 26); + let response = await autocompletePromise("dump(window.foobarObject.)", 26); ok(!response.matchProp, "matchProp"); is(response.matches.length, 0, "matches.length"); nextTest(); } -function* doAutocompleteLarge1() { +async function doAutocompleteLarge1() { // Check that completion requests with too large objects will // have no suggestions. info("test autocomplete for 'window.largeObject1.'"); - let response = yield autocompletePromise("window.largeObject1.", 20); + let response = await autocompletePromise("window.largeObject1.", 20); ok(!response.matchProp, "matchProp"); info (response.matches.join("|")); is(response.matches.length, 0, "Bailed out with too many properties"); @@ -145,11 +143,11 @@ function* doAutocompleteLarge1() { nextTest(); } -function* doAutocompleteLarge2() { +async function doAutocompleteLarge2() { // Check that completion requests with pretty large objects will // have MAX_AUTOCOMPLETIONS suggestions info("test autocomplete for 'window.largeObject2.'"); - let response = yield autocompletePromise("window.largeObject2.", 20); + let response = await autocompletePromise("window.largeObject2.", 20); ok(!response.matchProp, "matchProp"); is(response.matches.length, MAX_AUTOCOMPLETIONS, "matches.length is MAX_AUTOCOMPLETIONS"); diff --git a/devtools/shared/webconsole/test/test_jsterm_last_result.html b/devtools/shared/webconsole/test/test_jsterm_last_result.html index 65e9878c8697..626dc303afff 100644 --- a/devtools/shared/webconsole/test/test_jsterm_last_result.html +++ b/devtools/shared/webconsole/test/test_jsterm_last_result.html @@ -38,34 +38,34 @@ function startTest() }); } -let checkUndefinedResult = Task.async(function*() { +let checkUndefinedResult = async function () { info ("$_ returns undefined if nothing has evaluated yet"); - let response = yield evaluateJS("$_"); + let response = await evaluateJS("$_"); basicResultCheck(response, "$_", undefined); nextTest(); -}); +}; -let checkAdditionResult = Task.async(function*() { +let checkAdditionResult = async function () { info ("$_ returns last value and performs basic arithmetic"); - let response = yield evaluateJS("2+2"); + let response = await evaluateJS("2+2"); basicResultCheck(response, "2+2", 4); - response = yield evaluateJS("$_"); + response = await evaluateJS("$_"); basicResultCheck(response, "$_", 4); - response = yield evaluateJS("$_ + 2"); + response = await evaluateJS("$_ + 2"); basicResultCheck(response, "$_ + 2", 6); - response = yield evaluateJS("$_ + 4"); + response = await evaluateJS("$_ + 4"); basicResultCheck(response, "$_ + 4", 10); nextTest(); -}); +}; -let checkObjectResult = Task.async(function*() { +let checkObjectResult = async function () { info ("$_ has correct references to objects"); - let response = yield evaluateJS("var foo = {bar:1}; foo;"); + let response = await evaluateJS("var foo = {bar:1}; foo;"); basicResultCheck(response, "var foo = {bar:1}; foo;", { type: "object", class: "Object", @@ -77,7 +77,7 @@ let checkObjectResult = Task.async(function*() { } }); - response = yield evaluateJS("$_"); + response = await evaluateJS("$_"); basicResultCheck(response, "$_", { type: "object", class: "Object", @@ -91,7 +91,7 @@ let checkObjectResult = Task.async(function*() { top.foo.bar = 2; - response = yield evaluateJS("$_"); + response = await evaluateJS("$_"); basicResultCheck(response, "$_", { type: "object", class: "Object", @@ -104,7 +104,7 @@ let checkObjectResult = Task.async(function*() { }); nextTest(); -}); +}; function basicResultCheck(response, input, output) { checkObject(response, { diff --git a/devtools/shared/webconsole/test/test_jsterm_queryselector.html b/devtools/shared/webconsole/test/test_jsterm_queryselector.html index 0528e1db610f..824a1ceab8d8 100644 --- a/devtools/shared/webconsole/test/test_jsterm_queryselector.html +++ b/devtools/shared/webconsole/test/test_jsterm_queryselector.html @@ -41,16 +41,16 @@ function startTest() { }); } -let setupWindow = Task.async(function*() { +let setupWindow = async function () { info ("Shimming window functions for the content privileged tab"); - yield evaluateJS("document.querySelector = function() { throw 'should not call qS'; }"); - yield evaluateJS("document.querySelectorAll = function() { throw 'should not call qSA'; }"); + await evaluateJS("document.querySelector = function() { throw 'should not call qS'; }"); + await evaluateJS("document.querySelectorAll = function() { throw 'should not call qSA'; }"); nextTest(); -}); +}; -let checkQuerySelector = Task.async(function*() { +let checkQuerySelector = async function () { info ("$ returns an DOMNode"); - let response = yield evaluateJS("$('body')"); + let response = await evaluateJS("$('body')"); basicResultCheck(response, "$('body')", { type: "object", class: "HTMLBodyElement", @@ -60,11 +60,11 @@ let checkQuerySelector = Task.async(function*() { } }); nextTest(); -}); +}; -let checkQuerySelectorAll = Task.async(function*() { +let checkQuerySelectorAll = async function () { info ("$$ returns an array"); - let response = yield evaluateJS("$$('body')"); + let response = await evaluateJS("$$('body')"); basicResultCheck(response, "$$('body')", { type: "object", class: "Array", @@ -73,11 +73,11 @@ let checkQuerySelectorAll = Task.async(function*() { } }); nextTest(); -}); +}; -let checkQuerySelectorAllNotExist = Task.async(function*() { +let checkQuerySelectorAllNotExist = async function () { info ("$$ returns an array even if query yields no results"); - let response = yield evaluateJS("$$('foobar')"); + let response = await evaluateJS("$$('foobar')"); basicResultCheck(response, "$$('foobar')", { type: "object", class: "Array", @@ -86,11 +86,11 @@ let checkQuerySelectorAllNotExist = Task.async(function*() { } }); nextTest(); -}); +}; -let checkQuerySelectorException = Task.async(function*() { +let checkQuerySelectorException = async function () { info ("$ returns an exception if an invalid selector was provided"); - let response = yield evaluateJS("$(':foo')"); + let response = await evaluateJS("$(':foo')"); checkObject(response, { input: "$(':foo')", exceptionMessage: "SyntaxError: ':foo' is not a valid selector", @@ -105,11 +105,11 @@ let checkQuerySelectorException = Task.async(function*() { } }); nextTest(); -}); +}; -let checkQuerySelectorAllException = Task.async(function*() { +let checkQuerySelectorAllException = async function () { info ("$$ returns an exception if an invalid selector was provided"); - let response = yield evaluateJS("$$(':foo')"); + let response = await evaluateJS("$$(':foo')"); checkObject(response, { input: "$$(':foo')", exceptionMessage: "SyntaxError: ':foo' is not a valid selector", @@ -124,7 +124,7 @@ let checkQuerySelectorAllException = Task.async(function*() { } }); nextTest(); -}); +}; function basicResultCheck(response, input, output) { checkObject(response, { @@ -145,10 +145,10 @@ function testEnd() { }); } -let load = Task.async(function*() { +let load = async function () { removeEventListener("load", load); - yield new Promise(resolve => { + await new Promise(resolve => { SpecialPowers.pushPrefEnv({"set": [ ["security.data_uri.unique_opaque_origin", false], ]}, resolve); @@ -158,7 +158,7 @@ let load = Task.async(function*() { gWin = window.open("data:text/html,"); info ("Waiting for content window to load"); gWin.onload = startTest; -}); +}; addEventListener("load", load); diff --git a/devtools/shared/webconsole/test/unit/test_throttle.js b/devtools/shared/webconsole/test/unit/test_throttle.js index d4f87e119ff4..417987e7ffdd 100644 --- a/devtools/shared/webconsole/test/unit/test_throttle.js +++ b/devtools/shared/webconsole/test/unit/test_throttle.js @@ -71,7 +71,7 @@ TestChannel.prototype = { }, }; -add_task(function* () { +add_task(async function () { let throttler = new NetworkThrottleManager({ latencyMean: 1, latencyMax: 1, @@ -129,13 +129,13 @@ add_task(function* () { "test listener should not have received data"); equal(activitySeen, false, "activity not distributed yet"); - let newState = yield testListener.onStateChanged(); + let newState = await testListener.onStateChanged(); equal(newState, "data", "test listener received data"); equal(testListener.data, TEST_INPUT, "test listener received all the data"); equal(activitySeen, true, "activity has been distributed"); let onChange = testListener.onStateChanged(); listener.onStopRequest(null, null, null); - newState = yield onChange; + newState = await onChange; equal(newState, "stop", "onStateChanged reported"); }); diff --git a/devtools/shared/worker/tests/browser/browser_worker-01.js b/devtools/shared/worker/tests/browser/browser_worker-01.js index 722cc42f497b..cfef8f5cb826 100644 --- a/devtools/shared/worker/tests/browser/browser_worker-01.js +++ b/devtools/shared/worker/tests/browser/browser_worker-01.js @@ -20,17 +20,17 @@ const WORKER_DATA = (function () { const INTERVAL = 100; const DURATION = 1000; -add_task(function* () { +add_task(async function () { // Test both CJS and JSM versions - yield testWorker("JSM", () => ChromeUtils.import("resource://devtools/shared/worker/worker.js", {})); - yield testWorker("CommonJS", () => require("devtools/shared/worker/worker")); + await testWorker("JSM", () => ChromeUtils.import("resource://devtools/shared/worker/worker.js", {})); + await testWorker("CommonJS", () => require("devtools/shared/worker/worker")); }); -function* testWorker(context, workerFactory) { +async function testWorker(context, workerFactory) { let { DevToolsWorker, workerify } = workerFactory(); let worker = new DevToolsWorker(WORKER_URL); - let results = yield worker.performTask("plotTimestampsGraph", { + let results = await worker.performTask("plotTimestampsGraph", { timestamps: WORKER_DATA, interval: INTERVAL, duration: DURATION @@ -40,7 +40,7 @@ function* testWorker(context, workerFactory) { `worker should have returned an object with array properties in ${context}`); let fn = workerify(x => x * x); - is((yield fn(5)), 25, `workerify works in ${context}`); + is((await fn(5)), 25, `workerify works in ${context}`); fn.destroy(); worker.destroy(); diff --git a/devtools/shared/worker/tests/browser/browser_worker-02.js b/devtools/shared/worker/tests/browser/browser_worker-02.js index 3b7503d60230..efedb056102a 100644 --- a/devtools/shared/worker/tests/browser/browser_worker-02.js +++ b/devtools/shared/worker/tests/browser/browser_worker-02.js @@ -9,7 +9,7 @@ const { DevToolsWorker } = require("devtools/shared/worker/worker"); const WORKER_URL = "resource://devtools/client/shared/widgets/GraphsWorker.js"; -add_task(function* () { +add_task(async function () { try { new DevToolsWorker("resource://i/dont/exist.js"); ok(false, "Creating a DevToolsWorker with an invalid URL throws"); @@ -21,7 +21,7 @@ add_task(function* () { try { // plotTimestampsGraph requires timestamp, interval an duration props on the object // passed in so there should be an error thrown in the worker - yield worker.performTask("plotTimestampsGraph", {}); + await worker.performTask("plotTimestampsGraph", {}); ok(false, "DevToolsWorker returns a rejected promise when an error occurs in the worker"); } catch (e) { @@ -30,7 +30,7 @@ add_task(function* () { } try { - yield worker.performTask("not a real task"); + await worker.performTask("not a real task"); ok(false, "DevToolsWorker returns a rejected promise when task does not exist"); } catch (e) { ok(true, "DevToolsWorker returns a rejected promise when task does not exist"); @@ -38,7 +38,7 @@ add_task(function* () { worker.destroy(); try { - yield worker.performTask("plotTimestampsGraph", { + await worker.performTask("plotTimestampsGraph", { timestamps: [0, 1, 2, 3, 4, 5, 6, 7, 8, 9], interval: 1, duration: 1 diff --git a/devtools/shared/worker/tests/browser/browser_worker-03.js b/devtools/shared/worker/tests/browser/browser_worker-03.js index 93325b686051..fb1a0a74ffec 100644 --- a/devtools/shared/worker/tests/browser/browser_worker-03.js +++ b/devtools/shared/worker/tests/browser/browser_worker-03.js @@ -25,18 +25,18 @@ function squarePromiseReject(x) { return new Promise((_, reject) => reject("Nope")); } -add_task(function* () { +add_task(async function () { let fn = workerify(square); - is((yield fn(5)), 25, "return primitives successful"); + is((await fn(5)), 25, "return primitives successful"); fn.destroy(); fn = workerify(squarePromise); - is((yield fn(5)), 25, "promise primitives successful"); + is((await fn(5)), 25, "promise primitives successful"); fn.destroy(); fn = workerify(squareError); try { - yield fn(5); + await fn(5); ok(false, "return error should reject"); } catch (e) { ok(true, "return error should reject"); @@ -45,7 +45,7 @@ add_task(function* () { fn = workerify(squarePromiseReject); try { - yield fn(5); + await fn(5); ok(false, "returned rejected promise rejects"); } catch (e) { ok(true, "returned rejected promise rejects");