Bug 1440321 - Convert Task.jsm to async/await in devtools/client. r=jryans

--HG--
extra : rebase_source : a86f7b995233bf3f0b307c10060d7e91ff6505b4
This commit is contained in:
Alexandre Poirot 2018-03-11 12:05:00 +02:00
parent 1a8239407b
commit 4752d43bed
782 changed files with 6676 additions and 6718 deletions

View File

@ -4,8 +4,6 @@
"use strict";
const { Task } = require("devtools/shared/task");
loader.lazyRequireGetter(this, "gDevTools",
"devtools/client/framework/devtools", true);
loader.lazyRequireGetter(this, "TargetFactory",
@ -42,28 +40,28 @@ exports.debugWorker = function (client, workerActor) {
* - {Array} workers
* Array of WorkerActor forms
*/
exports.getWorkerForms = Task.async(function* (client) {
exports.getWorkerForms = async function (client) {
let registrations = [];
let workers = [];
try {
// List service worker registrations
({ registrations } =
yield client.mainRoot.listServiceWorkerRegistrations());
await client.mainRoot.listServiceWorkerRegistrations());
// List workers from the Parent process
({ workers } = yield client.mainRoot.listWorkers());
({ workers } = await client.mainRoot.listWorkers());
// And then from the Child processes
let { processes } = yield client.mainRoot.listProcesses();
let { processes } = await client.mainRoot.listProcesses();
for (let process of processes) {
// Ignore parent process
if (process.parent) {
continue;
}
let { form } = yield client.getProcess(process.id);
let { form } = await client.getProcess(process.id);
let processActor = form.actor;
let response = yield client.request({
let response = await client.request({
to: processActor,
type: "listWorkers"
});
@ -74,4 +72,4 @@ exports.getWorkerForms = Task.async(function* (client) {
}
return { registrations, workers };
});
};

View File

@ -15,8 +15,8 @@ const ADDON_NAME = "test-devtools";
const { BrowserToolboxProcess } = ChromeUtils.import("resource://devtools/client/framework/ToolboxProcess.jsm", {});
add_task(function* () {
yield new Promise(resolve => {
add_task(async function () {
await new Promise(resolve => {
let options = {"set": [
// Force enabling of addons debugging
["devtools.chrome.enabled", true],
@ -29,9 +29,9 @@ add_task(function* () {
SpecialPowers.pushPrefEnv(options, resolve);
});
let { tab, document } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
yield installAddon({
let { tab, document } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
await installAddon({
document,
path: "addons/unpacked/install.rdf",
name: ADDON_NAME,
@ -77,12 +77,12 @@ add_task(function* () {
debugBtn.click();
yield onCustomMessage;
await onCustomMessage;
ok(true, "Received the notification message from the bootstrap.js function");
yield onToolboxClose;
await onToolboxClose;
ok(true, "Addon toolbox closed");
yield uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
yield closeAboutDebugging(tab);
await uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
await closeAboutDebugging(tab);
});

View File

@ -10,13 +10,13 @@ function testFilePath(container, expectedFilePath) {
is(filePath.previousElementSibling.textContent, "Location", "file path has label");
}
add_task(function* testLegacyAddon() {
add_task(async function testLegacyAddon() {
let addonId = "test-devtools@mozilla.org";
let addonName = "test-devtools";
let { tab, document } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
let { tab, document } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
yield installAddon({
await installAddon({
document,
path: "addons/unpacked/install.rdf",
name: addonName,
@ -25,18 +25,18 @@ add_task(function* testLegacyAddon() {
let container = document.querySelector(`[data-addon-id="${addonId}"]`);
testFilePath(container, "browser/devtools/client/aboutdebugging/test/addons/unpacked/");
yield uninstallAddon({document, id: addonId, name: addonName});
await uninstallAddon({document, id: addonId, name: addonName});
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
add_task(function* testWebExtension() {
add_task(async function testWebExtension() {
let addonId = "test-devtools-webextension-nobg@mozilla.org";
let addonName = "test-devtools-webextension-nobg";
let { tab, document } = yield openAboutDebugging("addons");
let { tab, document } = await openAboutDebugging("addons");
yield waitForInitialAddonList(document);
yield installAddon({
await waitForInitialAddonList(document);
await installAddon({
document,
path: "addons/test-devtools-webextension-nobg/manifest.json",
name: addonName,
@ -55,17 +55,17 @@ add_task(function* testWebExtension() {
let manifestURL = container.querySelector(".manifest-url");
ok(manifestURL.href.startsWith("moz-extension://"), "href for manifestURL exists");
yield uninstallAddon({document, id: addonId, name: addonName});
await uninstallAddon({document, id: addonId, name: addonName});
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
add_task(function* testTemporaryWebExtension() {
add_task(async function testTemporaryWebExtension() {
let addonName = "test-devtools-webextension-noid";
let { tab, document } = yield openAboutDebugging("addons");
let { tab, document } = await openAboutDebugging("addons");
yield waitForInitialAddonList(document);
yield installAddon({
await waitForInitialAddonList(document);
await installAddon({
document,
path: "addons/test-devtools-webextension-noid/manifest.json",
name: addonName,
@ -83,18 +83,18 @@ add_task(function* testTemporaryWebExtension() {
let temporaryID = container.querySelector(".temporary-id-url");
ok(temporaryID, "Temporary ID message does appear");
yield uninstallAddon({document, id: addonId, name: addonName});
await uninstallAddon({document, id: addonId, name: addonName});
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
add_task(function* testUnknownManifestProperty() {
add_task(async function testUnknownManifestProperty() {
let addonId = "test-devtools-webextension-unknown-prop@mozilla.org";
let addonName = "test-devtools-webextension-unknown-prop";
let { tab, document } = yield openAboutDebugging("addons");
let { tab, document } = await openAboutDebugging("addons");
yield waitForInitialAddonList(document);
yield installAddon({
await waitForInitialAddonList(document);
await installAddon({
document,
path: "addons/test-devtools-webextension-unknown-prop/manifest.json",
name: addonName,
@ -102,10 +102,10 @@ add_task(function* testUnknownManifestProperty() {
});
info("Wait until the addon appears in about:debugging");
let container = yield waitUntilAddonContainer(addonName, document);
let container = await waitUntilAddonContainer(addonName, document);
info("Wait until the installation message appears for the new addon");
yield waitUntilElement(".addon-target-messages", container);
await waitUntilElement(".addon-target-messages", container);
let messages = container.querySelectorAll(".addon-target-message");
ok(messages.length === 1, "there is one message");
@ -114,7 +114,7 @@ add_task(function* testUnknownManifestProperty() {
ok(messages[0].classList.contains("addon-target-warning-message"),
"the message is a warning");
yield uninstallAddon({document, id: addonId, name: addonName});
await uninstallAddon({document, id: addonId, name: addonName});
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});

View File

@ -24,10 +24,10 @@ const {
* - when the debug button is clicked on a webextension, the opened toolbox
* has a working webconsole with the background page as default target;
*/
add_task(function* testWebExtensionsToolboxWebConsole() {
add_task(async function testWebExtensionsToolboxWebConsole() {
let {
tab, document, debugBtn,
} = yield setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_MANIFEST_PATH);
} = await setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_MANIFEST_PATH);
// Be careful, this JS function is going to be executed in the addon toolbox,
// which lives in another process. So do not try to use any scope variable!
@ -73,9 +73,9 @@ add_task(function* testWebExtensionsToolboxWebConsole() {
debugBtn.click();
yield onToolboxClose;
await onToolboxClose;
ok(true, "Addon toolbox closed");
yield uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
yield closeAboutDebugging(tab);
await uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
await closeAboutDebugging(tab);
});

View File

@ -23,10 +23,10 @@ const {
* - the webextension developer toolbox has a working Inspector panel, with the
* background page as default target;
*/
add_task(function* testWebExtensionsToolboxInspector() {
add_task(async function testWebExtensionsToolboxInspector() {
let {
tab, document, debugBtn,
} = yield setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_PATH);
} = await setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_PATH);
// Be careful, this JS function is going to be executed in the addon toolbox,
// which lives in another process. So do not try to use any scope variable!
@ -78,10 +78,10 @@ add_task(function* testWebExtensionsToolboxInspector() {
let onToolboxClose = BrowserToolboxProcess.once("close");
debugBtn.click();
yield onToolboxClose;
await onToolboxClose;
ok(true, "Addon toolbox closed");
yield uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
yield closeAboutDebugging(tab);
await uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
await closeAboutDebugging(tab);
});

View File

@ -25,10 +25,10 @@ const {
* the expected message, which warns the user that the current page is not a real
* webextension context);
*/
add_task(function* testWebExtensionsToolboxNoBackgroundPage() {
add_task(async function testWebExtensionsToolboxNoBackgroundPage() {
let {
tab, document, debugBtn,
} = yield setupTestAboutDebuggingWebExtension(ADDON_NOBG_NAME, ADDON_NOBG_PATH);
} = await setupTestAboutDebuggingWebExtension(ADDON_NOBG_NAME, ADDON_NOBG_PATH);
// Be careful, this JS function is going to be executed in the addon toolbox,
// which lives in another process. So do not try to use any scope variable!
@ -80,10 +80,10 @@ add_task(function* testWebExtensionsToolboxNoBackgroundPage() {
let onToolboxClose = BrowserToolboxProcess.once("close");
debugBtn.click();
yield onToolboxClose;
await onToolboxClose;
ok(true, "Addon toolbox closed");
yield uninstallAddon({document, id: ADDON_NOBG_ID, name: ADDON_NOBG_NAME});
yield closeAboutDebugging(tab);
await uninstallAddon({document, id: ADDON_NOBG_ID, name: ADDON_NOBG_NAME});
await closeAboutDebugging(tab);
});

View File

@ -41,7 +41,7 @@ function makeWidgetId(id) {
return id.replace(/[^a-z0-9_-]/g, "_");
}
add_task(function* testWebExtensionsToolboxSwitchToPopup() {
add_task(async function testWebExtensionsToolboxSwitchToPopup() {
let onReadyForOpenPopup;
let onPopupCustomMessage;
@ -78,7 +78,7 @@ add_task(function* testWebExtensionsToolboxSwitchToPopup() {
let {
tab, document, debugBtn,
} = yield setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_MANIFEST_PATH);
} = await setupTestAboutDebuggingWebExtension(ADDON_NAME, ADDON_MANIFEST_PATH);
// Be careful, this JS function is going to be executed in the addon toolbox,
// which lives in another process. So do not try to use any scope variable!
@ -165,7 +165,7 @@ add_task(function* testWebExtensionsToolboxSwitchToPopup() {
debugBtn.click();
yield onReadyForOpenPopup;
await onReadyForOpenPopup;
let browserActionId = makeWidgetId(ADDON_ID) + "-browser-action";
let browserActionEl = window.document.getElementById(browserActionId);
@ -174,16 +174,16 @@ add_task(function* testWebExtensionsToolboxSwitchToPopup() {
browserActionEl.click();
info("Clicked on the browserAction button");
let args = yield onPopupCustomMessage;
let args = await onPopupCustomMessage;
ok(true, "Received console message from the popup page function as expected");
is(args[0], "popupPageFunctionCalled", "Got the expected console message");
is(args[1] && args[1].name, ADDON_NAME,
"Got the expected manifest from WebExtension API");
yield onToolboxClose;
await onToolboxClose;
ok(true, "Addon toolbox closed");
yield uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
yield closeAboutDebugging(tab);
await uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
await closeAboutDebugging(tab);
});

View File

@ -30,15 +30,15 @@ const TEST_DATA = [
}
];
add_task(function* () {
add_task(async function () {
for (let testData of TEST_DATA) {
yield testCheckboxState(testData);
await testCheckboxState(testData);
}
});
function* testCheckboxState(testData) {
async function testCheckboxState(testData) {
info("Set preferences as defined by the current test data.");
yield new Promise(resolve => {
await new Promise(resolve => {
let options = {"set": [
["devtools.chrome.enabled", testData.chromeEnabled],
["devtools.debugger.remote-enabled", testData.debuggerRemoteEnable],
@ -46,11 +46,11 @@ function* testCheckboxState(testData) {
SpecialPowers.pushPrefEnv(options, resolve);
});
let { tab, document } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
let { tab, document } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
info("Install a test addon.");
yield installAddon({
await installAddon({
document,
path: "addons/unpacked/install.rdf",
name: ADDON_NAME,
@ -67,7 +67,7 @@ function* testCheckboxState(testData) {
"Debug buttons should be in the expected state");
info("Uninstall test addon installed earlier.");
yield uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
await uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
}

View File

@ -34,26 +34,26 @@ function promiseWriteWebManifestForExtension(manifest, dir) {
dir.path, manifest.applications.gecko.id, files, true);
}
add_task(function* testLegacyInstallSuccess() {
let { tab, document } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
add_task(async function testLegacyInstallSuccess() {
let { tab, document } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
// Install this add-on, and verify that it appears in the about:debugging UI
yield installAddon({
await installAddon({
document,
path: "addons/unpacked/install.rdf",
name: ADDON_NAME,
});
// Install the add-on, and verify that it disappears in the about:debugging UI
yield uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
await uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
add_task(function* testWebextensionInstallError() {
let { tab, document, window } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
add_task(async function testWebextensionInstallError() {
let { tab, document, window } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
// Trigger the file picker by clicking on the button
mockFilePicker(window, getSupportsFile("addons/bad/manifest.json").file);
@ -61,14 +61,14 @@ add_task(function* testWebextensionInstallError() {
info("wait for the install error to appear");
let top = document.querySelector(".addons-top");
yield waitUntilElement(".addons-install-error", top);
await waitUntilElement(".addons-install-error", top);
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
add_task(function* testWebextensionInstallErrorRetry() {
let { tab, document, window } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
add_task(async function testWebextensionInstallErrorRetry() {
let { tab, document, window } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
let tempdir = AddonTestUtils.tempDir.clone();
let addonId = "invalid-addon-install-retry@mozilla.org";
@ -85,7 +85,7 @@ add_task(function* testWebextensionInstallErrorRetry() {
content_scripts: { matches: "http://*/", js: "foo.js" },
};
yield promiseWriteWebManifestForExtension(manifest, tempdir);
await promiseWriteWebManifestForExtension(manifest, tempdir);
// Mock the file picker to select a test addon.
let manifestFile = tempdir.clone();
@ -97,7 +97,7 @@ add_task(function* testWebextensionInstallErrorRetry() {
info("wait for the install error to appear");
let top = document.querySelector(".addons-top");
yield waitUntilElement(".addons-install-error", top);
await waitUntilElement(".addons-install-error", top);
let retryButton = document.querySelector("button.addons-install-retry");
is(retryButton.textContent, "Retry", "Retry button has a good label");
@ -108,7 +108,7 @@ add_task(function* testWebextensionInstallErrorRetry() {
matches: ["http://*/"],
js: ["foo.js"],
}];
yield promiseWriteWebManifestForExtension(manifest, tempdir);
await promiseWriteWebManifestForExtension(manifest, tempdir);
let addonEl = document.querySelector(`[data-addon-id="${addonId}"]`);
// Verify this add-on isn't installed yet.
@ -118,11 +118,11 @@ add_task(function* testWebextensionInstallErrorRetry() {
retryButton.click();
info("Wait for the add-on to be shown");
yield waitUntilElement(`[data-addon-id="${addonId}"]`, document);
await waitUntilElement(`[data-addon-id="${addonId}"]`, document);
info("Addon is installed");
// Install the add-on, and verify that it disappears in the about:debugging UI
yield uninstallAddon({document, id: addonId, name: addonName});
await uninstallAddon({document, id: addonId, name: addonName});
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});

View File

@ -60,11 +60,11 @@ class TempWebExt {
}
}
add_task(function* reloadButtonReloadsAddon() {
const { tab, document, window } = yield openAboutDebugging("addons");
add_task(async function reloadButtonReloadsAddon() {
const { tab, document, window } = await openAboutDebugging("addons");
const { AboutDebugging } = window;
yield waitForInitialAddonList(document);
yield installAddon({
await waitForInitialAddonList(document);
await installAddon({
document,
path: "addons/unpacked/install.rdf",
name: ADDON_NAME,
@ -84,21 +84,21 @@ add_task(function* reloadButtonReloadsAddon() {
let reloaded = once(AboutDebugging, "addon-reload");
reloadButton.click();
yield reloaded;
await reloaded;
const [reloadedAddon] = yield onInstalled;
const [reloadedAddon] = await onInstalled;
is(reloadedAddon.name, ADDON_NAME,
"Add-on was reloaded: " + reloadedAddon.name);
yield onBootstrapInstallCalled;
yield tearDownAddon(reloadedAddon);
yield closeAboutDebugging(tab);
await onBootstrapInstallCalled;
await tearDownAddon(reloadedAddon);
await closeAboutDebugging(tab);
});
add_task(function* reloadButtonRefreshesMetadata() {
const { tab, document, window } = yield openAboutDebugging("addons");
add_task(async function reloadButtonRefreshesMetadata() {
const { tab, document, window } = await openAboutDebugging("addons");
const { AboutDebugging } = window;
yield waitForInitialAddonList(document);
await waitForInitialAddonList(document);
const manifestBase = {
"manifest_version": 2,
@ -115,13 +115,13 @@ add_task(function* reloadButtonRefreshesMetadata() {
tempExt.writeManifest(manifestBase);
const onInstalled = promiseAddonEvent("onInstalled");
yield AddonManager.installTemporaryAddon(tempExt.sourceDir);
await AddonManager.installTemporaryAddon(tempExt.sourceDir);
info("Wait until addon onInstalled event is received");
yield onInstalled;
await onInstalled;
info("Wait until addon appears in about:debugging#addons");
yield waitUntilAddonContainer("Temporary web extension", document);
await waitUntilAddonContainer("Temporary web extension", document);
const newName = "Temporary web extension (updated)";
tempExt.writeManifest(Object.assign({}, manifestBase, {name: newName}));
@ -131,34 +131,34 @@ add_task(function* reloadButtonRefreshesMetadata() {
const reloadButton = getReloadButton(document, manifestBase.name);
let reloaded = once(AboutDebugging, "addon-reload");
reloadButton.click();
yield reloaded;
await reloaded;
info("Wait until addon onInstalled event is received again");
const [reloadedAddon] = yield onReInstall;
const [reloadedAddon] = await onReInstall;
info("Wait until addon name is updated in about:debugging#addons");
yield waitUntilAddonContainer(newName, document);
await waitUntilAddonContainer(newName, document);
yield tearDownAddon(reloadedAddon);
await tearDownAddon(reloadedAddon);
tempExt.remove();
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
add_task(function* onlyTempInstalledAddonsCanBeReloaded() {
const { tab, document } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
yield installAddonWithManager(getSupportsFile("addons/bug1273184.xpi").file);
add_task(async function onlyTempInstalledAddonsCanBeReloaded() {
const { tab, document } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
await installAddonWithManager(getSupportsFile("addons/bug1273184.xpi").file);
info("Wait until addon appears in about:debugging#addons");
yield waitUntilAddonContainer(PACKAGED_ADDON_NAME, document);
await waitUntilAddonContainer(PACKAGED_ADDON_NAME, document);
info("Retrieved the installed addon from the addon manager");
const addon = yield getAddonByID(PACKAGED_ADDON_ID);
const addon = await getAddonByID(PACKAGED_ADDON_ID);
is(addon.name, PACKAGED_ADDON_NAME, "Addon name is correct");
const reloadButton = getReloadButton(document, addon.name);
ok(!reloadButton, "There should not be a reload button");
yield tearDownAddon(addon);
yield closeAboutDebugging(tab);
await tearDownAddon(addon);
await closeAboutDebugging(tab);
});

View File

@ -12,15 +12,15 @@ function getRemoveButton(document, id) {
return document.querySelector(`[data-addon-id="${id}"] .uninstall-button`);
}
add_task(function* removeLegacyExtension() {
add_task(async function removeLegacyExtension() {
const addonID = "test-devtools@mozilla.org";
const addonName = "test-devtools";
const { tab, document } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
const { tab, document } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
// Install this add-on, and verify that it appears in the about:debugging UI
yield installAddon({
await installAddon({
document,
path: "addons/unpacked/install.rdf",
name: addonName,
@ -30,22 +30,22 @@ add_task(function* removeLegacyExtension() {
info("Click on the remove button and wait until the addon container is removed");
getRemoveButton(document, addonID).click();
yield waitUntil(() => !getTargetEl(document, addonID), 100);
await waitUntil(() => !getTargetEl(document, addonID), 100);
info("add-on is not shown");
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
add_task(function* removeWebextension() {
add_task(async function removeWebextension() {
const addonID = "test-devtools-webextension@mozilla.org";
const addonName = "test-devtools-webextension";
const { tab, document } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
const { tab, document } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
// Install this add-on, and verify that it appears in the about:debugging UI
yield installAddon({
await installAddon({
document,
path: "addons/test-devtools-webextension/manifest.json",
name: addonName,
@ -56,26 +56,26 @@ add_task(function* removeWebextension() {
info("Click on the remove button and wait until the addon container is removed");
getRemoveButton(document, addonID).click();
yield waitUntil(() => !getTargetEl(document, addonID), 100);
await waitUntil(() => !getTargetEl(document, addonID), 100);
info("add-on is not shown");
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
add_task(function* onlyTempInstalledAddonsCanBeRemoved() {
const { tab, document } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
add_task(async function onlyTempInstalledAddonsCanBeRemoved() {
const { tab, document } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
yield installAddonWithManager(getSupportsFile("addons/bug1273184.xpi").file);
const addon = yield getAddonByID("bug1273184@tests");
await installAddonWithManager(getSupportsFile("addons/bug1273184.xpi").file);
const addon = await getAddonByID("bug1273184@tests");
info("Wait until addon appears in about:debugging#addons");
yield waitUntilAddonContainer(PACKAGED_ADDON_NAME, document);
await waitUntilAddonContainer(PACKAGED_ADDON_NAME, document);
const removeButton = getRemoveButton(document, addon.id);
ok(!removeButton, "remove button is not shown");
yield tearDownAddon(addon);
yield closeAboutDebugging(tab);
await tearDownAddon(addon);
await closeAboutDebugging(tab);
});

View File

@ -9,9 +9,9 @@
const ADDON_ID = "test-devtools@mozilla.org";
const ADDON_NAME = "test-devtools";
add_task(function* () {
add_task(async function () {
info("Turn off addon debugging.");
yield new Promise(resolve => {
await new Promise(resolve => {
let options = {"set": [
["devtools.chrome.enabled", false],
["devtools.debugger.remote-enabled", false],
@ -19,11 +19,11 @@ add_task(function* () {
SpecialPowers.pushPrefEnv(options, resolve);
});
let { tab, document } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
let { tab, document } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
info("Install a test addon.");
yield installAddon({
await installAddon({
document,
path: "addons/unpacked/install.rdf",
name: ADDON_NAME,
@ -51,9 +51,9 @@ add_task(function* () {
info("All debug buttons are disabled again.");
info("Uninstall addon installed earlier.");
yield uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
await uninstallAddon({document, id: ADDON_ID, name: ADDON_NAME});
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
function getDebugButtons(document) {

View File

@ -6,36 +6,36 @@
// error page.
// Every url navigating including #invalid-hash should be kept in history and
// navigate back as expected.
add_task(function* () {
let { tab, document } = yield openAboutDebugging("invalid-hash");
add_task(async function () {
let { tab, document } = await openAboutDebugging("invalid-hash");
let element = document.querySelector(".header-name");
is(element.textContent, "Page not found", "Show error page");
info("Opening addons-panel panel");
document.querySelector("[aria-controls='addons-panel']").click();
yield waitUntilElement("#addons-panel", document);
await waitUntilElement("#addons-panel", document);
yield waitForInitialAddonList(document);
await waitForInitialAddonList(document);
element = document.querySelector(".header-name");
is(element.textContent, "Add-ons", "Show Addons");
info("Opening about:debugging#invalid-hash");
window.openUILinkIn("about:debugging#invalid-hash", "current");
yield waitUntilElement(".error-page", document);
await waitUntilElement(".error-page", document);
element = document.querySelector(".header-name");
is(element.textContent, "Page not found", "Show error page");
gBrowser.goBack();
yield waitUntilElement("#addons-panel", document);
yield waitForInitialAddonList(document);
await waitUntilElement("#addons-panel", document);
await waitForInitialAddonList(document);
element = document.querySelector(".header-name");
is(element.textContent, "Add-ons", "Show Addons");
gBrowser.goBack();
yield waitUntilElement(".error-page", document);
await waitUntilElement(".error-page", document);
element = document.querySelector(".header-name");
is(element.textContent, "Page not found", "Show error page");
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});

View File

@ -8,16 +8,16 @@
const SERVICE_WORKER = URL_ROOT + "service-workers/empty-sw.js";
const TAB_URL = URL_ROOT + "service-workers/empty-sw.html";
add_task(function* () {
yield enableServiceWorkerDebugging();
add_task(async function () {
await enableServiceWorkerDebugging();
let { tab, document } = yield openAboutDebugging("workers");
let { tab, document } = await openAboutDebugging("workers");
let swTab = yield addTab(TAB_URL);
let swTab = await addTab(TAB_URL);
let serviceWorkersElement = getServiceWorkerList(document);
yield waitUntil(() => {
await waitUntil(() => {
// Check that the service worker appears in the UI
let names = [...document.querySelectorAll("#service-workers .target-name")];
names = names.map(element => element.textContent);
@ -26,7 +26,7 @@ add_task(function* () {
info("The service worker url appears in the list");
try {
yield unregisterServiceWorker(swTab, serviceWorkersElement);
await unregisterServiceWorker(swTab, serviceWorkersElement);
ok(true, "Service worker registration unregistered");
} catch (e) {
ok(false, "SW not unregistered; " + e);
@ -38,6 +38,6 @@ add_task(function* () {
ok(!names.includes(SERVICE_WORKER),
"The service worker url is no longer in the list: " + names);
yield removeTab(swTab);
yield closeAboutDebugging(tab);
await removeTab(swTab);
await closeAboutDebugging(tab);
});

View File

@ -8,16 +8,16 @@
const EMPTY_SW_TAB_URL = URL_ROOT + "service-workers/empty-sw.html";
const FETCH_SW_TAB_URL = URL_ROOT + "service-workers/fetch-sw.html";
function* testBody(url, expecting) {
yield enableServiceWorkerDebugging();
let { tab, document } = yield openAboutDebugging("workers");
async function testBody(url, expecting) {
await enableServiceWorkerDebugging();
let { tab, document } = await openAboutDebugging("workers");
let swTab = yield addTab(url);
let swTab = await addTab(url);
let serviceWorkersElement = getServiceWorkerList(document);
info("Wait for fetch flag.");
yield waitUntil(() => {
await waitUntil(() => {
let fetchFlags =
[...document.querySelectorAll("#service-workers .service-worker-fetch-flag")];
fetchFlags = fetchFlags.map(element => element.textContent);
@ -27,7 +27,7 @@ function* testBody(url, expecting) {
info("Found correct fetch flag.");
try {
yield unregisterServiceWorker(swTab, serviceWorkersElement);
await unregisterServiceWorker(swTab, serviceWorkersElement);
ok(true, "Service worker registration unregistered");
} catch (e) {
ok(false, "SW not unregistered; " + e);
@ -38,11 +38,11 @@ function* testBody(url, expecting) {
names = names.map(element => element.textContent);
ok(names.length == 0, "All service workers were removed from the list.");
yield removeTab(swTab);
yield closeAboutDebugging(tab);
await removeTab(swTab);
await closeAboutDebugging(tab);
}
add_task(function* () {
yield testBody(FETCH_SW_TAB_URL, "Listening for fetch events.");
yield testBody(EMPTY_SW_TAB_URL, "Not listening for fetch events.");
add_task(async function () {
await testBody(FETCH_SW_TAB_URL, "Listening for fetch events.");
await testBody(EMPTY_SW_TAB_URL, "Not listening for fetch events.");
});

View File

@ -10,12 +10,12 @@
const SERVICE_WORKER = URL_ROOT + "service-workers/empty-sw.js";
const TAB_URL = URL_ROOT + "service-workers/empty-sw.html";
add_task(function* () {
yield enableServiceWorkerDebugging();
add_task(async function () {
await enableServiceWorkerDebugging();
info("Force two content processes");
yield pushPref("dom.ipc.processCount", 2);
await pushPref("dom.ipc.processCount", 2);
let { tab, document } = yield openAboutDebugging("workers");
let { tab, document } = await openAboutDebugging("workers");
let warningSection = document.querySelector(".service-worker-multi-process");
let img = warningSection.querySelector(".warning");
@ -23,12 +23,12 @@ add_task(function* () {
let serviceWorkersElement = getServiceWorkerList(document);
let swTab = yield addTab(TAB_URL, { background: true });
let swTab = await addTab(TAB_URL, { background: true });
info("Wait for service worker to appear in the list");
// Check that the service worker appears in the UI
let serviceWorkerContainer =
yield waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
await waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
info("Check that service worker buttons are disabled.");
let debugButton = getDebugButton(serviceWorkerContainer);
@ -39,8 +39,8 @@ add_task(function* () {
let hasWarning = document.querySelector(".service-worker-multi-process");
return !hasWarning && !debugButton.disabled;
}, 100);
yield pushPref("dom.ipc.processCount", 1);
yield onWarningCleared;
await pushPref("dom.ipc.processCount", 1);
await onWarningCleared;
ok(!debugButton.disabled, "Debug button is enabled.");
info("Update the preference back to 2");
@ -48,8 +48,8 @@ add_task(function* () {
let hasWarning = document.querySelector(".service-worker-multi-process");
return hasWarning && getDebugButton(serviceWorkerContainer).disabled;
}, 100);
yield pushPref("dom.ipc.processCount", 2);
yield onWarningRestored;
await pushPref("dom.ipc.processCount", 2);
await onWarningRestored;
// Update the reference to the debugButton, as the previous DOM element might have been
// deleted.
@ -58,14 +58,14 @@ add_task(function* () {
info("Unregister service worker");
try {
yield unregisterServiceWorker(swTab, serviceWorkersElement);
await unregisterServiceWorker(swTab, serviceWorkersElement);
ok(true, "Service worker registration unregistered");
} catch (e) {
ok(false, "SW not unregistered; " + e);
}
yield removeTab(swTab);
yield closeAboutDebugging(tab);
await removeTab(swTab);
await closeAboutDebugging(tab);
});
function getDebugButton(serviceWorkerContainer) {

View File

@ -11,8 +11,8 @@
var imgClass = ".service-worker-disabled .warning";
add_task(function* () {
yield new Promise(done => {
add_task(async function () {
await new Promise(done => {
info("disable service workers");
let options = {"set": [
["dom.serviceWorkers.enabled", false],
@ -20,16 +20,16 @@ add_task(function* () {
SpecialPowers.pushPrefEnv(options, done);
});
let { tab, document } = yield openAboutDebugging("workers");
let { tab, document } = await openAboutDebugging("workers");
// Check that the warning img appears in the UI
let img = document.querySelector(imgClass);
ok(img, "warning message is rendered");
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
add_task(function* () {
yield new Promise(done => {
add_task(async function () {
await new Promise(done => {
info("set private browsing mode as default");
let options = {"set": [
["browser.privatebrowsing.autostart", true],
@ -37,24 +37,24 @@ add_task(function* () {
SpecialPowers.pushPrefEnv(options, done);
});
let { tab, document } = yield openAboutDebugging("workers");
let { tab, document } = await openAboutDebugging("workers");
// Check that the warning img appears in the UI
let img = document.querySelector(imgClass);
ok(img, "warning message is rendered");
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
add_task(function* () {
add_task(async function () {
info("Opening a new private window");
let win = OpenBrowserWindow({private: true});
yield waitForDelayedStartupFinished(win);
await waitForDelayedStartupFinished(win);
let { tab, document } = yield openAboutDebugging("workers", win);
let { tab, document } = await openAboutDebugging("workers", win);
// Check that the warning img appears in the UI
let img = document.querySelector(imgClass);
ok(img, "warning message is rendered");
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
win.close();
});

View File

@ -14,19 +14,19 @@
const SERVICE_WORKER = URL_ROOT + "service-workers/push-sw.js";
const TAB_URL = URL_ROOT + "service-workers/push-sw.html";
add_task(function* () {
yield enableServiceWorkerDebugging();
let { tab, document } = yield openAboutDebugging("workers");
add_task(async function () {
await enableServiceWorkerDebugging();
let { tab, document } = await openAboutDebugging("workers");
// Listen for mutations in the service-workers list.
let serviceWorkersElement = getServiceWorkerList(document);
// Open a tab that registers a push service worker.
let swTab = yield addTab(TAB_URL);
let swTab = await addTab(TAB_URL);
info("Make the test page notify us when the service worker sends a message.");
yield ContentTask.spawn(swTab.linkedBrowser, {}, function () {
await ContentTask.spawn(swTab.linkedBrowser, {}, function () {
let win = content.wrappedJSObject;
win.navigator.serviceWorker.addEventListener("message", function (event) {
sendAsyncMessage(event.data);
@ -37,14 +37,14 @@ add_task(function* () {
let onClaimed = onTabMessage(swTab, "sw-claimed");
info("Wait until the service worker appears in the UI");
yield waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
await waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
info("Ensure that the registration resolved before trying to interact with " +
"the service worker.");
yield waitForServiceWorkerRegistered(swTab);
await waitForServiceWorkerRegistered(swTab);
ok(true, "Service worker registration resolved");
yield waitForServiceWorkerActivation(SERVICE_WORKER, document);
await waitForServiceWorkerActivation(SERVICE_WORKER, document);
// Retrieve the Push button for the worker.
let names = [...document.querySelectorAll("#service-workers .target-name")];
@ -57,26 +57,26 @@ add_task(function* () {
ok(pushBtn, "Found its push button");
info("Wait for the service worker to claim the test window before proceeding.");
yield onClaimed;
await onClaimed;
info("Click on the Push button and wait for the service worker to receive " +
"a push notification");
let onPushNotification = onTabMessage(swTab, "sw-pushed");
pushBtn.click();
yield onPushNotification;
await onPushNotification;
ok(true, "Service worker received a push notification");
// Finally, unregister the service worker itself.
try {
yield unregisterServiceWorker(swTab, serviceWorkersElement);
await unregisterServiceWorker(swTab, serviceWorkersElement);
ok(true, "Service worker registration unregistered");
} catch (e) {
ok(false, "SW not unregistered; " + e);
}
yield removeTab(swTab);
yield closeAboutDebugging(tab);
await removeTab(swTab);
await closeAboutDebugging(tab);
});
/**

View File

@ -16,11 +16,11 @@ const FAKE_ENDPOINT = "https://fake/endpoint";
const PushService = Cc["@mozilla.org/push/Service;1"]
.getService(Ci.nsIPushService).wrappedJSObject;
add_task(function* () {
add_task(async function () {
info("Turn on workers via mochitest http.");
yield enableServiceWorkerDebugging();
await enableServiceWorkerDebugging();
// Enable the push service.
yield pushPref("dom.push.connection.enabled", true);
await pushPref("dom.push.connection.enabled", true);
info("Mock the push service");
PushService.service = {
@ -52,18 +52,18 @@ add_task(function* () {
},
};
let { tab, document } = yield openAboutDebugging("workers");
let { tab, document } = await openAboutDebugging("workers");
// Listen for mutations in the service-workers list.
let serviceWorkersElement = document.getElementById("service-workers");
// Open a tab that registers a push service worker.
let swTab = yield addTab(TAB_URL);
let swTab = await addTab(TAB_URL);
info("Wait until the service worker appears in about:debugging");
yield waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
await waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
yield waitForServiceWorkerActivation(SERVICE_WORKER, document);
await waitForServiceWorkerActivation(SERVICE_WORKER, document);
// Wait for the service worker details to update.
let names = [...document.querySelectorAll("#service-workers .target-name")];
@ -74,7 +74,7 @@ add_task(function* () {
// Retrieve the push subscription endpoint URL, and verify it looks good.
info("Wait for the push URL");
let pushURL = yield waitUntilElement(".service-worker-push-url", targetContainer);
let pushURL = await waitUntilElement(".service-worker-push-url", targetContainer);
info("Found the push service URL in the service worker details");
is(pushURL.textContent, FAKE_ENDPOINT, "The push service URL looks correct");
@ -87,12 +87,12 @@ add_task(function* () {
// Wait for the service worker details to update again
info("Wait until the push URL is removed from the UI");
yield waitUntil(() => !targetContainer.querySelector(".service-worker-push-url"), 100);
await waitUntil(() => !targetContainer.querySelector(".service-worker-push-url"), 100);
info("The push service URL should be removed");
// Finally, unregister the service worker itself.
try {
yield unregisterServiceWorker(swTab, serviceWorkersElement);
await unregisterServiceWorker(swTab, serviceWorkersElement);
ok(true, "Service worker registration unregistered");
} catch (e) {
ok(false, "SW not unregistered; " + e);
@ -101,6 +101,6 @@ add_task(function* () {
info("Unmock the push service");
PushService.service = null;
yield removeTab(swTab);
yield closeAboutDebugging(tab);
await removeTab(swTab);
await closeAboutDebugging(tab);
});

View File

@ -14,29 +14,29 @@ const TAB_URL = URL_ROOT + "service-workers/empty-sw.html";
const SW_TIMEOUT = 1000;
add_task(function* () {
yield enableServiceWorkerDebugging();
yield pushPref("dom.serviceWorkers.idle_timeout", SW_TIMEOUT);
yield pushPref("dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT);
add_task(async function () {
await enableServiceWorkerDebugging();
await pushPref("dom.serviceWorkers.idle_timeout", SW_TIMEOUT);
await pushPref("dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT);
let { tab, document } = yield openAboutDebugging("workers");
let { tab, document } = await openAboutDebugging("workers");
// Listen for mutations in the service-workers list.
let serviceWorkersElement = getServiceWorkerList(document);
// Open a tab that registers an empty service worker.
let swTab = yield addTab(TAB_URL);
let swTab = await addTab(TAB_URL);
// Wait for the service-workers list to update.
info("Wait until the service worker appears in about:debugging");
yield waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
await waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
info("Ensure that the registration resolved before trying to interact with " +
"the service worker.");
yield waitForServiceWorkerRegistered(swTab);
await waitForServiceWorkerRegistered(swTab);
ok(true, "Service worker registration resolved");
yield waitForServiceWorkerActivation(SERVICE_WORKER, document);
await waitForServiceWorkerActivation(SERVICE_WORKER, document);
// Retrieve the Target element corresponding to the service worker.
let names = [...document.querySelectorAll("#service-workers .target-name")];
@ -49,7 +49,7 @@ add_task(function* () {
// already stopped and the start button is visible. Wait until the service worker is
// stopped.
info("Wait until the start button is visible");
yield waitUntilElement(".start-button", targetElement);
await waitUntilElement(".start-button", targetElement);
// We should now have a Start button but no Debug button.
let startBtn = targetElement.querySelector(".start-button");
@ -60,7 +60,7 @@ add_task(function* () {
startBtn.click();
info("Wait until the service worker starts and the debug button appears");
yield waitUntilElement(".debug-button", targetElement);
await waitUntilElement(".debug-button", targetElement);
info("Found the debug button");
// Check that we have a Debug button but not a Start button again.
@ -68,12 +68,12 @@ add_task(function* () {
// Finally, unregister the service worker itself.
try {
yield unregisterServiceWorker(swTab, serviceWorkersElement);
await unregisterServiceWorker(swTab, serviceWorkersElement);
ok(true, "Service worker registration unregistered");
} catch (e) {
ok(false, "SW not unregistered; " + e);
}
yield removeTab(swTab);
yield closeAboutDebugging(tab);
await removeTab(swTab);
await closeAboutDebugging(tab);
});

View File

@ -11,31 +11,31 @@ const SW_TIMEOUT = 2000;
requestLongerTimeout(2);
add_task(function* () {
yield enableServiceWorkerDebugging();
yield pushPref("dom.serviceWorkers.idle_timeout", SW_TIMEOUT);
yield pushPref("dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT);
add_task(async function () {
await enableServiceWorkerDebugging();
await pushPref("dom.serviceWorkers.idle_timeout", SW_TIMEOUT);
await pushPref("dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT);
let { tab, document } = yield openAboutDebugging("workers");
let { tab, document } = await openAboutDebugging("workers");
// Listen for mutations in the service-workers list.
let serviceWorkersElement = getServiceWorkerList(document);
let swTab = yield addTab(TAB_URL);
let swTab = await addTab(TAB_URL);
info("Wait until the service worker appears in about:debugging");
let container = yield waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
let container = await waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
// We should ideally check that the service worker registration goes through the
// "registering" and "running" steps, but it is difficult to workaround race conditions
// for a test running on a wide variety of platforms. Due to intermittent failures, we
// simply check that the registration transitions to "stopped".
let status = container.querySelector(".target-status");
yield waitUntil(() => status.textContent == "Stopped", 100);
await waitUntil(() => status.textContent == "Stopped", 100);
is(status.textContent, "Stopped", "Service worker is currently stopped");
try {
yield unregisterServiceWorker(swTab, serviceWorkersElement);
await unregisterServiceWorker(swTab, serviceWorkersElement);
ok(true, "Service worker unregistered");
} catch (e) {
ok(false, "Service worker not unregistered; " + e);
@ -47,6 +47,6 @@ add_task(function* () {
ok(!names.includes(SERVICE_WORKER),
"The service worker url is no longer in the list: " + names);
yield removeTab(swTab);
yield closeAboutDebugging(tab);
await removeTab(swTab);
await closeAboutDebugging(tab);
});

View File

@ -11,22 +11,22 @@ const TAB_URL = URL_ROOT + "service-workers/empty-sw.html";
const SW_TIMEOUT = 1000;
add_task(function* () {
yield enableServiceWorkerDebugging();
yield pushPref("dom.serviceWorkers.idle_timeout", SW_TIMEOUT);
yield pushPref("dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT);
add_task(async function () {
await enableServiceWorkerDebugging();
await pushPref("dom.serviceWorkers.idle_timeout", SW_TIMEOUT);
await pushPref("dom.serviceWorkers.idle_extended_timeout", SW_TIMEOUT);
let { tab, document } = yield openAboutDebugging("workers");
let { tab, document } = await openAboutDebugging("workers");
let serviceWorkersElement = getServiceWorkerList(document);
let swTab = yield addTab(TAB_URL);
let swTab = await addTab(TAB_URL);
info("Wait until the service worker appears in about:debugging");
yield waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
await waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
// Ensure that the registration resolved before trying to connect to the sw
yield waitForServiceWorkerRegistered(swTab);
await waitForServiceWorkerRegistered(swTab);
ok(true, "Service worker registration resolved");
// Retrieve the DEBUG button for the worker
@ -45,12 +45,12 @@ add_task(function* () {
});
debugBtn.click();
let toolbox = yield onToolboxReady;
let toolbox = await onToolboxReady;
// Wait for more than the regular timeout,
// so that if the worker freezing doesn't work,
// it will be destroyed and removed from the list
yield new Promise(done => {
await new Promise(done => {
setTimeout(done, SW_TIMEOUT * 2);
});
@ -58,20 +58,20 @@ add_task(function* () {
ok(targetElement.querySelector(".debug-button"),
"The debug button is still there");
yield toolbox.destroy();
await toolbox.destroy();
toolbox = null;
// Now ensure that the worker is correctly destroyed
// after we destroy the toolbox.
// The DEBUG button should disappear once the worker is destroyed.
info("Wait until the debug button disappears");
yield waitUntil(() => {
await waitUntil(() => {
return !targetElement.querySelector(".debug-button");
});
// Finally, unregister the service worker itself.
try {
yield unregisterServiceWorker(swTab, serviceWorkersElement);
await unregisterServiceWorker(swTab, serviceWorkersElement);
ok(true, "Service worker registration unregistered");
} catch (e) {
ok(false, "SW not unregistered; " + e);
@ -79,6 +79,6 @@ add_task(function* () {
assertHasTarget(false, document, "service-workers", SERVICE_WORKER);
yield removeTab(swTab);
yield closeAboutDebugging(tab);
await removeTab(swTab);
await closeAboutDebugging(tab);
});

View File

@ -14,22 +14,22 @@ const SCOPE = URL_ROOT + "service-workers/";
const SERVICE_WORKER = SCOPE + "empty-sw.js";
const TAB_URL = SCOPE + "empty-sw.html";
add_task(function* () {
yield enableServiceWorkerDebugging();
add_task(async function () {
await enableServiceWorkerDebugging();
let { tab, document } = yield openAboutDebugging("workers");
let { tab, document } = await openAboutDebugging("workers");
// Open a tab that registers an empty service worker.
let swTab = yield addTab(TAB_URL);
let swTab = await addTab(TAB_URL);
info("Wait until the service worker appears in about:debugging");
yield waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
await waitUntilServiceWorkerContainer(SERVICE_WORKER, document);
yield waitForServiceWorkerActivation(SERVICE_WORKER, document);
await waitForServiceWorkerActivation(SERVICE_WORKER, document);
info("Ensure that the registration resolved before trying to interact with " +
"the service worker.");
yield waitForServiceWorkerRegistered(swTab);
await waitForServiceWorkerRegistered(swTab);
ok(true, "Service worker registration resolved");
let targets = document.querySelectorAll("#service-workers .target");
@ -51,10 +51,10 @@ add_task(function* () {
unregisterLink.click();
info("Wait until the service worker disappears");
yield waitUntil(() => {
await waitUntil(() => {
return !document.querySelector("#service-workers .target");
});
yield removeTab(swTab);
yield closeAboutDebugging(tab);
await removeTab(swTab);
await closeAboutDebugging(tab);
});

View File

@ -5,12 +5,12 @@
const TAB_URL = "data:text/html,<title>foo</title>";
add_task(function* () {
let { tab, document } = yield openAboutDebugging("tabs");
add_task(async function () {
let { tab, document } = await openAboutDebugging("tabs");
// Wait for initial tabs list which may be empty
let tabsElement = getTabList(document);
yield waitUntilElement(".target-name", tabsElement);
await waitUntilElement(".target-name", tabsElement);
// Refresh tabsElement to get the .target-list element
tabsElement = getTabList(document);
@ -19,13 +19,13 @@ add_task(function* () {
let initialTabCount = names.length;
info("Open a new background tab");
let newTab = yield addTab(TAB_URL, { background: true });
let newTab = await addTab(TAB_URL, { background: true });
info("Wait for the tab to appear in the list with the correct name");
let container = yield waitUntilTabContainer("foo", document);
let container = await waitUntilTabContainer("foo", document);
info("Wait until the title to update");
yield waitUntil(() => {
await waitUntil(() => {
return container.querySelector(".target-name").title === TAB_URL;
}, 100);
@ -33,7 +33,7 @@ add_task(function* () {
ok(icon && icon.src, "Tab icon found and src attribute is not empty");
info("Check if the tab icon is a valid image");
yield new Promise(r => {
await new Promise(r => {
let image = new Image();
image.onload = () => {
ok(true, "Favicon is not a broken image");
@ -47,16 +47,16 @@ add_task(function* () {
});
// Finally, close the tab
yield removeTab(newTab);
await removeTab(newTab);
info("Wait until the tab container is removed");
yield waitUntil(() => !getTabContainer("foo", document), 100);
await waitUntil(() => !getTabContainer("foo", document), 100);
// Check that the tab disappeared from the UI
names = [...tabsElement.querySelectorAll("#tabs .target-name")];
is(names.length, initialTabCount, "The tab disappeared from the UI");
yield closeAboutDebugging(tab);
await closeAboutDebugging(tab);
});
function getTabContainer(name, document) {
@ -69,8 +69,8 @@ function getTabContainer(name, document) {
return null;
}
function* waitUntilTabContainer(name, document) {
yield waitUntil(() => {
async function waitUntilTabContainer(name, document) {
await waitUntil(() => {
return getTabContainer(name, document);
});
return getTabContainer(name, document);

View File

@ -20,20 +20,20 @@ registerCleanupFunction(() => {
flags.testing = false;
});
function* openAboutDebugging(page, win) {
async function openAboutDebugging(page, win) {
info("opening about:debugging");
let url = "about:debugging";
if (page) {
url += "#" + page;
}
let tab = yield addTab(url, { window: win });
let tab = await addTab(url, { window: win });
let browser = tab.linkedBrowser;
let document = browser.contentDocument;
let window = browser.contentWindow;
info("Wait until the main about debugging container is available");
yield waitUntilElement(".app", document);
await waitUntilElement(".app", document);
return { tab, document, window };
}
@ -135,8 +135,8 @@ function getServiceWorkerContainer(name, document) {
* #service-workers section container document
* @return {Promise} promise that resolves the service worker container element.
*/
function* waitUntilServiceWorkerContainer(name, document) {
yield waitUntil(() => {
async function waitUntilServiceWorkerContainer(name, document) {
await waitUntil(() => {
return getServiceWorkerContainer(name, document);
}, 100);
return getServiceWorkerContainer(name, document);
@ -152,8 +152,8 @@ function* waitUntilServiceWorkerContainer(name, document) {
* Parent that should contain the element.
* @return {Promise} promise that resolves the matched DOMNode.
*/
function* waitUntilElement(selector, parent) {
yield waitUntil(() => {
async function waitUntilElement(selector, parent) {
await waitUntil(() => {
return parent.querySelector(selector);
}, 100);
return parent.querySelector(selector);
@ -170,7 +170,7 @@ function getTabList(document) {
document.querySelector("#tabs.targets");
}
function* installAddon({document, path, name, isWebExtension}) {
async function installAddon({document, path, name, isWebExtension}) {
// Mock the file picker to select a test addon
let MockFilePicker = SpecialPowers.MockFilePicker;
MockFilePicker.init(window);
@ -203,16 +203,16 @@ function* installAddon({document, path, name, isWebExtension}) {
// Trigger the file picker by clicking on the button
document.getElementById("load-addon-from-file").click();
yield onAddonInstalled;
await onAddonInstalled;
ok(true, "Addon installed and running its bootstrap.js file");
info("Wait for the addon to appear in the UI");
yield waitUntilAddonContainer(name, document);
await waitUntilAddonContainer(name, document);
}
function* uninstallAddon({document, id, name}) {
async function uninstallAddon({document, id, name}) {
// Now uninstall this addon
yield new Promise(done => {
await new Promise(done => {
AddonManager.getAddonByID(id, addon => {
let listener = {
onUninstalled: function (uninstalledAddon) {
@ -230,7 +230,7 @@ function* uninstallAddon({document, id, name}) {
});
info("Wait until the addon is removed from about:debugging");
yield waitUntil(() => !getAddonContainer(name, document), 100);
await waitUntil(() => !getAddonContainer(name, document), 100);
}
function getAddonCount(document) {
@ -260,8 +260,8 @@ function getAddonContainer(name, document) {
return null;
}
function* waitUntilAddonContainer(name, document) {
yield waitUntil(() => {
async function waitUntilAddonContainer(name, document) {
await waitUntil(() => {
return getAddonContainer(name, document);
});
return getAddonContainer(name, document);
@ -289,10 +289,10 @@ function assertHasTarget(expected, document, type, name) {
* @return {Promise} Resolves when the service worker is registered.
*/
function waitForServiceWorkerRegistered(tab) {
return ContentTask.spawn(tab.linkedBrowser, {}, function* () {
return ContentTask.spawn(tab.linkedBrowser, {}, async function () {
// Retrieve the `sw` promise created in the html page.
let { sw } = content.wrappedJSObject;
yield sw;
await sw;
});
}
@ -305,7 +305,7 @@ function waitForServiceWorkerRegistered(tab) {
* @param {Node} serviceWorkersElement
* @return {Promise} Resolves when the service worker is unregistered.
*/
function* unregisterServiceWorker(tab, serviceWorkersElement) {
async function unregisterServiceWorker(tab, serviceWorkersElement) {
// Get the initial count of service worker registrations.
let registrations = serviceWorkersElement.querySelectorAll(".target-container");
let registrationCount = registrations.length;
@ -317,11 +317,11 @@ function* unregisterServiceWorker(tab, serviceWorkersElement) {
}, 100);
// Unregister the service worker from the content page
yield ContentTask.spawn(tab.linkedBrowser, {}, function* () {
await ContentTask.spawn(tab.linkedBrowser, {}, async function () {
// Retrieve the `sw` promise created in the html page
let { sw } = content.wrappedJSObject;
let registration = yield sw;
yield registration.unregister();
let registration = await sw;
await registration.unregister();
});
return isRemoved;
@ -347,8 +347,8 @@ function waitForDelayedStartupFinished(win) {
/**
* open the about:debugging page and install an addon
*/
function* setupTestAboutDebuggingWebExtension(name, path) {
yield new Promise(resolve => {
async function setupTestAboutDebuggingWebExtension(name, path) {
await new Promise(resolve => {
let options = {"set": [
// Force enabling of addons debugging
["devtools.chrome.enabled", true],
@ -361,10 +361,10 @@ function* setupTestAboutDebuggingWebExtension(name, path) {
SpecialPowers.pushPrefEnv(options, resolve);
});
let { tab, document } = yield openAboutDebugging("addons");
yield waitForInitialAddonList(document);
let { tab, document } = await openAboutDebugging("addons");
await waitForInitialAddonList(document);
yield installAddon({
await installAddon({
document,
path,
name,
@ -386,14 +386,14 @@ function* setupTestAboutDebuggingWebExtension(name, path) {
* Wait for aboutdebugging to be notified about the activation of the service worker
* corresponding to the provided service worker url.
*/
function* waitForServiceWorkerActivation(swUrl, document) {
async function waitForServiceWorkerActivation(swUrl, document) {
let serviceWorkersElement = getServiceWorkerList(document);
let names = serviceWorkersElement.querySelectorAll(".target-name");
let name = [...names].filter(element => element.textContent === swUrl)[0];
let targetElement = name.parentNode.parentNode;
let targetStatus = targetElement.querySelector(".target-status");
yield waitUntil(() => {
await waitUntil(() => {
return targetStatus.textContent !== "Registering";
}, 100);
}
@ -401,7 +401,7 @@ function* waitForServiceWorkerActivation(swUrl, document) {
/**
* Set all preferences needed to enable service worker debugging and testing.
*/
function* enableServiceWorkerDebugging() {
async function enableServiceWorkerDebugging() {
let options = { "set": [
// Enable service workers.
["dom.serviceWorkers.enabled", true],
@ -412,7 +412,7 @@ function* enableServiceWorkerDebugging() {
]};
// Wait for dom.ipc.processCount to be updated before releasing processes.
yield new Promise(done => {
await new Promise(done => {
SpecialPowers.pushPrefEnv(options, done);
});
@ -466,10 +466,10 @@ function getAddonByID(addonId) {
/**
* Uninstall an add-on.
*/
function* tearDownAddon(addon) {
async function tearDownAddon(addon) {
const onUninstalled = promiseAddonEvent("onUninstalled");
addon.uninstall();
const [uninstalledAddon] = yield onUninstalled;
const [uninstalledAddon] = await onUninstalled;
is(uninstalledAddon.id, addon.id,
`Add-on was uninstalled: ${uninstalledAddon.id}`);
}

View File

@ -25,7 +25,6 @@ const Promise = require("Promise");
const CANVAS_ACTOR_RECORDING_ATTEMPT = flags.testing ? 500 : 5000;
const { Task } = require("devtools/shared/task");
ChromeUtils.defineModuleGetter(this, "FileUtils",
"resource://gre/modules/FileUtils.jsm");

View File

@ -179,33 +179,33 @@ var SnapshotsListView = extend(WidgetMethods, {
$("#screenshot-container").hidden = true;
$("#snapshot-filmstrip").hidden = true;
Task.spawn(function* () {
(async function () {
// Wait for a few milliseconds between presenting the function calls,
// screenshot and thumbnails, to allow each component being
// sequentially drawn. This gives the illusion of snappiness.
yield DevToolsUtils.waitForTime(SNAPSHOT_DATA_DISPLAY_DELAY);
await DevToolsUtils.waitForTime(SNAPSHOT_DATA_DISPLAY_DELAY);
CallsListView.showCalls(calls);
$("#debugging-pane-contents").hidden = false;
$("#waiting-notice").hidden = true;
yield DevToolsUtils.waitForTime(SNAPSHOT_DATA_DISPLAY_DELAY);
await DevToolsUtils.waitForTime(SNAPSHOT_DATA_DISPLAY_DELAY);
CallsListView.showThumbnails(thumbnails);
$("#snapshot-filmstrip").hidden = false;
yield DevToolsUtils.waitForTime(SNAPSHOT_DATA_DISPLAY_DELAY);
await DevToolsUtils.waitForTime(SNAPSHOT_DATA_DISPLAY_DELAY);
CallsListView.showScreenshot(screenshot);
$("#screenshot-container").hidden = false;
window.emit(EVENTS.SNAPSHOT_RECORDING_SELECTED);
});
})();
},
/**
* The click listener for the "clear" button in this container.
*/
_onClearButtonClick: function () {
Task.spawn(function* () {
(async function () {
SnapshotsListView.empty();
CallsListView.empty();
@ -213,7 +213,7 @@ var SnapshotsListView = extend(WidgetMethods, {
$("#empty-notice").hidden = true;
$("#waiting-notice").hidden = true;
if (yield gFront.isInitialized()) {
if (await gFront.isInitialized()) {
$("#empty-notice").hidden = false;
} else {
$("#reload-notice").hidden = false;
@ -224,7 +224,7 @@ var SnapshotsListView = extend(WidgetMethods, {
$("#snapshot-filmstrip").hidden = true;
window.emit(EVENTS.SNAPSHOTS_LIST_CLEARED);
});
})();
},
/**
@ -270,7 +270,7 @@ var SnapshotsListView = extend(WidgetMethods, {
/**
* Begins recording an animation.
*/
_recordAnimation: Task.async(function* () {
async _recordAnimation() {
if (this._recording) {
return;
}
@ -279,7 +279,7 @@ var SnapshotsListView = extend(WidgetMethods, {
setNamedTimeout("canvas-actor-recording", CANVAS_ACTOR_RECORDING_ATTEMPT, this._stopRecordingAnimation);
yield DevToolsUtils.waitForTime(SNAPSHOT_START_RECORDING_DELAY);
await DevToolsUtils.waitForTime(SNAPSHOT_START_RECORDING_DELAY);
window.emit(EVENTS.SNAPSHOT_RECORDING_STARTED);
gFront.recordAnimationFrame().then(snapshot => {
@ -292,20 +292,20 @@ var SnapshotsListView = extend(WidgetMethods, {
// Wait another delay before reenabling the button to stop the recording
// if a recording is not found.
yield DevToolsUtils.waitForTime(SNAPSHOT_START_RECORDING_DELAY);
await DevToolsUtils.waitForTime(SNAPSHOT_START_RECORDING_DELAY);
this._enableRecordButton();
}),
},
/**
* Stops recording animation. Called when a click on the stopwatch occurs during a recording,
* or if a recording times out.
*/
_stopRecordingAnimation: Task.async(function* () {
async _stopRecordingAnimation() {
clearNamedTimeout("canvas-actor-recording");
let actorCanStop = yield gTarget.actorHasMethod("canvas", "stopRecordingAnimationFrame");
let actorCanStop = await gTarget.actorHasMethod("canvas", "stopRecordingAnimationFrame");
if (actorCanStop) {
yield gFront.stopRecordingAnimationFrame();
await gFront.stopRecordingAnimationFrame();
}
// If actor does not have the method to stop recording (Fx39+),
// manually call the record failure method. This will call a connection failure
@ -318,16 +318,16 @@ var SnapshotsListView = extend(WidgetMethods, {
this._recording = false;
$("#record-snapshot").removeAttribute("checked");
this._enableRecordButton();
}),
},
/**
* Resolves from the front's recordAnimationFrame to setup the interface with the screenshots.
*/
_onRecordSuccess: Task.async(function* (snapshotActor) {
async _onRecordSuccess(snapshotActor) {
// Clear bail-out case if frame found in CANVAS_ACTOR_RECORDING_ATTEMPT milliseconds
clearNamedTimeout("canvas-actor-recording");
let snapshotItem = this.getItemAtIndex(this.itemCount - 1);
let snapshotOverview = yield snapshotActor.getOverview();
let snapshotOverview = await snapshotActor.getOverview();
this.customizeSnapshot(snapshotItem, snapshotActor, snapshotOverview);
this._recording = false;
@ -335,7 +335,7 @@ var SnapshotsListView = extend(WidgetMethods, {
window.emit(EVENTS.SNAPSHOT_RECORDING_COMPLETED);
window.emit(EVENTS.SNAPSHOT_RECORDING_FINISHED);
}),
},
/**
* Called as a reject from the front's recordAnimationFrame.
@ -408,7 +408,7 @@ var SnapshotsListView = extend(WidgetMethods, {
// Start serializing all the function call actors for the specified snapshot,
// while the nsIFilePicker dialog is being opened. Snappy.
let serialized = Task.spawn(function* () {
let serialized = (async function () {
let data = {
fileType: CALLS_LIST_SERIALIZER_IDENTIFIER,
version: CALLS_LIST_SERIALIZER_VERSION,
@ -421,7 +421,7 @@ var SnapshotsListView = extend(WidgetMethods, {
let screenshot = snapshotItem.attachment.screenshot;
// Prepare all the function calls for serialization.
yield DevToolsUtils.yieldingEach(functionCalls, (call, i) => {
await DevToolsUtils.yieldingEach(functionCalls, (call, i) => {
let { type, name, file, line, timestamp, argsPreview, callerPreview } = call;
return call.getDetails().then(({ stack }) => {
data.calls[i] = {
@ -438,7 +438,7 @@ var SnapshotsListView = extend(WidgetMethods, {
});
// Prepare all the thumbnails for serialization.
yield DevToolsUtils.yieldingEach(thumbnails, (thumbnail, i) => {
await DevToolsUtils.yieldingEach(thumbnails, (thumbnail, i) => {
let { index, width, height, flipped, pixels } = thumbnail;
data.thumbnails.push({ index, width, height, flipped, pixels });
});
@ -453,7 +453,7 @@ var SnapshotsListView = extend(WidgetMethods, {
converter.charset = "UTF-8";
return converter.convertToInputStream(string);
});
})();
// Open the nsIFilePicker and wait for the function call actors to finish
// being serialized, in order to save the generated JSON data to disk.

View File

@ -6,12 +6,12 @@
* You can also use this initialization format as a template for other tests.
*/
function* ifTestingSupported() {
let { target, front } = yield initCallWatcherBackend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, front } = await initCallWatcherBackend(SIMPLE_CANVAS_URL);
ok(target, "Should have a target available.");
ok(front, "Should have a protocol front available.");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,12 +6,12 @@
* and that their stack is successfully retrieved.
*/
function* ifTestingSupported() {
let { target, front } = yield initCallWatcherBackend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, front } = await initCallWatcherBackend(SIMPLE_CANVAS_URL);
let navigated = once(target, "navigate");
yield front.setup({
await front.setup({
tracedGlobals: ["CanvasRenderingContext2D", "WebGLRenderingContext"],
startRecording: true,
performReload: true,
@ -19,13 +19,13 @@ function* ifTestingSupported() {
});
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
// Allow the content to execute some functions.
yield waitForTick();
await waitForTick();
let functionCalls = yield front.pauseRecording();
let functionCalls = await front.pauseRecording();
ok(functionCalls,
"An array of function call actors was sent after reloading.");
ok(functionCalls.length > 0,
@ -45,7 +45,7 @@ function* ifTestingSupported() {
is(functionCalls[0].argsPreview, "0, 0, 128, 128",
"The called function's args preview is correct.");
let details = yield functionCalls[1].getDetails();
let details = await functionCalls[1].getDetails();
ok(details,
"The first called function has some details available.");
@ -73,6 +73,6 @@ function* ifTestingSupported() {
is(details.stack[2].line, 33,
"The called function's stack is correct (3.3).");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,22 +6,22 @@
* for a canvas context.
*/
function* ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, front } = await initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let snapshotActor = await front.recordAnimationFrame();
ok(snapshotActor,
"A snapshot actor was sent after recording.");
let animationOverview = yield snapshotActor.getOverview();
let animationOverview = await snapshotActor.getOverview();
ok(snapshotActor,
"An animation overview could be retrieved after recording.");
@ -70,6 +70,6 @@ function* ifTestingSupported() {
is(functionCalls[7].callerPreview, "Object",
"The last called function's caller preview is correct.");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,22 +6,22 @@
* the correct thumbnails.
*/
function* ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, front } = await initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let snapshotActor = await front.recordAnimationFrame();
ok(snapshotActor,
"A snapshot actor was sent after recording.");
let animationOverview = yield snapshotActor.getOverview();
let animationOverview = await snapshotActor.getOverview();
ok(animationOverview,
"An animation overview could be retrieved after recording.");
@ -75,7 +75,7 @@ function* ifTestingSupported() {
is([].find.call(Uint32(thumbnails[3].pixels), e => e > 0), 4290822336,
"The fourth thumbnail's pixels seem to not be completely transparent.");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,22 +6,22 @@
* the correct "end result" screenshot.
*/
function* ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, front } = await initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let snapshotActor = await front.recordAnimationFrame();
ok(snapshotActor,
"A snapshot actor was sent after recording.");
let animationOverview = yield snapshotActor.getOverview();
let animationOverview = await snapshotActor.getOverview();
ok(snapshotActor,
"An animation overview could be retrieved after recording.");
@ -40,7 +40,7 @@ function* ifTestingSupported() {
is([].find.call(Uint32(screenshot.pixels), e => e > 0), 4290822336,
"The screenshot's pixels seem to not be completely transparent.");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -5,19 +5,19 @@
* Tests if screenshots for arbitrary draw calls are generated properly.
*/
function* ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(SIMPLE_CANVAS_TRANSPARENT_URL);
async function ifTestingSupported() {
let { target, front } = await initCanvasDebuggerBackend(SIMPLE_CANVAS_TRANSPARENT_URL);
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let animationOverview = yield snapshotActor.getOverview();
let snapshotActor = await front.recordAnimationFrame();
let animationOverview = await snapshotActor.getOverview();
let functionCalls = animationOverview.calls;
ok(functionCalls,
@ -34,10 +34,10 @@ function* ifTestingSupported() {
is(functionCalls[6].name, "fillRect",
"The fourth called function's name is correct.");
let firstDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]);
let secondDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[2]);
let thirdDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[4]);
let fourthDrawCallScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[6]);
let firstDrawCallScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[0]);
let secondDrawCallScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[2]);
let thirdDrawCallScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[4]);
let fourthDrawCallScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[6]);
ok(firstDrawCallScreenshot,
"The first draw call has a screenshot attached.");
@ -90,7 +90,7 @@ function* ifTestingSupported() {
isnot(thirdDrawCallScreenshot.pixels, fourthDrawCallScreenshot.pixels,
"The screenshots taken on consecutive draw calls are different (3).");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,19 +6,19 @@
* by deferring the the most recent previous draw-call.
*/
function* ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, front } = await initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let animationOverview = yield snapshotActor.getOverview();
let snapshotActor = await front.recordAnimationFrame();
let animationOverview = await snapshotActor.getOverview();
let functionCalls = animationOverview.calls;
ok(functionCalls,
@ -26,9 +26,9 @@ function* ifTestingSupported() {
is(functionCalls.length, 8,
"The number of function call actors is correct.");
let firstNonDrawCall = yield functionCalls[1].getDetails();
let secondNonDrawCall = yield functionCalls[3].getDetails();
let lastNonDrawCall = yield functionCalls[7].getDetails();
let firstNonDrawCall = await functionCalls[1].getDetails();
let secondNonDrawCall = await functionCalls[3].getDetails();
let lastNonDrawCall = await functionCalls[7].getDetails();
is(firstNonDrawCall.name, "fillStyle",
"The first non-draw function's name is correct.");
@ -37,9 +37,9 @@ function* ifTestingSupported() {
is(lastNonDrawCall.name, "requestAnimationFrame",
"The last non-draw function's name is correct.");
let firstScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[1]);
let secondScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[3]);
let lastScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[7]);
let firstScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[1]);
let secondScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[3]);
let lastScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[7]);
ok(firstScreenshot,
"A screenshot was successfully retrieved for the first non-draw function.");
@ -48,7 +48,7 @@ function* ifTestingSupported() {
ok(lastScreenshot,
"A screenshot was successfully retrieved for the last non-draw function.");
let firstActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]);
let firstActualScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[0]);
ok(sameArray(firstScreenshot.pixels, firstActualScreenshot.pixels),
"The screenshot for the first non-draw function is correct.");
is(firstScreenshot.width, 128,
@ -56,7 +56,7 @@ function* ifTestingSupported() {
is(firstScreenshot.height, 128,
"The screenshot for the first non-draw function has the correct height.");
let secondActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[2]);
let secondActualScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[2]);
ok(sameArray(secondScreenshot.pixels, secondActualScreenshot.pixels),
"The screenshot for the second non-draw function is correct.");
is(secondScreenshot.width, 128,
@ -64,7 +64,7 @@ function* ifTestingSupported() {
is(secondScreenshot.height, 128,
"The screenshot for the second non-draw function has the correct height.");
let lastActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[6]);
let lastActualScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[6]);
ok(sameArray(lastScreenshot.pixels, lastActualScreenshot.pixels),
"The screenshot for the last non-draw function is correct.");
is(lastScreenshot.width, 128,
@ -77,7 +77,7 @@ function* ifTestingSupported() {
ok(!sameArray(secondScreenshot.pixels, lastScreenshot.pixels),
"The screenshots taken on consecutive draw calls are different (2).");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,19 +6,19 @@
* forms if the method's signature does not expect an enum. Bug 999687.
*/
function* ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(SIMPLE_BITMASKS_URL);
async function ifTestingSupported() {
let { target, front } = await initCanvasDebuggerBackend(SIMPLE_BITMASKS_URL);
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let animationOverview = yield snapshotActor.getOverview();
let snapshotActor = await front.recordAnimationFrame();
let animationOverview = await snapshotActor.getOverview();
let functionCalls = animationOverview.calls;
is(functionCalls[0].name, "clearRect",
@ -31,6 +31,6 @@ function* ifTestingSupported() {
is(functionCalls[2].argsPreview, "0, 0, 1, 1",
"The fillRect called function's args preview is not casted to enums.");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,19 +6,19 @@
* forms if the method's signature does not expect an enum. Bug 999687.
*/
function* ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(WEBGL_ENUM_URL);
async function ifTestingSupported() {
let { target, front } = await initCanvasDebuggerBackend(WEBGL_ENUM_URL);
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let animationOverview = yield snapshotActor.getOverview();
let snapshotActor = await front.recordAnimationFrame();
let animationOverview = await snapshotActor.getOverview();
let functionCalls = animationOverview.calls;
is(functionCalls[0].name, "clear",
@ -31,6 +31,6 @@ function* ifTestingSupported() {
is(functionCalls[1].argsPreview, "TEXTURE_2D, null",
"The bits passed into `gl.bindTexture` have been cast to their enum values.");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,23 +6,23 @@
* after generating screenshots using the actor.
*/
function* ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(WEBGL_BINDINGS_URL);
async function ifTestingSupported() {
let { target, front } = await initCanvasDebuggerBackend(WEBGL_BINDINGS_URL);
loadFrameScriptUtils();
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let animationOverview = yield snapshotActor.getOverview();
let snapshotActor = await front.recordAnimationFrame();
let animationOverview = await snapshotActor.getOverview();
let functionCalls = animationOverview.calls;
let firstScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]);
let firstScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[0]);
is(firstScreenshot.index, -1,
"The first screenshot didn't encounter any draw call.");
is(firstScreenshot.scaling, 0.25,
@ -36,29 +36,29 @@ function* ifTestingSupported() {
is(firstScreenshot.pixels.length, 0,
"The first screenshot should be empty.");
is((yield evalInDebuggee("gl.getParameter(gl.FRAMEBUFFER_BINDING) === customFramebuffer")),
is((await evalInDebuggee("gl.getParameter(gl.FRAMEBUFFER_BINDING) === customFramebuffer")),
true,
"The debuggee's gl context framebuffer wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.RENDERBUFFER_BINDING) === customRenderbuffer")),
is((await evalInDebuggee("gl.getParameter(gl.RENDERBUFFER_BINDING) === customRenderbuffer")),
true,
"The debuggee's gl context renderbuffer wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.TEXTURE_BINDING_2D) === customTexture")),
is((await evalInDebuggee("gl.getParameter(gl.TEXTURE_BINDING_2D) === customTexture")),
true,
"The debuggee's gl context texture binding wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[0]")),
is((await evalInDebuggee("gl.getParameter(gl.VIEWPORT)[0]")),
128,
"The debuggee's gl context viewport's left coord. wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[1]")),
is((await evalInDebuggee("gl.getParameter(gl.VIEWPORT)[1]")),
256,
"The debuggee's gl context viewport's left coord. wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[2]")),
is((await evalInDebuggee("gl.getParameter(gl.VIEWPORT)[2]")),
384,
"The debuggee's gl context viewport's left coord. wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[3]")),
is((await evalInDebuggee("gl.getParameter(gl.VIEWPORT)[3]")),
512,
"The debuggee's gl context viewport's left coord. wasn't changed.");
let secondScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[1]);
let secondScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[1]);
is(secondScreenshot.index, 1,
"The second screenshot has the correct index.");
is(secondScreenshot.width, CanvasFront.WEBGL_SCREENSHOT_MAX_HEIGHT,
@ -80,28 +80,28 @@ function* ifTestingSupported() {
is(secondScreenshot.pixels[3], 255,
"The second screenshot has the correct alpha component.");
is((yield evalInDebuggee("gl.getParameter(gl.FRAMEBUFFER_BINDING) === customFramebuffer")),
is((await evalInDebuggee("gl.getParameter(gl.FRAMEBUFFER_BINDING) === customFramebuffer")),
true,
"The debuggee's gl context framebuffer still wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.RENDERBUFFER_BINDING) === customRenderbuffer")),
is((await evalInDebuggee("gl.getParameter(gl.RENDERBUFFER_BINDING) === customRenderbuffer")),
true,
"The debuggee's gl context renderbuffer still wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.TEXTURE_BINDING_2D) === customTexture")),
is((await evalInDebuggee("gl.getParameter(gl.TEXTURE_BINDING_2D) === customTexture")),
true,
"The debuggee's gl context texture binding still wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[0]")),
is((await evalInDebuggee("gl.getParameter(gl.VIEWPORT)[0]")),
128,
"The debuggee's gl context viewport's left coord. still wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[1]")),
is((await evalInDebuggee("gl.getParameter(gl.VIEWPORT)[1]")),
256,
"The debuggee's gl context viewport's left coord. still wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[2]")),
is((await evalInDebuggee("gl.getParameter(gl.VIEWPORT)[2]")),
384,
"The debuggee's gl context viewport's left coord. still wasn't changed.");
is((yield evalInDebuggee("gl.getParameter(gl.VIEWPORT)[3]")),
is((await evalInDebuggee("gl.getParameter(gl.VIEWPORT)[3]")),
512,
"The debuggee's gl context viewport's left coord. still wasn't changed.");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,22 +6,22 @@
* for a canvas context, and that the generated screenshots are correct.
*/
function* ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(SET_TIMEOUT_URL);
async function ifTestingSupported() {
let { target, front } = await initCanvasDebuggerBackend(SET_TIMEOUT_URL);
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let snapshotActor = await front.recordAnimationFrame();
ok(snapshotActor,
"A snapshot actor was sent after recording.");
let animationOverview = yield snapshotActor.getOverview();
let animationOverview = await snapshotActor.getOverview();
ok(snapshotActor,
"An animation overview could be retrieved after recording.");
@ -70,9 +70,9 @@ function* ifTestingSupported() {
is(functionCalls[7].callerPreview, "Object",
"The last called function's caller preview is correct.");
let firstNonDrawCall = yield functionCalls[1].getDetails();
let secondNonDrawCall = yield functionCalls[3].getDetails();
let lastNonDrawCall = yield functionCalls[7].getDetails();
let firstNonDrawCall = await functionCalls[1].getDetails();
let secondNonDrawCall = await functionCalls[3].getDetails();
let lastNonDrawCall = await functionCalls[7].getDetails();
is(firstNonDrawCall.name, "fillStyle",
"The first non-draw function's name is correct.");
@ -81,9 +81,9 @@ function* ifTestingSupported() {
is(lastNonDrawCall.name, "setTimeout",
"The last non-draw function's name is correct.");
let firstScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[1]);
let secondScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[3]);
let lastScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[7]);
let firstScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[1]);
let secondScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[3]);
let lastScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[7]);
ok(firstScreenshot,
"A screenshot was successfully retrieved for the first non-draw function.");
@ -92,7 +92,7 @@ function* ifTestingSupported() {
ok(lastScreenshot,
"A screenshot was successfully retrieved for the last non-draw function.");
let firstActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[0]);
let firstActualScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[0]);
ok(sameArray(firstScreenshot.pixels, firstActualScreenshot.pixels),
"The screenshot for the first non-draw function is correct.");
is(firstScreenshot.width, 128,
@ -100,7 +100,7 @@ function* ifTestingSupported() {
is(firstScreenshot.height, 128,
"The screenshot for the first non-draw function has the correct height.");
let secondActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[2]);
let secondActualScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[2]);
ok(sameArray(secondScreenshot.pixels, secondActualScreenshot.pixels),
"The screenshot for the second non-draw function is correct.");
is(secondScreenshot.width, 128,
@ -108,7 +108,7 @@ function* ifTestingSupported() {
is(secondScreenshot.height, 128,
"The screenshot for the second non-draw function has the correct height.");
let lastActualScreenshot = yield snapshotActor.generateScreenshotFor(functionCalls[6]);
let lastActualScreenshot = await snapshotActor.generateScreenshotFor(functionCalls[6]);
ok(sameArray(lastScreenshot.pixels, lastActualScreenshot.pixels),
"The screenshot for the last non-draw function is correct.");
is(lastScreenshot.width, 128,
@ -121,7 +121,7 @@ function* ifTestingSupported() {
ok(!sameArray(secondScreenshot.pixels, lastScreenshot.pixels),
"The screenshots taken on consecutive draw calls are different (2).");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,24 +6,24 @@
* in the event no rAF loop is found.
*/
function* ifTestingSupported() {
let { target, front } = yield initCanvasDebuggerBackend(NO_CANVAS_URL);
async function ifTestingSupported() {
let { target, front } = await initCanvasDebuggerBackend(NO_CANVAS_URL);
loadFrameScriptUtils();
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let startRecording = front.recordAnimationFrame();
yield front.stopRecordingAnimationFrame();
await front.stopRecordingAnimationFrame();
ok(!(yield startRecording),
ok(!(await startRecording),
"recordAnimationFrame() does not return a SnapshotActor when cancelled.");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -5,16 +5,16 @@
* Tests if certain function calls are properly highlighted in the UI.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, callListPopulated]);
await promise.all([recordingFinished, callListPopulated]);
is(CallsListView.itemCount, 8,
"All the function calls should now be displayed in the UI.");
@ -36,6 +36,6 @@ function* ifTestingSupported() {
is($(".call-item-view", CallsListView.getItemAtIndex(7).target).hasAttribute("draw-call"), false,
"The eigth item's node should not have a draw-call attribute.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -6,16 +6,16 @@
* are properly displayed in the UI.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, callListPopulated]);
await promise.all([recordingFinished, callListPopulated]);
is(CallsListView.itemCount, 8,
"All the function calls should now be displayed in the UI.");
@ -65,6 +65,6 @@ function* ifTestingSupported() {
"The item's location label has the correct text.");
}
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,17 +5,17 @@
* Tests if filtering the items in the call list works properly.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
let searchbox = $("#calls-searchbox");
yield reload(target);
await reload(target);
let firstRecordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([firstRecordingFinished, callListPopulated]);
await promise.all([firstRecordingFinished, callListPopulated]);
is(searchbox.value, "",
"The searchbox should be initially empty.");
@ -47,10 +47,10 @@ function* ifTestingSupported() {
callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
SnapshotsListView._onRecordButtonClick();
yield secondRecordingFinished;
await secondRecordingFinished;
SnapshotsListView.selectedIndex = 1;
yield callListPopulated;
await callListPopulated;
is(searchbox.value, "clear",
"The searchbox should still contain the 'clear' string.");
@ -67,6 +67,6 @@ function* ifTestingSupported() {
is(CallsListView.visibleItems.length, 8,
"All the items should be initially visible again in the calls list.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -7,20 +7,20 @@
// Force the old debugger UI since it's directly used (see Bug 1301705)
Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
registerCleanupFunction(function* () {
registerCleanupFunction(function() {
Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
});
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, callListPopulated]);
await promise.all([recordingFinished, callListPopulated]);
let callItem = CallsListView.getItemAtIndex(2);
let locationLink = $(".call-item-location", callItem.target);
@ -30,7 +30,7 @@ function* ifTestingSupported() {
let callStackDisplayed = once(window, EVENTS.CALL_STACK_DISPLAYED);
EventUtils.sendMouseEvent({ type: "mousedown" }, locationLink, window);
yield callStackDisplayed;
await callStackDisplayed;
isnot($(".call-item-stack", callItem.target), null,
"There should be a stack container available now for the draw call.");
@ -67,9 +67,9 @@ function* ifTestingSupported() {
let jumpedToSource = once(window, EVENTS.SOURCE_SHOWN_IN_JS_DEBUGGER);
EventUtils.sendMouseEvent({ type: "mousedown" }, $(".call-item-stack-fn-location", callItem.target));
yield jumpedToSource;
await jumpedToSource;
let toolbox = yield gDevTools.getToolbox(target);
let toolbox = await gDevTools.getToolbox(target);
let { panelWin: { DebuggerView: view } } = toolbox.getPanel("jsdebugger");
is(view.Sources.selectedValue, getSourceActor(view.Sources, SIMPLE_CANVAS_DEEP_STACK_URL),
@ -77,6 +77,6 @@ function* ifTestingSupported() {
is(view.editor.getCursor().line, 25,
"The expected source line is highlighted in the debugger.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -8,20 +8,20 @@
// Force the old debugger UI since it's directly used (see Bug 1301705)
Services.prefs.setBoolPref("devtools.debugger.new-debugger-frontend", false);
registerCleanupFunction(function* () {
registerCleanupFunction(function() {
Services.prefs.clearUserPref("devtools.debugger.new-debugger-frontend");
});
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, callListPopulated]);
await promise.all([recordingFinished, callListPopulated]);
let callItem = CallsListView.getItemAtIndex(2);
let locationLink = $(".call-item-location", callItem.target);
@ -31,7 +31,7 @@ function* ifTestingSupported() {
let callStackDisplayed = once(window, EVENTS.CALL_STACK_DISPLAYED);
EventUtils.sendMouseEvent({ type: "mousedown" }, locationLink, window);
yield callStackDisplayed;
await callStackDisplayed;
isnot($(".call-item-stack", callItem.target), null,
"There should be a stack container available now for the draw call.");
@ -42,9 +42,9 @@ function* ifTestingSupported() {
let jumpedToSource = once(window, EVENTS.SOURCE_SHOWN_IN_JS_DEBUGGER);
EventUtils.sendMouseEvent({ type: "mousedown" }, $(".call-item-location", callItem.target));
yield jumpedToSource;
await jumpedToSource;
let toolbox = yield gDevTools.getToolbox(target);
let toolbox = await gDevTools.getToolbox(target);
let { panelWin: { DebuggerView: view } } = toolbox.getPanel("jsdebugger");
is(view.Sources.selectedValue, getSourceActor(view.Sources, SIMPLE_CANVAS_DEEP_STACK_URL),
@ -52,6 +52,6 @@ function* ifTestingSupported() {
is(view.editor.getCursor().line, 23,
"The expected source line is highlighted in the debugger.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -6,16 +6,16 @@
* on a function call item.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_DEEP_STACK_URL);
let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, callListPopulated]);
await promise.all([recordingFinished, callListPopulated]);
let callItem = CallsListView.getItemAtIndex(2);
let view = $(".call-item-view", callItem.target);
@ -30,7 +30,7 @@ function* ifTestingSupported() {
let callStackDisplayed = once(window, EVENTS.CALL_STACK_DISPLAYED);
EventUtils.sendMouseEvent({ type: "dblclick" }, contents, window);
yield callStackDisplayed;
await callStackDisplayed;
is(view.hasAttribute("call-stack-populated"), true,
"The call item's view should have the stack populated now.");
@ -60,6 +60,6 @@ function* ifTestingSupported() {
ok($all(".call-item-stack-fn", callItem.target).length >= 4,
"There should still be at least 4 functions on the stack for the draw call.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,16 +5,16 @@
* Tests if clearing the snapshots list works as expected.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, EVENTS, SnapshotsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let firstRecordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
SnapshotsListView._onRecordButtonClick();
yield firstRecordingFinished;
await firstRecordingFinished;
ok(true, "Finished recording a snapshot of the animation loop.");
is(SnapshotsListView.itemCount, 1,
@ -23,7 +23,7 @@ function* ifTestingSupported() {
let secondRecordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
SnapshotsListView._onRecordButtonClick();
yield secondRecordingFinished;
await secondRecordingFinished;
ok(true, "Finished recording another snapshot of the animation loop.");
is(SnapshotsListView.itemCount, 2,
@ -32,12 +32,12 @@ function* ifTestingSupported() {
let clearingFinished = once(window, EVENTS.SNAPSHOTS_LIST_CLEARED);
SnapshotsListView._onClearButtonClick();
yield clearingFinished;
await clearingFinished;
ok(true, "Finished recording all snapshots.");
is(SnapshotsListView.itemCount, 0,
"There should be no items available in the snapshots list.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,17 +5,17 @@
* Tests if screenshots are properly displayed in the UI.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, EVENTS, SnapshotsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, callListPopulated, screenshotDisplayed]);
await promise.all([recordingFinished, callListPopulated, screenshotDisplayed]);
is($("#screenshot-container").hidden, false,
"The screenshot container should now be visible.");
@ -29,6 +29,6 @@ function* ifTestingSupported() {
ok(window.getComputedStyle($("#screenshot-image")).backgroundImage.includes("#screenshot-rendering"),
"The screenshot element should have an offscreen canvas element as a background.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,17 +5,17 @@
* Tests if thumbnails are properly displayed in the UI.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, $all, EVENTS, SnapshotsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, callListPopulated, thumbnailsDisplayed]);
await promise.all([recordingFinished, callListPopulated, thumbnailsDisplayed]);
is($all(".filmstrip-thumbnail").length, 4,
"There should be 4 thumbnails displayed in the UI.");
@ -60,6 +60,6 @@ function* ifTestingSupported() {
is(fourthThumbnail.getAttribute("flipped"), "false",
"The fourth thumbnail should not be flipped vertically.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -6,18 +6,18 @@
* function call items and their respective screenshots.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED);
let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([
await promise.all([
recordingFinished,
callListPopulated,
thumbnailsDisplayed,
@ -30,7 +30,7 @@ function* ifTestingSupported() {
"There should be no selected item in the calls list view.");
EventUtils.sendMouseEvent({ type: "mousedown" }, $all(".filmstrip-thumbnail")[0], window);
yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
await once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
info("The first draw call was selected, by clicking the first thumbnail.");
isnot($(".filmstrip-thumbnail[highlighted][index='0']"), null,
@ -41,7 +41,7 @@ function* ifTestingSupported() {
"The first draw call should be selected in the calls list view.");
EventUtils.sendMouseEvent({ type: "mousedown" }, $all(".call-item-view")[1], window);
yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
await once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
info("The second context call was selected, by clicking the second call item.");
isnot($(".filmstrip-thumbnail[highlighted][index='0']"), null,
@ -52,7 +52,7 @@ function* ifTestingSupported() {
"The second draw call should be selected in the calls list view.");
EventUtils.sendMouseEvent({ type: "mousedown" }, $all(".call-item-view")[2], window);
yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
await once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
info("The second draw call was selected, by clicking the third call item.");
isnot($(".filmstrip-thumbnail[highlighted][index='2']"), null,
@ -62,6 +62,6 @@ function* ifTestingSupported() {
is(CallsListView.selectedIndex, 2,
"The second draw call should be selected in the calls list view.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,8 +5,8 @@
* Tests that the frontend UI is properly configured when opening the tool.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { $ } = panel.panelWin;
is($("#snapshots-pane").hasAttribute("hidden"), false,
@ -36,6 +36,6 @@ function* ifTestingSupported() {
is($("#debugging-pane-contents").getAttribute("hidden"), "true",
"The rest of the UI should initially be hidden.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,11 +5,11 @@
* Tests whether the frontend behaves correctly while reording a snapshot.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, EVENTS, $, SnapshotsListView } = panel.panelWin;
yield reload(target);
await reload(target);
is($("#record-snapshot").hasAttribute("checked"), false,
"The 'record snapshot' button should initially be unchecked.");
@ -27,7 +27,7 @@ function* ifTestingSupported() {
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
SnapshotsListView._onRecordButtonClick();
yield recordingStarted;
await recordingStarted;
ok(true, "Started recording a snapshot of the animation loop.");
is($("#record-snapshot").getAttribute("checked"), "true",
@ -40,7 +40,7 @@ function* ifTestingSupported() {
is(SnapshotsListView.selectedIndex, -1,
"There should be no selected item in the snapshots list view yet.");
yield recordingFinished;
await recordingFinished;
ok(true, "Finished recording a snapshot of the animation loop.");
is($("#record-snapshot").hasAttribute("checked"), false,
@ -55,6 +55,6 @@ function* ifTestingSupported() {
is(SnapshotsListView.selectedIndex, 0,
"There should be one selected item in the snapshots list view now.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,18 +5,18 @@
* Tests whether the frontend displays a placeholder snapshot while recording.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, EVENTS, L10N, $, SnapshotsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingStarted = once(window, EVENTS.SNAPSHOT_RECORDING_STARTED);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let recordingSelected = once(window, EVENTS.SNAPSHOT_RECORDING_SELECTED);
SnapshotsListView._onRecordButtonClick();
yield recordingStarted;
await recordingStarted;
ok(true, "Started recording a snapshot of the animation loop.");
let item = SnapshotsListView.getItemAtIndex(0);
@ -47,10 +47,10 @@ function* ifTestingSupported() {
is($("#debugging-pane-contents").getAttribute("hidden"), "true",
"The rest of the UI should still be hidden.");
yield recordingFinished;
await recordingFinished;
ok(true, "Finished recording a snapshot of the animation loop.");
yield recordingSelected;
await recordingSelected;
ok(true, "Finished selecting a snapshot of the animation loop.");
is($("#reload-notice").getAttribute("hidden"), "true",
@ -68,6 +68,6 @@ function* ifTestingSupported() {
is($("#debugging-pane-contents").hasAttribute("hidden"), false,
"The rest of the UI should now be visible.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -6,16 +6,16 @@
* after finishing recording.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, EVENTS, $, SnapshotsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
SnapshotsListView._onRecordButtonClick();
yield recordingFinished;
await recordingFinished;
ok(true, "Finished recording a snapshot of the animation loop.");
let item = SnapshotsListView.getItemAtIndex(0);
@ -32,6 +32,6 @@ function* ifTestingSupported() {
is($(".snapshot-item-save", item.target).getAttribute("disabled"), "false",
"The placeholder item's save label should be clickable.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -8,12 +8,12 @@
* of its loop, when the recording starts before the rAFs start.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(RAF_BEGIN_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(RAF_BEGIN_URL);
let { window, EVENTS, gFront, SnapshotsListView } = panel.panelWin;
loadFrameScriptUtils();
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
SnapshotsListView._onRecordButtonClick();
@ -21,14 +21,14 @@ function* ifTestingSupported() {
// Wait until after the recording started to trigger the content.
// Use the gFront method rather than the SNAPSHOT_RECORDING_STARTED event
// which triggers before the underlying actor call
yield waitUntil(function* () { return !(yield gFront.isRecording()); });
await waitUntil(async function () { return !(await gFront.isRecording()); });
// Start animation in content
evalInDebuggee("start();");
yield recordingFinished;
await recordingFinished;
ok(true, "Finished recording a snapshot of the animation loop.");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -5,17 +5,17 @@
* Tests that the frontend UI is properly reconfigured after reloading.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, EVENTS } = panel.panelWin;
let reset = once(window, EVENTS.UI_RESET);
let navigated = reload(target);
yield reset;
await reset;
ok(true, "The UI was reset after the refresh button was clicked.");
yield navigated;
await navigated;
ok(true, "The target finished reloading.");
is($("#snapshots-pane").hasAttribute("hidden"), false,
@ -50,6 +50,6 @@ function* ifTestingSupported() {
is($("#debugging-pane-contents").getAttribute("hidden"), "true",
"The rest of the UI should still be hidden.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,8 +5,8 @@
* Tests that the frontend UI is properly reconfigured after reloading.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, $all, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
is(SnapshotsListView.itemCount, 0,
@ -21,14 +21,14 @@ function* ifTestingSupported() {
is($all(".filmstrip-thumbnail").length, 0,
"There should be no thumbnails initially displayed in the UI (2).");
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED);
let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([
await promise.all([
recordingFinished,
callListPopulated,
thumbnailsDisplayed,
@ -50,7 +50,7 @@ function* ifTestingSupported() {
let reset = once(window, EVENTS.UI_RESET);
let navigated = reload(target);
yield reset;
await reset;
ok(true, "The UI was reset after the refresh button was clicked.");
is(SnapshotsListView.itemCount, 0,
@ -62,9 +62,9 @@ function* ifTestingSupported() {
is($("#screenshot-container").hidden, true,
"The screenshot should not be displayed in the UI after navigating.");
yield navigated;
await navigated;
ok(true, "The target finished reloading.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,16 +5,16 @@
* Tests if the slider in the calls list view works as advertised.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, callListPopulated]);
await promise.all([recordingFinished, callListPopulated]);
is(CallsListView.selectedIndex, -1,
"No item in the function calls list should be initially selected.");
@ -34,6 +34,6 @@ function* ifTestingSupported() {
is(CallsListView.selectedIndex, 2,
"The calls selection should be changed according to the current slider value.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,20 +5,20 @@
* Tests if the slider in the calls list view works as advertised.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, EVENTS, gFront, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
let thumbnailsDisplayed = once(window, EVENTS.THUMBNAILS_DISPLAYED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, callListPopulated, thumbnailsDisplayed]);
await promise.all([recordingFinished, callListPopulated, thumbnailsDisplayed]);
let firstSnapshot = SnapshotsListView.getItemAtIndex(0);
let firstSnapshotOverview = yield firstSnapshot.attachment.actor.getOverview();
let firstSnapshotOverview = await firstSnapshot.attachment.actor.getOverview();
let thumbnails = firstSnapshotOverview.thumbnails;
is(thumbnails.length, 4,
@ -26,55 +26,55 @@ function* ifTestingSupported() {
let thumbnailImageElementSet = waitForMozSetImageElement(window);
$("#calls-slider").value = 1;
let thumbnailPixels = yield thumbnailImageElementSet;
let thumbnailPixels = await thumbnailImageElementSet;
ok(sameArray(thumbnailPixels, thumbnails[0].pixels),
"The screenshot element should have a thumbnail as an immediate background.");
yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
await once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
ok(true, "The full-sized screenshot was displayed for the item at index 1.");
thumbnailImageElementSet = waitForMozSetImageElement(window);
$("#calls-slider").value = 2;
thumbnailPixels = yield thumbnailImageElementSet;
thumbnailPixels = await thumbnailImageElementSet;
ok(sameArray(thumbnailPixels, thumbnails[1].pixels),
"The screenshot element should have a thumbnail as an immediate background.");
yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
await once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
ok(true, "The full-sized screenshot was displayed for the item at index 2.");
thumbnailImageElementSet = waitForMozSetImageElement(window);
$("#calls-slider").value = 7;
thumbnailPixels = yield thumbnailImageElementSet;
thumbnailPixels = await thumbnailImageElementSet;
ok(sameArray(thumbnailPixels, thumbnails[3].pixels),
"The screenshot element should have a thumbnail as an immediate background.");
yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
await once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
ok(true, "The full-sized screenshot was displayed for the item at index 7.");
thumbnailImageElementSet = waitForMozSetImageElement(window);
$("#calls-slider").value = 4;
thumbnailPixels = yield thumbnailImageElementSet;
thumbnailPixels = await thumbnailImageElementSet;
ok(sameArray(thumbnailPixels, thumbnails[2].pixels),
"The screenshot element should have a thumbnail as an immediate background.");
yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
await once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
ok(true, "The full-sized screenshot was displayed for the item at index 4.");
thumbnailImageElementSet = waitForMozSetImageElement(window);
$("#calls-slider").value = 0;
thumbnailPixels = yield thumbnailImageElementSet;
thumbnailPixels = await thumbnailImageElementSet;
ok(sameArray(thumbnailPixels, thumbnails[0].pixels),
"The screenshot element should have a thumbnail as an immediate background.");
yield once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
await once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
ok(true, "The full-sized screenshot was displayed for the item at index 0.");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -6,13 +6,13 @@
* respective to their recorded animation frame.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
yield recordAndWaitForFirstSnapshot();
await recordAndWaitForFirstSnapshot();
info("First snapshot recorded.");
is(SnapshotsListView.selectedIndex, 0,
@ -20,7 +20,7 @@ function* ifTestingSupported() {
is(CallsListView.selectedIndex, -1,
"There should be no call item automatically selected in the snapshot.");
yield recordAndWaitForAnotherSnapshot();
await recordAndWaitForAnotherSnapshot();
info("Second snapshot recorded.");
is(SnapshotsListView.selectedIndex, 0,
@ -32,7 +32,7 @@ function* ifTestingSupported() {
let snapshotSelected = waitForSnapshotSelection();
EventUtils.sendMouseEvent({ type: "mousedown" }, secondSnapshotTarget, window);
yield snapshotSelected;
await snapshotSelected;
info("Second snapshot selected.");
is(SnapshotsListView.selectedIndex, 1,
@ -44,7 +44,7 @@ function* ifTestingSupported() {
let screenshotDisplayed = once(window, EVENTS.CALL_SCREENSHOT_DISPLAYED);
EventUtils.sendMouseEvent({ type: "mousedown" }, firstDrawCallContents, window);
yield screenshotDisplayed;
await screenshotDisplayed;
info("First draw call in the second snapshot selected.");
is(SnapshotsListView.selectedIndex, 1,
@ -56,7 +56,7 @@ function* ifTestingSupported() {
snapshotSelected = waitForSnapshotSelection();
EventUtils.sendMouseEvent({ type: "mousedown" }, firstSnapshotTarget, window);
yield snapshotSelected;
await snapshotSelected;
info("First snapshot re-selected.");
is(SnapshotsListView.selectedIndex, 0,
@ -88,6 +88,6 @@ function* ifTestingSupported() {
]);
}
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -6,11 +6,11 @@
* respective to their recorded animation frame.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
SnapshotsListView._onRecordButtonClick();
let snapshotTarget = SnapshotsListView.getItemAtIndex(0).target;
@ -23,8 +23,8 @@ function* ifTestingSupported() {
let finished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
SnapshotsListView._onRecordButtonClick();
yield finished;
await finished;
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,16 +5,16 @@
* Tests if the stepping buttons in the call list toolbar work as advertised.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(SIMPLE_CANVAS_URL);
let { window, $, EVENTS, SnapshotsListView, CallsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let callListPopulated = once(window, EVENTS.CALL_LIST_POPULATED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, callListPopulated]);
await promise.all([recordingFinished, callListPopulated]);
checkSteppingButtons(1, 1, 1, 1);
is(CallsListView.selectedIndex, -1,
@ -71,6 +71,6 @@ function* ifTestingSupported() {
}
}
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,16 +5,16 @@
* Tests that you can stop a recording that does not have a rAF cycle.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(NO_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(NO_CANVAS_URL);
let { window, EVENTS, $, SnapshotsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingStarted = once(window, EVENTS.SNAPSHOT_RECORDING_STARTED);
SnapshotsListView._onRecordButtonClick();
yield recordingStarted;
await recordingStarted;
is($("#empty-notice").hidden, true, "Empty notice not shown");
is($("#waiting-notice").hidden, false, "Waiting notice shown");
@ -23,7 +23,7 @@ function* ifTestingSupported() {
let recordingCancelled = once(window, EVENTS.SNAPSHOT_RECORDING_CANCELLED);
SnapshotsListView._onRecordButtonClick();
yield promise.all([recordingFinished, recordingCancelled]);
await promise.all([recordingFinished, recordingCancelled]);
ok(true, "Recording stopped and was considered failed.");
@ -31,6 +31,6 @@ function* ifTestingSupported() {
is($("#empty-notice").hidden, false, "Empty notice shown");
is($("#waiting-notice").hidden, true, "Waiting notice not shown");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -5,16 +5,16 @@
* Tests that a recording that does not have a rAF cycle fails after timeout.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(NO_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(NO_CANVAS_URL);
let { window, EVENTS, $, SnapshotsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingStarted = once(window, EVENTS.SNAPSHOT_RECORDING_STARTED);
SnapshotsListView._onRecordButtonClick();
yield recordingStarted;
await recordingStarted;
is($("#empty-notice").hidden, true, "Empty notice not shown");
is($("#waiting-notice").hidden, false, "Waiting notice shown");
@ -22,7 +22,7 @@ function* ifTestingSupported() {
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let recordingCancelled = once(window, EVENTS.SNAPSHOT_RECORDING_CANCELLED);
yield promise.all([recordingFinished, recordingCancelled]);
await promise.all([recordingFinished, recordingCancelled]);
ok(true, "Recording stopped and was considered failed.");
@ -30,6 +30,6 @@ function* ifTestingSupported() {
is($("#empty-notice").hidden, false, "Empty notice shown");
is($("#waiting-notice").hidden, true, "Waiting notice not shown");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -6,16 +6,16 @@
* after timeout.
*/
function* ifTestingSupported() {
let { target, panel } = yield initCanvasDebuggerFrontend(RAF_NO_CANVAS_URL);
async function ifTestingSupported() {
let { target, panel } = await initCanvasDebuggerFrontend(RAF_NO_CANVAS_URL);
let { window, EVENTS, $, SnapshotsListView } = panel.panelWin;
yield reload(target);
await reload(target);
let recordingStarted = once(window, EVENTS.SNAPSHOT_RECORDING_STARTED);
SnapshotsListView._onRecordButtonClick();
yield recordingStarted;
await recordingStarted;
is($("#empty-notice").hidden, true, "Empty notice not shown");
is($("#waiting-notice").hidden, false, "Waiting notice shown");
@ -23,7 +23,7 @@ function* ifTestingSupported() {
let recordingFinished = once(window, EVENTS.SNAPSHOT_RECORDING_FINISHED);
let recordingCancelled = once(window, EVENTS.SNAPSHOT_RECORDING_CANCELLED);
yield promise.all([recordingFinished, recordingCancelled]);
await promise.all([recordingFinished, recordingCancelled]);
ok(true, "Recording stopped and was considered failed.");
@ -31,6 +31,6 @@ function* ifTestingSupported() {
is($("#empty-notice").hidden, false, "Empty notice shown");
is($("#waiting-notice").hidden, true, "Waiting notice not shown");
yield teardown(panel);
await teardown(panel);
finish();
}

View File

@ -6,23 +6,23 @@
* for a canvas context profiling.
*/
function* ifTestingSupported() {
async function ifTestingSupported() {
let currentTime = window.performance.now();
let { target, front } = yield initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
let { target, front } = await initCanvasDebuggerBackend(SIMPLE_CANVAS_URL);
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let snapshotActor = await front.recordAnimationFrame();
ok(snapshotActor,
"A snapshot actor was sent after recording.");
let animationOverview = yield snapshotActor.getOverview();
let animationOverview = await snapshotActor.getOverview();
ok(animationOverview,
"An animation overview could be retrieved after recording.");
@ -40,6 +40,6 @@ function* ifTestingSupported() {
ok(functionCalls[i + 1].timestamp >= functionCalls[i].timestamp, "The timestamp of the called function is correct.");
}
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -6,24 +6,24 @@
* for a canvas context profiling.
*/
function* ifTestingSupported() {
async function ifTestingSupported() {
let currentTime = window.performance.now();
info("Start to estimate WebGL drawArrays function.");
var { target, front } = yield initCanvasDebuggerBackend(WEBGL_DRAW_ARRAYS);
var { target, front } = await initCanvasDebuggerBackend(WEBGL_DRAW_ARRAYS);
let navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
let snapshotActor = yield front.recordAnimationFrame();
let snapshotActor = await front.recordAnimationFrame();
ok(snapshotActor,
"A snapshot actor was sent after recording.");
let animationOverview = yield snapshotActor.getOverview();
let animationOverview = await snapshotActor.getOverview();
ok(animationOverview,
"An animation overview could be retrieved after recording.");
@ -39,24 +39,24 @@ function* ifTestingSupported() {
is(animationOverview.primitive.points, 4, "The count of points is correct.");
is(animationOverview.primitive.lines, 8, "The count of lines is correct.");
yield removeTab(target.tab);
await removeTab(target.tab);
info("Start to estimate WebGL drawElements function.");
var { target, front } = yield initCanvasDebuggerBackend(WEBGL_DRAW_ELEMENTS);
var { target, front } = await initCanvasDebuggerBackend(WEBGL_DRAW_ELEMENTS);
navigated = once(target, "navigate");
yield front.setup({ reload: true });
await front.setup({ reload: true });
ok(true, "The front was setup up successfully.");
yield navigated;
await navigated;
ok(true, "Target automatically navigated when the front was set up.");
snapshotActor = yield front.recordAnimationFrame();
snapshotActor = await front.recordAnimationFrame();
ok(snapshotActor,
"A snapshot actor was sent after recording.");
animationOverview = yield snapshotActor.getOverview();
animationOverview = await snapshotActor.getOverview();
ok(animationOverview,
"An animation overview could be retrieved after recording.");
@ -72,7 +72,7 @@ function* ifTestingSupported() {
is(animationOverview.primitive.points, 4, "The count of points is correct.");
is(animationOverview.primitive.lines, 8, "The count of lines is correct.");
yield removeTab(target.tab);
await removeTab(target.tab);
finish();
}

View File

@ -68,9 +68,13 @@ function ifTestingUnsupported() {
finish();
}
function test() {
async function test() {
let generator = isTestingSupported() ? ifTestingSupported : ifTestingUnsupported;
Task.spawn(generator).catch(handleError);
try {
await generator();
} catch(e) {
handleError(e);
}
}
function createCanvas() {
@ -114,46 +118,46 @@ function initCallWatcherBackend(aUrl) {
info("Initializing a call watcher front.");
initServer();
return Task.spawn(function* () {
let tab = yield addTab(aUrl);
return (async function () {
let tab = await addTab(aUrl);
let target = TargetFactory.forTab(tab);
yield target.makeRemote();
await target.makeRemote();
let front = new CallWatcherFront(target.client, target.form);
return { target, front };
});
})();
}
function initCanvasDebuggerBackend(aUrl) {
info("Initializing a canvas debugger front.");
initServer();
return Task.spawn(function* () {
let tab = yield addTab(aUrl);
return (async function () {
let tab = await addTab(aUrl);
let target = TargetFactory.forTab(tab);
yield target.makeRemote();
await target.makeRemote();
let front = new CanvasFront(target.client, target.form);
return { target, front };
});
})();
}
function initCanvasDebuggerFrontend(aUrl) {
info("Initializing a canvas debugger pane.");
return Task.spawn(function* () {
let tab = yield addTab(aUrl);
return (async function () {
let tab = await addTab(aUrl);
let target = TargetFactory.forTab(tab);
yield target.makeRemote();
await target.makeRemote();
Services.prefs.setBoolPref("devtools.canvasdebugger.enabled", true);
let toolbox = yield gDevTools.showToolbox(target, "canvasdebugger");
let toolbox = await gDevTools.showToolbox(target, "canvasdebugger");
let panel = toolbox.getCurrentPanel();
return { target, panel };
});
})();
}
function teardown({target}) {

View File

@ -12,6 +12,7 @@ const TEST_BASE_HTTPS = "https://example.com/browser/devtools/client/commandline
var { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
var flags = require("devtools/shared/flags");
var { Task } = require("devtools/shared/task");
// Import the GCLI test helper
var testDir = gTestPath.substr(0, gTestPath.lastIndexOf("/"));

View File

@ -38,6 +38,7 @@ Services.scriptloader.loadSubScript(
this
);
var { Toolbox } = require("devtools/client/framework/toolbox");
var { Task } = require("devtools/shared/task");
const sourceUtils = {
isLoaded: source => source.get("loadedState") === "loaded"
};

View File

@ -21,6 +21,7 @@ var ObjectClient = require("devtools/shared/client/object-client");
var { AddonManager } = ChromeUtils.import("resource://gre/modules/AddonManager.jsm", {});
var EventEmitter = require("devtools/shared/old-event-emitter");
var { Toolbox } = require("devtools/client/framework/toolbox");
var { Task } = require("devtools/shared/task");
const chromeRegistry = Cc["@mozilla.org/chrome/chrome-registry;1"].getService(Ci.nsIChromeRegistry);

View File

@ -10,7 +10,6 @@ const ObjectClient = require("devtools/shared/client/object-client");
const defer = require("devtools/shared/defer");
const EventEmitter = require("devtools/shared/old-event-emitter");
const { Task } = require("devtools/shared/task");
/**
* This object represents DOM panel. It's responsibility is to
@ -36,7 +35,7 @@ DomPanel.prototype = {
* @return object
* A promise that is resolved when the DOM panel completes opening.
*/
open: Task.async(function* () {
async open() {
if (this._opening) {
return this._opening;
}
@ -46,7 +45,7 @@ DomPanel.prototype = {
// Local monitoring needs to make the target remote.
if (!this.target.isRemote) {
yield this.target.makeRemote();
await this.target.makeRemote();
}
this.initialize();
@ -56,7 +55,7 @@ DomPanel.prototype = {
deferred.resolve(this);
return this._opening;
}),
},
// Initialization
@ -78,7 +77,7 @@ DomPanel.prototype = {
this.shouldRefresh = true;
},
destroy: Task.async(function* () {
async destroy() {
if (this._destroying) {
return this._destroying;
}
@ -93,7 +92,7 @@ DomPanel.prototype = {
deferred.resolve();
return this._destroying;
}),
},
// Events

View File

@ -14,13 +14,13 @@ const TEST_ARRAY = [
/**
* Basic test that checks content of the DOM panel.
*/
add_task(function* () {
add_task(async function () {
info("Test DOM Panel Array Expansion started");
let { panel } = yield addTestTab(TEST_PAGE_URL);
let { panel } = await addTestTab(TEST_PAGE_URL);
// Expand specified row and wait till children are displayed.
yield expandRow(panel, "_a");
await expandRow(panel, "_a");
// Verify that children is displayed now.
let childRows = getAllRowsForLabel(panel, "_a");

View File

@ -10,13 +10,13 @@ const TEST_PAGE_URL = URL_ROOT + "page_basic.html";
/**
* Basic test that checks content of the DOM panel.
*/
add_task(function* () {
add_task(async function () {
info("Test DOM panel basic started");
let { panel } = yield addTestTab(TEST_PAGE_URL);
let { panel } = await addTestTab(TEST_PAGE_URL);
// Expand specified row and wait till children are displayed.
yield expandRow(panel, "_a");
await expandRow(panel, "_a");
// Verify that child is displayed now.
let childRow = getRowByLabel(panel, "_data");

View File

@ -10,14 +10,14 @@ const TEST_PAGE_URL = URL_ROOT + "page_basic.html";
/**
* Basic test that checks the Refresh action in DOM panel.
*/
add_task(function* () {
add_task(async function () {
info("Test DOM panel basic started");
let { panel } = yield addTestTab(TEST_PAGE_URL);
let { panel } = await addTestTab(TEST_PAGE_URL);
// Create a new variable in the page scope and refresh the panel.
yield evaluateJSAsync(panel, "var _b = 10");
yield refreshPanel(panel);
await evaluateJSAsync(panel, "var _b = 10");
await refreshPanel(panel);
// Verify that the variable is displayed now.
let row = getRowByLabel(panel, "_b");

View File

@ -225,12 +225,12 @@ function waitForDispatch(panel, type, eventRepeat = 1) {
const actionType = constants[type];
let count = 0;
return Task.spawn(function* () {
return (async function () {
info("Waiting for " + type + " to dispatch " + eventRepeat + " time(s)");
while (count < eventRepeat) {
yield _afterDispatchDone(store, actionType);
await _afterDispatchDone(store, actionType);
count++;
info(type + " dispatched " + count + " time(s)");
}
});
})();
}

View File

@ -12,7 +12,6 @@ var {gDevTools} = require("devtools/client/framework/devtools");
var {TargetFactory} = require("devtools/client/framework/target");
var {Toolbox} = require("devtools/client/framework/toolbox");
var {DebuggerClient} = require("devtools/shared/client/debugger-client");
var {Task} = require("devtools/shared/task");
var {LocalizationHelper} = require("devtools/shared/l10n");
var L10N = new LocalizationHelper("devtools/client/locales/connection-screen.properties");
@ -48,7 +47,7 @@ window.addEventListener("DOMContentLoaded", function () {
/**
* Called when the "connect" button is clicked.
*/
var submit = Task.async(function* () {
var submit = async function () {
// Show the "connecting" screen
document.body.classList.add("connecting");
@ -64,23 +63,23 @@ var submit = Task.async(function* () {
}
// Initiate the connection
let transport = yield DebuggerClient.socketConnect({ host, port });
let transport = await DebuggerClient.socketConnect({ host, port });
gClient = new DebuggerClient(transport);
let delay = Services.prefs.getIntPref("devtools.debugger.remote-timeout");
gConnectionTimeout = setTimeout(handleConnectionTimeout, delay);
let response = yield gClient.connect();
yield onConnectionReady(...response);
});
let response = await gClient.connect();
await onConnectionReady(...response);
};
/**
* Connection is ready. List actors and build buttons.
*/
var onConnectionReady = Task.async(function* ([aType, aTraits]) {
var onConnectionReady = async function ([aType, aTraits]) {
clearTimeout(gConnectionTimeout);
let addons = [];
try {
let response = yield gClient.listAddons();
let response = await gClient.listAddons();
if (!response.error && response.addons.length > 0) {
addons = response.addons;
}
@ -104,7 +103,7 @@ var onConnectionReady = Task.async(function* ([aType, aTraits]) {
parent.remove();
}
let response = yield gClient.listTabs();
let response = await gClient.listTabs();
parent = document.getElementById("tabActors");
@ -156,7 +155,7 @@ var onConnectionReady = Task.async(function* ([aType, aTraits]) {
if (firstLink) {
firstLink.focus();
}
});
};
/**
* Build one button for an add-on actor.

View File

@ -25,7 +25,6 @@ loader.lazyRequireGetter(this, "WebExtensionInspectedWindowFront",
const {defaultTools: DefaultTools, defaultThemes: DefaultThemes} =
require("devtools/client/definitions");
const EventEmitter = require("devtools/shared/old-event-emitter");
const {Task} = require("devtools/shared/task");
const {getTheme, setTheme, addThemeObserver, removeThemeObserver} =
require("devtools/client/shared/theme");
@ -453,15 +452,15 @@ DevTools.prototype = {
* @return {Toolbox} toolbox
* The toolbox that was opened
*/
showToolbox: Task.async(function* (target, toolId, hostType, hostOptions, startTime) {
async showToolbox(target, toolId, hostType, hostOptions, startTime) {
let toolbox = this._toolboxes.get(target);
if (toolbox) {
if (hostType != null && toolbox.hostType != hostType) {
yield toolbox.switchHost(hostType);
await toolbox.switchHost(hostType);
}
if (toolId != null && toolbox.currentToolId != toolId) {
yield toolbox.selectTool(toolId);
await toolbox.selectTool(toolId);
}
toolbox.raise();
@ -471,11 +470,11 @@ DevTools.prototype = {
// actually trying to create a new one.
let promise = this._creatingToolboxes.get(target);
if (promise) {
return yield promise;
return promise;
}
let toolboxPromise = this.createToolbox(target, toolId, hostType, hostOptions);
this._creatingToolboxes.set(target, toolboxPromise);
toolbox = yield toolboxPromise;
toolbox = await toolboxPromise;
this._creatingToolboxes.delete(target);
if (startTime) {
@ -484,7 +483,7 @@ DevTools.prototype = {
this._firstShowToolbox = false;
}
return toolbox;
}),
},
/**
* Log telemetry related to toolbox opening.
@ -508,10 +507,10 @@ DevTools.prototype = {
histogram.add(toolId, delay);
},
createToolbox: Task.async(function* (target, toolId, hostType, hostOptions) {
async createToolbox(target, toolId, hostType, hostOptions) {
let manager = new ToolboxHostManager(target, hostType, hostOptions);
let toolbox = yield manager.create(toolId);
let toolbox = await manager.create(toolId);
this._toolboxes.set(target, toolbox);
@ -526,11 +525,11 @@ DevTools.prototype = {
this.emit("toolbox-destroyed", target);
});
yield toolbox.open();
await toolbox.open();
this.emit("toolbox-ready", toolbox);
return toolbox;
}),
},
/**
* Return the toolbox for a given target.
@ -553,17 +552,17 @@ DevTools.prototype = {
* associated to the target. true, if the toolbox was successfully
* closed.
*/
closeToolbox: Task.async(function* (target) {
let toolbox = yield this._creatingToolboxes.get(target);
async closeToolbox(target) {
let toolbox = await this._creatingToolboxes.get(target);
if (!toolbox) {
toolbox = this._toolboxes.get(target);
}
if (!toolbox) {
return false;
}
yield toolbox.destroy();
await toolbox.destroy();
return true;
}),
},
/**
* Wrapper on TargetFactory.forTab, constructs a Target for the provided tab.

View File

@ -5,7 +5,6 @@
"use strict";
var Services = require("Services");
var {Task} = require("devtools/shared/task");
var EventEmitter = require("devtools/shared/event-emitter");
var Telemetry = require("devtools/client/shared/telemetry");
@ -335,7 +334,7 @@ ToolSidebar.prototype = {
* @param {String} tabPanelId Optional. If provided, this ID will be used
* instead of the tabId to retrieve and remove the corresponding <tabpanel>
*/
removeTab: Task.async(function* (tabId, tabPanelId) {
async removeTab(tabId, tabPanelId) {
// Remove the tab if it can be found
let tab = this.getTab(tabId);
if (!tab) {
@ -344,7 +343,7 @@ ToolSidebar.prototype = {
let win = this.getWindowForTab(tabId);
if (win && ("destroy" in win)) {
yield win.destroy();
await win.destroy();
}
tab.remove();
@ -357,7 +356,7 @@ ToolSidebar.prototype = {
this._tabs.delete(tabId);
this.emit("tab-unregistered", tabId);
}),
},
/**
* Show or hide a specific tab.
@ -549,7 +548,7 @@ ToolSidebar.prototype = {
/**
* Clean-up.
*/
destroy: Task.async(function* () {
async destroy() {
if (this._destroyed) {
return;
}
@ -570,7 +569,7 @@ ToolSidebar.prototype = {
let panel = this._tabbox.tabpanels.firstChild;
let win = panel.firstChild.contentWindow;
if (win && ("destroy" in win)) {
yield win.destroy();
await win.destroy();
}
panel.remove();
}
@ -589,5 +588,5 @@ ToolSidebar.prototype = {
this._tabbox = null;
this._panelDoc = null;
this._toolPanel = null;
})
}
};

View File

@ -10,7 +10,7 @@ PromiseTestUtils.whitelistRejectionsGlobally(/File closed/);
// On debug test slave, it takes about 50s to run the test.
requestLongerTimeout(4);
add_task(async function() {
add_task(async function () {
await new Promise(done => {
let options = {"set": [
["devtools.debugger.prompt-connection", false],

View File

@ -20,8 +20,8 @@ const { fetch } = require("devtools/shared/DevToolsUtils");
const debuggerHeadURL = CHROME_URL_ROOT + "../../debugger/new/test/mochitest/head.js";
const testScriptURL = CHROME_URL_ROOT + "test_browser_toolbox_debugger.js";
add_task(function* runTest() {
yield new Promise(done => {
add_task(async function runTest() {
await new Promise(done => {
let options = {"set": [
["devtools.debugger.prompt-connection", false],
["devtools.debugger.remote-enabled", true],
@ -96,7 +96,6 @@ add_task(function* runTest() {
const registerCleanupFunction = () => {};
const { Task } = ChromeUtils.import("resource://gre/modules/Task.jsm", {});
const { require } = ChromeUtils.import("resource://devtools/shared/Loader.jsm", {});
const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm", {});
@ -119,7 +118,7 @@ add_task(function* runTest() {
// to ensure inner symbols gets exposed to next pieces of code
// Then inject new debugger head file
let { content } = yield fetch(debuggerHeadURL);
let { content } = await fetch(debuggerHeadURL);
let debuggerHead = content;
// We remove its import of shared-head, which isn't available in browser toolbox process
// And isn't needed thanks to testHead's symbols
@ -127,7 +126,7 @@ add_task(function* runTest() {
// Finally, fetch the debugger test script that is going to be execute in the browser
// toolbox process
let testScript = (yield fetch(testScriptURL)).content;
let testScript = (await fetch(testScriptURL)).content;
let source =
"try { let testUrl = \""+testUrl+"\";" + testHead + debuggerHead + testScript + "} catch (e) {" +
" dump('Exception: '+ e + ' at ' + e.fileName + ':' + " +
@ -142,7 +141,7 @@ add_task(function* runTest() {
// Use two promises, one for each BrowserToolboxProcess.init callback
// arguments, to ensure that we wait for toolbox run and close events.
let closePromise;
yield new Promise(onRun => {
await new Promise(onRun => {
closePromise = new Promise(onClose => {
info("Opening the browser toolbox\n");
BrowserToolboxProcess.init(onClose, onRun);
@ -150,7 +149,7 @@ add_task(function* runTest() {
});
ok(true, "Browser toolbox started\n");
yield closePromise;
await closePromise;
ok(true, "Browser toolbox process just closed");
clearInterval(interval);

View File

@ -139,7 +139,7 @@ function runTests2() {
});
}
var continueTests = Task.async(function* (toolbox, panel) {
var continueTests = async function (toolbox, panel) {
ok(toolbox.getCurrentPanel(), "panel value is correct");
is(toolbox.currentToolId, toolId2, "toolbox _currentToolId is correct");
@ -151,11 +151,11 @@ var continueTests = Task.async(function* (toolbox, panel) {
info("Testing toolbox tool-unregistered event");
let toolSelected = toolbox.once("select");
let unregisteredTool = yield new Promise(resolve => {
let unregisteredTool = await new Promise(resolve => {
toolbox.once("tool-unregistered", (e, id) => resolve(id));
gDevTools.unregisterTool(toolId2);
});
yield toolSelected;
await toolSelected;
is(unregisteredTool, toolId2, "Event returns correct id");
ok(!toolbox.isToolRegistered(toolId2),
@ -164,7 +164,7 @@ var continueTests = Task.async(function* (toolbox, panel) {
"The tool is no longer registered");
info("Testing toolbox tool-registered event");
let registeredTool = yield new Promise(resolve => {
let registeredTool = await new Promise(resolve => {
toolbox.once("tool-registered", (e, id) => resolve(id));
gDevTools.registerTool(toolDefinition);
});
@ -180,7 +180,7 @@ var continueTests = Task.async(function* (toolbox, panel) {
info("Destroying toolbox");
destroyToolbox(toolbox);
});
};
function destroyToolbox(toolbox) {
toolbox.destroy().then(function () {

View File

@ -8,26 +8,26 @@
// Test that network requests originating from the toolbox don't get recorded in
// the network panel.
add_task(function* () {
add_task(async function () {
// TODO: This test tries to verify the normal behavior of the netmonitor and
// therefore needs to avoid the explicit check for tests. Bug 1167188 will
// allow us to remove this workaround.
let isTesting = flags.testing;
flags.testing = false;
let tab = yield addTab(URL_ROOT + "doc_viewsource.html");
let tab = await addTab(URL_ROOT + "doc_viewsource.html");
let target = TargetFactory.forTab(tab);
let toolbox = yield gDevTools.showToolbox(target, "styleeditor");
let toolbox = await gDevTools.showToolbox(target, "styleeditor");
let panel = toolbox.getPanel("styleeditor");
is(panel.UI.editors.length, 1, "correct number of editors opened");
let monitor = yield toolbox.selectTool("netmonitor");
let monitor = await toolbox.selectTool("netmonitor");
let { store, windowRequire } = monitor.panelWin;
is(store.getState().requests.requests.size, 0, "No network requests appear in the network panel");
yield gDevTools.closeToolbox(target);
await gDevTools.closeToolbox(target);
tab = target = toolbox = panel = null;
gBrowser.removeCurrentTab();
flags.testing = isTesting;

View File

@ -18,24 +18,24 @@ function getZoomValue() {
return parseFloat(Services.prefs.getCharPref("devtools.toolbox.zoomValue"));
}
add_task(function* () {
add_task(async function () {
info("Create a test tab and open the toolbox");
let tab = yield addTab(URL);
let tab = await addTab(URL);
let target = TargetFactory.forTab(tab);
let toolbox = yield gDevTools.showToolbox(target, "webconsole");
let toolbox = await gDevTools.showToolbox(target, "webconsole");
let {SIDE, BOTTOM} = Toolbox.HostType;
for (let type of [SIDE, BOTTOM, SIDE]) {
info("Switch to host type " + type);
yield toolbox.switchHost(type);
await toolbox.switchHost(type);
info("Try to use the toolbox shortcuts");
yield checkKeyBindings(toolbox);
await checkKeyBindings(toolbox);
}
Services.prefs.clearUserPref("devtools.toolbox.zoomValue");
Services.prefs.setCharPref("devtools.toolbox.host", BOTTOM);
yield toolbox.destroy();
await toolbox.destroy();
gBrowser.removeCurrentTab();
});
@ -51,7 +51,7 @@ function zoomWithKey(toolbox, key) {
isnot(getZoomValue(), currentZoom, "The zoom level was changed in the toolbox");
}
function* checkKeyBindings(toolbox) {
function checkKeyBindings(toolbox) {
zoomWithKey(toolbox, "toolbox.zoomIn.key");
zoomWithKey(toolbox, "toolbox.zoomIn2.key");
zoomWithKey(toolbox, "toolbox.zoomIn3.key");

View File

@ -15,11 +15,11 @@ var {Toolbox} = require("devtools/client/framework/toolbox");
const {LocalizationHelper} = require("devtools/shared/l10n");
const L10N = new LocalizationHelper("devtools/client/locales/toolbox.properties");
add_task(function* () {
add_task(async function () {
info("Create a test tab and open the toolbox");
let tab = yield addTab(URL);
let tab = await addTab(URL);
let target = TargetFactory.forTab(tab);
let toolbox = yield gDevTools.showToolbox(target, "webconsole");
let toolbox = await gDevTools.showToolbox(target, "webconsole");
let shortcut = L10N.getStr("toolbox.toggleHost.key");
@ -29,25 +29,25 @@ add_task(function* () {
info("Switching from bottom to side");
let onHostChanged = toolbox.once("host-changed");
synthesizeKeyShortcut(shortcut, toolbox.win);
yield onHostChanged;
await onHostChanged;
checkHostType(toolbox, SIDE, BOTTOM);
info("Switching from side to bottom");
onHostChanged = toolbox.once("host-changed");
synthesizeKeyShortcut(shortcut, toolbox.win);
yield onHostChanged;
await onHostChanged;
checkHostType(toolbox, BOTTOM, SIDE);
info("Switching to window");
yield toolbox.switchHost(WINDOW);
await toolbox.switchHost(WINDOW);
checkHostType(toolbox, WINDOW, BOTTOM);
info("Switching from window to bottom");
onHostChanged = toolbox.once("host-changed");
synthesizeKeyShortcut(shortcut, toolbox.win);
yield onHostChanged;
await onHostChanged;
checkHostType(toolbox, BOTTOM, WINDOW);
yield toolbox.destroy();
await toolbox.destroy();
gBrowser.removeCurrentTab();
});

View File

@ -11,18 +11,18 @@ const URL = "data:text/html;charset=utf8,test page for menu api";
const Menu = require("devtools/client/framework/menu");
const MenuItem = require("devtools/client/framework/menu-item");
add_task(function* () {
add_task(async function () {
info("Create a test tab and open the toolbox");
let tab = yield addTab(URL);
let tab = await addTab(URL);
let target = TargetFactory.forTab(tab);
let toolbox = yield gDevTools.showToolbox(target, "webconsole");
let toolbox = await gDevTools.showToolbox(target, "webconsole");
yield testMenuItems();
yield testMenuPopup(toolbox);
yield testSubmenu(toolbox);
await testMenuItems();
await testMenuPopup(toolbox);
await testSubmenu(toolbox);
});
function* testMenuItems() {
function testMenuItems() {
let menu = new Menu();
let menuItem1 = new MenuItem();
let menuItem2 = new MenuItem();
@ -35,7 +35,7 @@ function* testMenuItems() {
is(menu.items[1], menuItem2, "Correct reference to MenuItem");
}
function* testMenuPopup(toolbox) {
async function testMenuPopup(toolbox) {
let clickFired = false;
let menu = new Menu({
@ -102,16 +102,16 @@ function* testMenuPopup(toolbox) {
is(menuItems[3].getAttribute("label"), MENU_ITEMS[3].label, "Correct label");
is(menuItems[3].getAttribute("disabled"), "true", "disabled attr menuitem");
yield once(menu, "open");
await once(menu, "open");
let closed = once(menu, "close");
EventUtils.synthesizeMouseAtCenter(menuItems[0], {}, toolbox.win);
yield closed;
await closed;
ok(clickFired, "Click has fired");
ok(!toolbox.doc.querySelector("#menu-popup"), "Popup removed from the DOM");
}
function* testSubmenu(toolbox) {
async function testSubmenu(toolbox) {
let clickFired = false;
let menu = new Menu({
id: "menu-popup",
@ -156,26 +156,26 @@ function* testSubmenu(toolbox) {
is(subMenuItems.length, 1, "Correct number of submenu items");
is(subMenuItems[0].getAttribute("label"), "Submenu item", "Correct label");
yield once(menu, "open");
await once(menu, "open");
let closed = once(menu, "close");
info("Using keyboard navigation to open, close, and reopen the submenu");
let shown = once(menus[0], "popupshown");
EventUtils.synthesizeKey("KEY_ArrowDown");
EventUtils.synthesizeKey("KEY_ArrowRight");
yield shown;
await shown;
let hidden = once(menus[0], "popuphidden");
EventUtils.synthesizeKey("KEY_ArrowLeft");
yield hidden;
await hidden;
shown = once(menus[0], "popupshown");
EventUtils.synthesizeKey("KEY_ArrowRight");
yield shown;
await shown;
info("Clicking the submenu item");
EventUtils.synthesizeMouseAtCenter(subMenuItems[0], {}, toolbox.win);
yield closed;
await closed;
ok(clickFired, "Click has fired");
}

View File

@ -20,26 +20,26 @@ const PAGE_URL = `${URL_ROOT}doc_empty-tab-01.html`;
const JS_URL = `${URL_ROOT}code_binary_search.js`;
const COFFEE_URL = `${URL_ROOT}code_binary_search.coffee`;
add_task(function* () {
yield pushPref("devtools.debugger.new-debugger-frontend", true);
add_task(async function () {
await pushPref("devtools.debugger.new-debugger-frontend", true);
const toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
const toolbox = await openNewTabAndToolbox(PAGE_URL, "jsdebugger");
const service = toolbox.sourceMapURLService;
// Inject JS script
let sourceSeen = waitForSourceLoad(toolbox, JS_URL);
yield createScript(JS_URL);
yield sourceSeen;
await createScript(JS_URL);
await sourceSeen;
let loc1 = { url: JS_URL, line: 6 };
let newLoc1 = yield service.originalPositionFor(loc1.url, loc1.line, 4);
let newLoc1 = await service.originalPositionFor(loc1.url, loc1.line, 4);
checkLoc1(loc1, newLoc1);
let loc2 = { url: JS_URL, line: 8, column: 3 };
let newLoc2 = yield service.originalPositionFor(loc2.url, loc2.line, loc2.column);
let newLoc2 = await service.originalPositionFor(loc2.url, loc2.line, loc2.column);
checkLoc2(loc2, newLoc2);
yield toolbox.destroy();
await toolbox.destroy();
gBrowser.removeCurrentTab();
finish();
});

View File

@ -15,19 +15,19 @@ const PAGE_URL = `${URL_ROOT}doc_empty-tab-01.html`;
const JS_URL = `${URL_ROOT}code_binary_search_absolute.js`;
const ORIGINAL_URL = `${URL_ROOT}code_binary_search.coffee`;
add_task(function* () {
yield pushPref("devtools.debugger.new-debugger-frontend", true);
add_task(async function () {
await pushPref("devtools.debugger.new-debugger-frontend", true);
const toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
const toolbox = await openNewTabAndToolbox(PAGE_URL, "jsdebugger");
const service = toolbox.sourceMapURLService;
// Inject JS script
let sourceSeen = waitForSourceLoad(toolbox, JS_URL);
yield createScript(JS_URL);
yield sourceSeen;
await createScript(JS_URL);
await sourceSeen;
info(`checking original location for ${JS_URL}:6`);
let newLoc = yield service.originalPositionFor(JS_URL, 6, 4);
let newLoc = await service.originalPositionFor(JS_URL, 6, 4);
is(newLoc.sourceUrl, ORIGINAL_URL, "check mapped URL");
is(newLoc.line, 4, "check mapped line number");

View File

@ -28,12 +28,12 @@ const ORIGINAL_URL = "webpack:///code_cross_domain.js";
const GENERATED_LINE = 82;
const ORIGINAL_LINE = 12;
add_task(function* () {
const toolbox = yield openNewTabAndToolbox(PAGE_URL, "webconsole");
add_task(async function () {
const toolbox = await openNewTabAndToolbox(PAGE_URL, "webconsole");
const service = toolbox.sourceMapURLService;
info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
let newLoc = yield service.originalPositionFor(JS_URL, GENERATED_LINE);
let newLoc = await service.originalPositionFor(JS_URL, GENERATED_LINE);
is(newLoc.sourceUrl, ORIGINAL_URL, "check mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check mapped line number");
});

View File

@ -28,16 +28,16 @@ const ORIGINAL_URL = "webpack:///code_no_race.js";
const GENERATED_LINE = 84;
const ORIGINAL_LINE = 11;
add_task(function* () {
add_task(async function () {
// Opening the debugger causes the source actors to be created.
const toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
const toolbox = await openNewTabAndToolbox(PAGE_URL, "jsdebugger");
// In bug 1391768, when the sourceMapURLService was created, it was
// ignoring any source actors that already existed, leading to
// source-mapping failures for those.
const service = toolbox.sourceMapURLService;
info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
let newLoc = yield service.originalPositionFor(JS_URL, GENERATED_LINE);
let newLoc = await service.originalPositionFor(JS_URL, GENERATED_LINE);
is(newLoc.sourceUrl, ORIGINAL_URL, "check mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check mapped line number");
});

View File

@ -17,24 +17,24 @@ const PAGE_URL = `${TEST_ROOT}doc_empty-tab-01.html`;
const JS_URL = `${TEST_ROOT}code_inline_bundle.js`;
const ORIGINAL_URL = "webpack:///code_inline_original.js";
add_task(function* () {
yield pushPref("devtools.debugger.new-debugger-frontend", true);
add_task(async function () {
await pushPref("devtools.debugger.new-debugger-frontend", true);
const toolbox = yield openNewTabAndToolbox(PAGE_URL, "jsdebugger");
const toolbox = await openNewTabAndToolbox(PAGE_URL, "jsdebugger");
const service = toolbox.sourceMapURLService;
// Inject JS script
let sourceSeen = waitForSourceLoad(toolbox, JS_URL);
yield createScript(JS_URL);
yield sourceSeen;
await createScript(JS_URL);
await sourceSeen;
info(`checking original location for ${JS_URL}:84`);
let newLoc = yield service.originalPositionFor(JS_URL, 84);
let newLoc = await service.originalPositionFor(JS_URL, 84);
is(newLoc.sourceUrl, ORIGINAL_URL, "check mapped URL");
is(newLoc.line, 11, "check mapped line number");
yield toolbox.destroy();
await toolbox.destroy();
gBrowser.removeCurrentTab();
finish();
});

View File

@ -28,14 +28,14 @@ const ORIGINAL_URL = "webpack:///code_no_race.js";
const GENERATED_LINE = 84;
const ORIGINAL_LINE = 11;
add_task(function* () {
add_task(async function () {
// Start with the empty page, then navigate, so that we can properly
// listen for new sources arriving.
const toolbox = yield openNewTabAndToolbox(PAGE_URL, "webconsole");
const toolbox = await openNewTabAndToolbox(PAGE_URL, "webconsole");
const service = toolbox.sourceMapURLService;
info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
let newLoc = yield service.originalPositionFor(JS_URL, GENERATED_LINE);
let newLoc = await service.originalPositionFor(JS_URL, GENERATED_LINE);
is(newLoc.sourceUrl, ORIGINAL_URL, "check mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check mapped line number");
});

View File

@ -15,36 +15,36 @@ const ORIGINAL_URL_2 = "webpack:///code_reload_2.js";
const GENERATED_LINE = 86;
const ORIGINAL_LINE = 13;
add_task(function* () {
yield pushPref("devtools.debugger.new-debugger-frontend", true);
add_task(async function () {
await pushPref("devtools.debugger.new-debugger-frontend", true);
// Start with the empty page, then navigate, so that we can properly
// listen for new sources arriving.
const toolbox = yield openNewTabAndToolbox(INITIAL_URL, "webconsole");
const toolbox = await openNewTabAndToolbox(INITIAL_URL, "webconsole");
const service = toolbox.sourceMapURLService;
const tab = toolbox.target.tab;
let sourceSeen = waitForSourceLoad(toolbox, JS_URL);
tab.linkedBrowser.loadURI(PAGE_URL);
yield sourceSeen;
await sourceSeen;
info(`checking original location for ${JS_URL}:${GENERATED_LINE}`);
let newLoc = yield service.originalPositionFor(JS_URL, GENERATED_LINE);
let newLoc = await service.originalPositionFor(JS_URL, GENERATED_LINE);
is(newLoc.sourceUrl, ORIGINAL_URL_1, "check mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check mapped line number");
// Reload the page. The sjs ensures that a different source file
// will be loaded.
sourceSeen = waitForSourceLoad(toolbox, JS_URL);
yield refreshTab();
yield sourceSeen;
await refreshTab();
await sourceSeen;
info(`checking post-reload original location for ${JS_URL}:${GENERATED_LINE}`);
newLoc = yield service.originalPositionFor(JS_URL, GENERATED_LINE);
newLoc = await service.originalPositionFor(JS_URL, GENERATED_LINE);
is(newLoc.sourceUrl, ORIGINAL_URL_2, "check post-reload mapped URL");
is(newLoc.line, ORIGINAL_LINE, "check post-reload mapped line number");
yield toolbox.destroy();
await toolbox.destroy();
gBrowser.removeCurrentTab();
finish();
});

View File

@ -23,14 +23,14 @@ function assertIsTabTarget(target, url, chrome = false) {
is(target.isRemote, true);
}
add_task(function* () {
let tab = yield addTab(TEST_URI);
add_task(async function () {
let tab = await addTab(TEST_URI);
let browser = tab.linkedBrowser;
let target;
info("Test invalid type");
try {
yield targetFromURL(new URL("http://foo?type=x"));
await targetFromURL(new URL("http://foo?type=x"));
ok(false, "Shouldn't pass");
} catch (e) {
is(e.message, "targetFromURL, unsupported type 'x' parameter");
@ -40,7 +40,7 @@ add_task(function* () {
let windowId = window.QueryInterface(Ci.nsIInterfaceRequestor)
.getInterface(Ci.nsIDOMWindowUtils)
.outerWindowID;
target = yield targetFromURL(new URL("http://foo?type=window&id=" + windowId));
target = await targetFromURL(new URL("http://foo?type=window&id=" + windowId));
is(target.url, window.location.href);
is(target.isLocalTab, false);
is(target.chrome, true);
@ -49,33 +49,33 @@ add_task(function* () {
info("Test tab");
windowId = browser.outerWindowID;
target = yield targetFromURL(new URL("http://foo?type=tab&id=" + windowId));
target = await targetFromURL(new URL("http://foo?type=tab&id=" + windowId));
assertIsTabTarget(target, TEST_URI);
info("Test tab with chrome privileges");
target = yield targetFromURL(new URL("http://foo?type=tab&id=" + windowId + "&chrome"));
target = await targetFromURL(new URL("http://foo?type=tab&id=" + windowId + "&chrome"));
assertIsTabTarget(target, TEST_URI, true);
info("Test invalid tab id");
try {
yield targetFromURL(new URL("http://foo?type=tab&id=10000"));
await targetFromURL(new URL("http://foo?type=tab&id=10000"));
ok(false, "Shouldn't pass");
} catch (e) {
is(e.message, "targetFromURL, tab with outerWindowID '10000' doesn't exist");
}
info("Test parent process");
target = yield targetFromURL(new URL("http://foo?type=process"));
target = await targetFromURL(new URL("http://foo?type=process"));
let topWindow = Services.wm.getMostRecentWindow("navigator:browser");
assertIsTabTarget(target, topWindow.location.href, true);
yield testRemoteTCP();
yield testRemoteWebSocket();
await testRemoteTCP();
await testRemoteWebSocket();
gBrowser.removeCurrentTab();
});
function* setupDebuggerServer(websocket) {
async function setupDebuggerServer(websocket) {
info("Create a separate loader instance for the DebuggerServer.");
let loader = new DevToolsLoader();
let { DebuggerServer } = loader.require("devtools/server/main");
@ -89,7 +89,7 @@ function* setupDebuggerServer(websocket) {
// Pass -1 to automatically choose an available port
listener.portOrPath = -1;
listener.webSocket = websocket;
yield listener.open();
await listener.open();
is(DebuggerServer.listeningSockets, 1, "1 listening socket");
return { DebuggerServer, listener };
@ -104,13 +104,13 @@ function teardownDebuggerServer({ DebuggerServer, listener }) {
DebuggerServer.destroy();
}
function* testRemoteTCP() {
async function testRemoteTCP() {
info("Test remote process via TCP Connection");
let server = yield setupDebuggerServer(false);
let server = await setupDebuggerServer(false);
let { port } = server.listener;
let target = yield targetFromURL(new URL("http://foo?type=process&host=127.0.0.1&port=" + port));
let target = await targetFromURL(new URL("http://foo?type=process&host=127.0.0.1&port=" + port));
let topWindow = Services.wm.getMostRecentWindow("navigator:browser");
assertIsTabTarget(target, topWindow.location.href, true);
@ -119,18 +119,18 @@ function* testRemoteTCP() {
is(settings.port, port);
is(settings.webSocket, false);
yield target.client.close();
await target.client.close();
teardownDebuggerServer(server);
}
function* testRemoteWebSocket() {
async function testRemoteWebSocket() {
info("Test remote process via WebSocket Connection");
let server = yield setupDebuggerServer(true);
let server = await setupDebuggerServer(true);
let { port } = server.listener;
let target = yield targetFromURL(new URL("http://foo?type=process&host=127.0.0.1&port=" + port + "&ws=true"));
let target = await targetFromURL(new URL("http://foo?type=process&host=127.0.0.1&port=" + port + "&ws=true"));
let topWindow = Services.wm.getMostRecentWindow("navigator:browser");
assertIsTabTarget(target, topWindow.location.href, true);
@ -138,7 +138,7 @@ function* testRemoteWebSocket() {
is(settings.host, "127.0.0.1");
is(settings.port, port);
is(settings.webSocket, true);
yield target.client.close();
await target.client.close();
teardownDebuggerServer(server);
}

View File

@ -9,8 +9,8 @@
var { WebAudioFront } =
require("devtools/shared/fronts/webaudio");
function* testTarget(client, target) {
yield target.makeRemote();
async function testTarget(client, target) {
await target.makeRemote();
is(target.hasActor("timeline"), true, "target.hasActor() true when actor exists.");
is(target.hasActor("webaudio"), true, "target.hasActor() true when actor exists.");
@ -18,27 +18,27 @@ function* testTarget(client, target) {
// Create a front to ensure the actor is loaded
let front = new WebAudioFront(target.client, target.form);
let desc = yield target.getActorDescription("webaudio");
let desc = await target.getActorDescription("webaudio");
is(desc.typeName, "webaudio",
"target.getActorDescription() returns definition data for corresponding actor");
is(desc.events["start-context"]["type"], "startContext",
"target.getActorDescription() returns event data for corresponding actor");
desc = yield target.getActorDescription("nope");
desc = await target.getActorDescription("nope");
is(desc, undefined, "target.getActorDescription() returns undefined for non-existing actor");
desc = yield target.getActorDescription();
desc = await target.getActorDescription();
is(desc, undefined, "target.getActorDescription() returns undefined for undefined actor");
let hasMethod = yield target.actorHasMethod("audionode", "getType");
let hasMethod = await target.actorHasMethod("audionode", "getType");
is(hasMethod, true,
"target.actorHasMethod() returns true for existing actor with method");
hasMethod = yield target.actorHasMethod("audionode", "nope");
hasMethod = await target.actorHasMethod("audionode", "nope");
is(hasMethod, false,
"target.actorHasMethod() returns false for existing actor with no method");
hasMethod = yield target.actorHasMethod("nope", "nope");
hasMethod = await target.actorHasMethod("nope", "nope");
is(hasMethod, false,
"target.actorHasMethod() returns false for non-existing actor with no method");
hasMethod = yield target.actorHasMethod();
hasMethod = await target.actorHasMethod();
is(hasMethod, false,
"target.actorHasMethod() returns false for undefined params");

View File

@ -10,27 +10,27 @@ var toolbox = null;
const URL = "data:text/html;charset=utf8,test for getPanelWhenReady";
add_task(function* () {
let tab = yield addTab(URL);
add_task(async function () {
let tab = await addTab(URL);
let target = TargetFactory.forTab(tab);
toolbox = yield gDevTools.showToolbox(target);
toolbox = await gDevTools.showToolbox(target);
let debuggerPanelPromise = toolbox.getPanelWhenReady("jsdebugger");
yield toolbox.selectTool("jsdebugger");
let debuggerPanel = yield debuggerPanelPromise;
await toolbox.selectTool("jsdebugger");
let debuggerPanel = await debuggerPanelPromise;
is(debuggerPanel, toolbox.getPanel("jsdebugger"),
"The debugger panel from getPanelWhenReady before loading is the actual panel");
let debuggerPanel2 = yield toolbox.getPanelWhenReady("jsdebugger");
let debuggerPanel2 = await toolbox.getPanelWhenReady("jsdebugger");
is(debuggerPanel2, toolbox.getPanel("jsdebugger"),
"The debugger panel from getPanelWhenReady after loading is the actual panel");
yield cleanup();
await cleanup();
});
function* cleanup() {
yield toolbox.destroy();
async function cleanup() {
await toolbox.destroy();
gBrowser.removeCurrentTab();
toolbox = null;
}

View File

@ -10,49 +10,49 @@ var {Toolbox} = require("devtools/client/framework/toolbox");
var toolbox = null;
function test() {
Task.spawn(function* () {
(async function () {
const URL = "data:text/plain;charset=UTF-8,Nothing to see here, move along";
const TOOL_ID_1 = "jsdebugger";
const TOOL_ID_2 = "webconsole";
yield addTab(URL);
await addTab(URL);
const target = TargetFactory.forTab(gBrowser.selectedTab);
toolbox = yield gDevTools.showToolbox(target, TOOL_ID_1, Toolbox.HostType.BOTTOM);
toolbox = await gDevTools.showToolbox(target, TOOL_ID_1, Toolbox.HostType.BOTTOM);
// select tool 2
yield toolbox.selectTool(TOOL_ID_2);
await toolbox.selectTool(TOOL_ID_2);
// and highlight the first one
yield highlightTab(TOOL_ID_1);
await highlightTab(TOOL_ID_1);
// to see if it has the proper class.
yield checkHighlighted(TOOL_ID_1);
await checkHighlighted(TOOL_ID_1);
// Now switch back to first tool
yield toolbox.selectTool(TOOL_ID_1);
await toolbox.selectTool(TOOL_ID_1);
// to check again. But there is no easy way to test if
// it is showing orange or not.
yield checkNoHighlightWhenSelected(TOOL_ID_1);
await checkNoHighlightWhenSelected(TOOL_ID_1);
// Switch to tool 2 again
yield toolbox.selectTool(TOOL_ID_2);
await toolbox.selectTool(TOOL_ID_2);
// and check again.
yield checkHighlighted(TOOL_ID_1);
await checkHighlighted(TOOL_ID_1);
// Highlight another tool
yield highlightTab(TOOL_ID_2);
await highlightTab(TOOL_ID_2);
// Check that both tools are highlighted.
yield checkHighlighted(TOOL_ID_1);
await checkHighlighted(TOOL_ID_1);
// Check second tool being both highlighted and selected.
yield checkNoHighlightWhenSelected(TOOL_ID_2);
await checkNoHighlightWhenSelected(TOOL_ID_2);
// Select tool 1
yield toolbox.selectTool(TOOL_ID_1);
await toolbox.selectTool(TOOL_ID_1);
// Check second tool is still highlighted
yield checkHighlighted(TOOL_ID_2);
await checkHighlighted(TOOL_ID_2);
// Unhighlight the second tool
yield unhighlightTab(TOOL_ID_2);
await unhighlightTab(TOOL_ID_2);
// to see the classes gone.
yield checkNoHighlight(TOOL_ID_2);
await checkNoHighlight(TOOL_ID_2);
// Now unhighlight the tool
yield unhighlightTab(TOOL_ID_1);
await unhighlightTab(TOOL_ID_1);
// to see the classes gone.
yield checkNoHighlight(TOOL_ID_1);
await checkNoHighlight(TOOL_ID_1);
// Now close the toolbox and exit.
executeSoon(() => {
@ -62,7 +62,7 @@ function test() {
finish();
});
});
})
})()
.catch(error => {
ok(false, "There was an error running the test.");
});

View File

@ -11,27 +11,27 @@ var toolbox, target;
const URL = "data:text/html;charset=utf8,test for opening toolbox in different hosts";
add_task(function* runTest() {
add_task(async function runTest() {
info("Create a test tab and open the toolbox");
let tab = yield addTab(URL);
let tab = await addTab(URL);
target = TargetFactory.forTab(tab);
toolbox = yield gDevTools.showToolbox(target, "webconsole");
toolbox = await gDevTools.showToolbox(target, "webconsole");
yield testBottomHost();
yield testSidebarHost();
yield testWindowHost();
yield testToolSelect();
yield testDestroy();
yield testRememberHost();
yield testPreviousHost();
await testBottomHost();
await testSidebarHost();
await testWindowHost();
await testToolSelect();
await testDestroy();
await testRememberHost();
await testPreviousHost();
yield toolbox.destroy();
await toolbox.destroy();
toolbox = target = null;
gBrowser.removeCurrentTab();
});
function* testBottomHost() {
function testBottomHost() {
checkHostType(toolbox, BOTTOM);
// test UI presence
@ -42,8 +42,8 @@ function* testBottomHost() {
checkToolboxLoaded(iframe);
}
function* testSidebarHost() {
yield toolbox.switchHost(SIDE);
async function testSidebarHost() {
await toolbox.switchHost(SIDE);
checkHostType(toolbox, SIDE);
// test UI presence
@ -57,8 +57,8 @@ function* testSidebarHost() {
checkToolboxLoaded(iframe);
}
function* testWindowHost() {
yield toolbox.switchHost(WINDOW);
async function testWindowHost() {
await toolbox.switchHost(WINDOW);
checkHostType(toolbox, WINDOW);
let nbox = gBrowser.getNotificationBox();
@ -72,18 +72,18 @@ function* testWindowHost() {
checkToolboxLoaded(iframe);
}
function* testToolSelect() {
async function testToolSelect() {
// make sure we can load a tool after switching hosts
yield toolbox.selectTool("inspector");
await toolbox.selectTool("inspector");
}
function* testDestroy() {
yield toolbox.destroy();
async function testDestroy() {
await toolbox.destroy();
target = TargetFactory.forTab(gBrowser.selectedTab);
toolbox = yield gDevTools.showToolbox(target);
toolbox = await gDevTools.showToolbox(target);
}
function* testRememberHost() {
function testRememberHost() {
// last host was the window - make sure it's the same when re-opening
is(toolbox.hostType, WINDOW, "host remembered");
@ -91,45 +91,45 @@ function* testRememberHost() {
ok(win, "toolbox separate window exists");
}
function* testPreviousHost() {
async function testPreviousHost() {
// last host was the window - make sure it's the same when re-opening
is(toolbox.hostType, WINDOW, "host remembered");
info("Switching to side");
yield toolbox.switchHost(SIDE);
await toolbox.switchHost(SIDE);
checkHostType(toolbox, SIDE, WINDOW);
info("Switching to bottom");
yield toolbox.switchHost(BOTTOM);
await toolbox.switchHost(BOTTOM);
checkHostType(toolbox, BOTTOM, SIDE);
info("Switching from bottom to side");
yield toolbox.switchToPreviousHost();
await toolbox.switchToPreviousHost();
checkHostType(toolbox, SIDE, BOTTOM);
info("Switching from side to bottom");
yield toolbox.switchToPreviousHost();
await toolbox.switchToPreviousHost();
checkHostType(toolbox, BOTTOM, SIDE);
info("Switching to window");
yield toolbox.switchHost(WINDOW);
await toolbox.switchHost(WINDOW);
checkHostType(toolbox, WINDOW, BOTTOM);
info("Switching from window to bottom");
yield toolbox.switchToPreviousHost();
await toolbox.switchToPreviousHost();
checkHostType(toolbox, BOTTOM, WINDOW);
info("Forcing the previous host to match the current (bottom)");
Services.prefs.setCharPref("devtools.toolbox.previousHost", BOTTOM);
info("Switching from bottom to side (since previous=current=bottom");
yield toolbox.switchToPreviousHost();
await toolbox.switchToPreviousHost();
checkHostType(toolbox, SIDE, BOTTOM);
info("Forcing the previous host to match the current (side)");
Services.prefs.setCharPref("devtools.toolbox.previousHost", SIDE);
info("Switching from side to bottom (since previous=current=side");
yield toolbox.switchToPreviousHost();
await toolbox.switchToPreviousHost();
checkHostType(toolbox, BOTTOM, SIDE);
}

View File

@ -10,16 +10,16 @@ const URL = "data:text/html;charset=utf8,test for host sizes";
var {Toolbox} = require("devtools/client/framework/toolbox");
add_task(function* () {
add_task(async function () {
// Set size prefs to make the hosts way too big, so that the size has
// to be clamped to fit into the browser window.
Services.prefs.setIntPref("devtools.toolbox.footer.height", 10000);
Services.prefs.setIntPref("devtools.toolbox.sidebar.width", 10000);
let tab = yield addTab(URL);
let tab = await addTab(URL);
let nbox = gBrowser.getNotificationBox();
let {clientHeight: nboxHeight, clientWidth: nboxWidth} = nbox;
let toolbox = yield gDevTools.showToolbox(TargetFactory.forTab(tab));
let toolbox = await gDevTools.showToolbox(TargetFactory.forTab(tab));
is(nbox.clientHeight, nboxHeight, "Opening the toolbox hasn't changed the height of the nbox");
is(nbox.clientWidth, nboxWidth, "Opening the toolbox hasn't changed the width of the nbox");
@ -27,24 +27,24 @@ add_task(function* () {
let iframe = document.getAnonymousElementByAttribute(nbox, "class", "devtools-toolbox-bottom-iframe");
is(iframe.clientHeight, nboxHeight - 25, "The iframe fits within the available space");
yield toolbox.switchHost(Toolbox.HostType.SIDE);
await toolbox.switchHost(Toolbox.HostType.SIDE);
iframe = document.getAnonymousElementByAttribute(nbox, "class", "devtools-toolbox-side-iframe");
iframe.style.minWidth = "1px"; // Disable the min width set in css
is(iframe.clientWidth, nboxWidth - 25, "The iframe fits within the available space");
yield cleanup(toolbox);
await cleanup(toolbox);
});
add_task(function* () {
add_task(async function () {
// Set size prefs to something reasonable, so we can check to make sure
// they are being set properly.
Services.prefs.setIntPref("devtools.toolbox.footer.height", 100);
Services.prefs.setIntPref("devtools.toolbox.sidebar.width", 100);
let tab = yield addTab(URL);
let tab = await addTab(URL);
let nbox = gBrowser.getNotificationBox();
let {clientHeight: nboxHeight, clientWidth: nboxWidth} = nbox;
let toolbox = yield gDevTools.showToolbox(TargetFactory.forTab(tab));
let toolbox = await gDevTools.showToolbox(TargetFactory.forTab(tab));
is(nbox.clientHeight, nboxHeight, "Opening the toolbox hasn't changed the height of the nbox");
is(nbox.clientWidth, nboxWidth, "Opening the toolbox hasn't changed the width of the nbox");
@ -52,18 +52,18 @@ add_task(function* () {
let iframe = document.getAnonymousElementByAttribute(nbox, "class", "devtools-toolbox-bottom-iframe");
is(iframe.clientHeight, 100, "The iframe is resized properly");
yield toolbox.switchHost(Toolbox.HostType.SIDE);
await toolbox.switchHost(Toolbox.HostType.SIDE);
iframe = document.getAnonymousElementByAttribute(nbox, "class", "devtools-toolbox-side-iframe");
iframe.style.minWidth = "1px"; // Disable the min width set in css
is(iframe.clientWidth, 100, "The iframe is resized properly");
yield cleanup(toolbox);
await cleanup(toolbox);
});
function* cleanup(toolbox) {
async function cleanup(toolbox) {
Services.prefs.clearUserPref("devtools.toolbox.host");
Services.prefs.clearUserPref("devtools.toolbox.footer.height");
Services.prefs.clearUserPref("devtools.toolbox.sidebar.width");
yield toolbox.destroy();
await toolbox.destroy();
gBrowser.removeCurrentTab();
}

View File

@ -12,18 +12,18 @@ function getHostHistogram() {
return Services.telemetry.getHistogramById("DEVTOOLS_TOOLBOX_HOST");
}
add_task(function* () {
add_task(async function () {
// Reset it to make counting easier
getHostHistogram().clear();
info("Create a test tab and open the toolbox");
let tab = yield addTab(URL);
let tab = await addTab(URL);
let target = TargetFactory.forTab(tab);
let toolbox = yield gDevTools.showToolbox(target, "webconsole");
let toolbox = await gDevTools.showToolbox(target, "webconsole");
yield changeToolboxHost(toolbox);
yield checkResults();
yield toolbox.destroy();
await changeToolboxHost(toolbox);
await checkResults();
await toolbox.destroy();
toolbox = target = null;
gBrowser.removeCurrentTab();
@ -32,14 +32,14 @@ add_task(function* () {
getHostHistogram().clear();
});
function* changeToolboxHost(toolbox) {
async function changeToolboxHost(toolbox) {
info("Switch toolbox host");
yield toolbox.switchHost(SIDE);
yield toolbox.switchHost(WINDOW);
yield toolbox.switchHost(BOTTOM);
yield toolbox.switchHost(SIDE);
yield toolbox.switchHost(WINDOW);
yield toolbox.switchHost(BOTTOM);
await toolbox.switchHost(SIDE);
await toolbox.switchHost(WINDOW);
await toolbox.switchHost(BOTTOM);
await toolbox.switchHost(SIDE);
await toolbox.switchHost(WINDOW);
await toolbox.switchHost(BOTTOM);
}
function checkResults() {

View File

@ -19,9 +19,9 @@ function containsFocus(aDoc, aElm) {
return false;
}
add_task(function* () {
add_task(async function () {
info("Create a test tab and open the toolbox");
let toolbox = yield openNewTabAndToolbox(TEST_URL, "webconsole");
let toolbox = await openNewTabAndToolbox(TEST_URL, "webconsole");
let doc = toolbox.doc;
let toolbar = doc.querySelector(".devtools-tabbar");

Some files were not shown because too many files have changed in this diff Show More