Bug 1597785 - fix review nits from bug 1594521, r=kmag

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

--HG--
extra : moz-landing-system : lando
This commit is contained in:
Gijs Kruitbosch 2019-11-19 21:44:10 +00:00
Родитель b9540d5e60
Коммит 734a4ade99
2 изменённых файлов: 9 добавлений и 13 удалений

Просмотреть файл

@ -38,9 +38,7 @@ let gShutdownResolver = null;
class Worker {
constructor(source) {
if (gShutdown) {
Cu.reportError(
new Error("Can't create worker once shutdown has started")
);
Cu.reportError("Can't create worker once shutdown has started");
}
this.source = source;
this.worker = null;
@ -52,7 +50,7 @@ class Worker {
async _execute(method, args = []) {
if (gShutdown) {
return Promise.reject(new Error("Remote Settings has shut down."));
throw new Error("Remote Settings has shut down.");
}
// (Re)instantiate the worker if it was terminated.
if (!this.worker) {
@ -136,7 +134,7 @@ try {
!RemoteSettingsWorker.worker ||
!RemoteSettingsWorker.callbacks.size
) {
return Promise.resolve();
return null;
}
// Otherwise, return a promise that the worker will resolve.
return new Promise(resolve => {
@ -145,9 +143,7 @@ try {
},
{
fetchState() {
return (
"Remaining: " + RemoteSettingsWorker.callbacks.size + " callbacks."
);
return `Remaining: ${RemoteSettingsWorker.callbacks.size} callbacks.`;
},
}
);

Просмотреть файл

@ -36,8 +36,8 @@ add_task(async function test_canonicaljson_merges_remote_into_local() {
);
Assert.equal(
'{"data":[{"id":"1","title":"title 1"},{"id":"2","title":"title b"}],"last_modified":"42"}',
serialized
serialized,
'{"data":[{"id":"1","title":"title 1"},{"id":"2","title":"title b"}],"last_modified":"42"}'
);
});
@ -67,7 +67,7 @@ add_task(async function test_throws_error_if_worker_fails() {
} catch (e) {
error = e;
}
Assert.equal("TypeError: localRecords is null", error.message);
Assert.equal(error.message, "TypeError: localRecords is null");
});
add_task(async function test_stops_worker_after_timeout() {
@ -78,7 +78,7 @@ add_task(async function test_stops_worker_after_timeout() {
);
// Run a task:
let serialized = await RemoteSettingsWorker.canonicalStringify([], [], 42);
Assert.equal('{"data":[],"last_modified":"42"}', serialized, "API works.");
Assert.equal(serialized, '{"data":[],"last_modified":"42"}', "API works.");
// Check that the worker gets stopped now the task is done:
await TestUtils.waitForCondition(() => !RemoteSettingsWorker.worker);
// Ensure the worker stays alive for 10 minutes instead:
@ -89,8 +89,8 @@ add_task(async function test_stops_worker_after_timeout() {
// Run another task:
serialized = await RemoteSettingsWorker.canonicalStringify([], [], 42);
Assert.equal(
'{"data":[],"last_modified":"42"}',
serialized,
'{"data":[],"last_modified":"42"}',
"API still works."
);
Assert.ok(RemoteSettingsWorker.worker, "Worker should stay alive a bit.");