bug 1607500: remote: preserve task name in add_agent_task() r=remote-protocol-reviewers,whimboo

Similarly to bug 1603451, the name of the function passed to the
specialised add_agent_task() is lost because of the anonymous
function wrapper inside.

Differential Revision: https://phabricator.services.mozilla.com/D58967

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Andreas Tolfsen 2020-01-08 08:34:46 +00:00
parent 290bc505ff
commit e221feba47

View File

@ -10,16 +10,21 @@ const { Preferences } = ChromeUtils.import(
const URL = Services.io.newURI("http://localhost:0");
// set up test conditions and clean up
function add_agent_task(taskFn) {
add_plain_task(async () => {
function add_agent_task(originalTask) {
const task = async function() {
try {
await RemoteAgent.close();
await taskFn();
await originalTask();
} finally {
Preferences.reset("remote.enabled");
Preferences.reset("remote.force-local");
}
};
Object.defineProperty(task, "name", {
value: originalTask.name,
writable: false,
});
add_plain_task(task);
}
add_agent_task(async function listening() {