зеркало из https://github.com/mozilla/gecko-dev.git
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:
Родитель
b9540d5e60
Коммит
734a4ade99
|
@ -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.");
|
||||
|
|
Загрузка…
Ссылка в новой задаче