summaryrefslogtreecommitdiffstats
path: root/services/sync/tests/unit
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-19 01:14:29 +0000
commitfbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 (patch)
tree4c1ccaf5486d4f2009f9a338a98a83e886e29c97 /services/sync/tests/unit
parentReleasing progress-linux version 124.0.1-1~progress7.99u1. (diff)
downloadfirefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.tar.xz
firefox-fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8.zip
Merging upstream version 125.0.1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'services/sync/tests/unit')
-rw-r--r--services/sync/tests/unit/head_helpers.js4
-rw-r--r--services/sync/tests/unit/head_http_server.js6
-rw-r--r--services/sync/tests/unit/test_addon_utils.js2
-rw-r--r--services/sync/tests/unit/test_addons_validator.js2
-rw-r--r--services/sync/tests/unit/test_bookmark_engine.js2
-rw-r--r--services/sync/tests/unit/test_bookmark_tracker.js14
-rw-r--r--services/sync/tests/unit/test_clients_engine.js27
-rw-r--r--services/sync/tests/unit/test_declined.js4
-rw-r--r--services/sync/tests/unit/test_engine_abort.js2
-rw-r--r--services/sync/tests/unit/test_errorhandler_1.js22
-rw-r--r--services/sync/tests/unit/test_errorhandler_2.js77
-rw-r--r--services/sync/tests/unit/test_errorhandler_filelog.js2
-rw-r--r--services/sync/tests/unit/test_fxa_node_reassignment.js2
-rw-r--r--services/sync/tests/unit/test_history_engine.js4
-rw-r--r--services/sync/tests/unit/test_history_store.js2
-rw-r--r--services/sync/tests/unit/test_history_tracker.js4
-rw-r--r--services/sync/tests/unit/test_hmac_error.js2
-rw-r--r--services/sync/tests/unit/test_httpd_sync_server.js2
-rw-r--r--services/sync/tests/unit/test_interval_triggers.js2
-rw-r--r--services/sync/tests/unit/test_password_engine.js9
-rw-r--r--services/sync/tests/unit/test_resource.js2
-rw-r--r--services/sync/tests/unit/test_service_sync_401.js2
-rw-r--r--services/sync/tests/unit/test_service_verifyLogin.js11
-rw-r--r--services/sync/tests/unit/test_sync_auth_manager.js35
-rw-r--r--services/sync/tests/unit/test_syncedtabs.js2
-rw-r--r--services/sync/tests/unit/test_syncscheduler.js2
-rw-r--r--services/sync/tests/unit/test_tab_quickwrite.js2
-rw-r--r--services/sync/tests/unit/test_telemetry.js4
-rw-r--r--services/sync/tests/unit/test_uistate.js4
29 files changed, 117 insertions, 138 deletions
diff --git a/services/sync/tests/unit/head_helpers.js b/services/sync/tests/unit/head_helpers.js
index e79e55e57f..865117e5d2 100644
--- a/services/sync/tests/unit/head_helpers.js
+++ b/services/sync/tests/unit/head_helpers.js
@@ -530,8 +530,8 @@ async function sync_engine_and_validate_telem(
// Returns a promise that resolves once the specified observer notification
// has fired.
-function promiseOneObserver(topic, callback) {
- return new Promise((resolve, reject) => {
+function promiseOneObserver(topic) {
+ return new Promise(resolve => {
let observer = function (subject, data) {
Svc.Obs.remove(topic, observer);
resolve({ subject, data });
diff --git a/services/sync/tests/unit/head_http_server.js b/services/sync/tests/unit/head_http_server.js
index 84dbb33951..d8603465c1 100644
--- a/services/sync/tests/unit/head_http_server.js
+++ b/services/sync/tests/unit/head_http_server.js
@@ -687,8 +687,8 @@ function track_collections_helper() {
* prototype, and override as appropriate.
*/
var SyncServerCallback = {
- onCollectionDeleted: function onCollectionDeleted(user, collection) {},
- onItemDeleted: function onItemDeleted(user, collection, wboID) {},
+ onCollectionDeleted: function onCollectionDeleted() {},
+ onItemDeleted: function onItemDeleted() {},
/**
* Called at the top of every request.
@@ -699,7 +699,7 @@ var SyncServerCallback = {
* must be taken to not screw with the response body or headers that may
* conflict with normal operation of this server.
*/
- onRequest: function onRequest(request, response) {},
+ onRequest: function onRequest() {},
};
/**
diff --git a/services/sync/tests/unit/test_addon_utils.js b/services/sync/tests/unit/test_addon_utils.js
index c039bee16c..e9e49fb9ea 100644
--- a/services/sync/tests/unit/test_addon_utils.js
+++ b/services/sync/tests/unit/test_addon_utils.js
@@ -119,7 +119,7 @@ add_task(async function test_source_uri_rewrite() {
let installCalled = false;
Object.getPrototypeOf(AddonUtils).installAddonFromSearchResult =
- async function testInstallAddon(addon, metadata) {
+ async function testInstallAddon(addon) {
Assert.equal(
SERVER_ADDRESS + "/require.xpi?src=sync",
addon.sourceURI.spec
diff --git a/services/sync/tests/unit/test_addons_validator.js b/services/sync/tests/unit/test_addons_validator.js
index 60f2f8bf43..91f3f7b31b 100644
--- a/services/sync/tests/unit/test_addons_validator.js
+++ b/services/sync/tests/unit/test_addons_validator.js
@@ -49,7 +49,7 @@ function getDummyServerAndClient() {
add_task(async function test_valid() {
let { server, client } = getDummyServerAndClient();
let validator = new AddonValidator({
- _findDupe(item) {
+ _findDupe() {
return null;
},
isAddonSyncable(item) {
diff --git a/services/sync/tests/unit/test_bookmark_engine.js b/services/sync/tests/unit/test_bookmark_engine.js
index 6274a6b836..2f5ac9dcd3 100644
--- a/services/sync/tests/unit/test_bookmark_engine.js
+++ b/services/sync/tests/unit/test_bookmark_engine.js
@@ -940,7 +940,7 @@ add_bookmark_test(async function test_sync_dateAdded(engine) {
// Make sure it's within 24 hours of the right timestamp... This is a little
// dodgey but we only really care that it's basically accurate and has the
// right day.
- ok(Math.abs(Date.now() - record3.dateAdded) < 24 * 60 * 60 * 1000);
+ Assert.less(Math.abs(Date.now() - record3.dateAdded), 24 * 60 * 60 * 1000);
let record4 = await store.createRecord(item4GUID);
equal(
diff --git a/services/sync/tests/unit/test_bookmark_tracker.js b/services/sync/tests/unit/test_bookmark_tracker.js
index 9cfbb4de78..8c26232cd5 100644
--- a/services/sync/tests/unit/test_bookmark_tracker.js
+++ b/services/sync/tests/unit/test_bookmark_tracker.js
@@ -54,8 +54,16 @@ async function verifyTrackedItems(tracked) {
let trackedIDs = new Set(Object.keys(changedIDs));
for (let guid of tracked) {
ok(guid in changedIDs, `${guid} should be tracked`);
- ok(changedIDs[guid].modified > 0, `${guid} should have a modified time`);
- ok(changedIDs[guid].counter >= -1, `${guid} should have a change counter`);
+ Assert.greater(
+ changedIDs[guid].modified,
+ 0,
+ `${guid} should have a modified time`
+ );
+ Assert.greaterOrEqual(
+ changedIDs[guid].counter,
+ -1,
+ `${guid} should have a change counter`
+ );
trackedIDs.delete(guid);
}
equal(
@@ -770,7 +778,7 @@ add_task(async function test_onFaviconChanged() {
iconURI,
true,
PlacesUtils.favicons.FAVICON_LOAD_NON_PRIVATE,
- (uri, dataLen, data, mimeType) => {
+ () => {
resolve();
},
Services.scriptSecurityManager.getSystemPrincipal()
diff --git a/services/sync/tests/unit/test_clients_engine.js b/services/sync/tests/unit/test_clients_engine.js
index d910a67503..9a5115db4e 100644
--- a/services/sync/tests/unit/test_clients_engine.js
+++ b/services/sync/tests/unit/test_clients_engine.js
@@ -125,7 +125,7 @@ add_task(async function test_bad_hmac() {
check_clients_count(0);
await syncClientsEngine(server);
check_clients_count(1);
- ok(engine.lastRecordUpload > 0);
+ Assert.greater(engine.lastRecordUpload, 0);
ok(!engine.isFirstSync);
// Our uploaded record has a version.
@@ -275,7 +275,7 @@ add_task(async function test_full_sync() {
strictEqual(engine.lastRecordUpload, 0);
ok(engine.isFirstSync);
await syncClientsEngine(server);
- ok(engine.lastRecordUpload > 0);
+ Assert.greater(engine.lastRecordUpload, 0);
ok(!engine.isFirstSync);
deepEqual(
user.collection("clients").keys().sort(),
@@ -333,7 +333,7 @@ add_task(async function test_sync() {
ok(engine.isFirstSync);
await syncClientsEngine(server);
ok(!!clientWBO().payload);
- ok(engine.lastRecordUpload > 0);
+ Assert.greater(engine.lastRecordUpload, 0);
ok(!engine.isFirstSync);
_(
@@ -344,7 +344,7 @@ add_task(async function test_sync() {
clientWBO().payload = undefined;
await syncClientsEngine(server);
ok(!!clientWBO().payload);
- ok(engine.lastRecordUpload > lastweek);
+ Assert.greater(engine.lastRecordUpload, lastweek);
ok(!engine.isFirstSync);
_("Remove client record.");
@@ -394,8 +394,8 @@ add_task(async function test_client_name_change() {
changedIDs = await tracker.getChangedIDs();
equal(Object.keys(changedIDs).length, 1);
ok(engine.localID in changedIDs);
- ok(tracker.score > initialScore);
- ok(tracker.score >= SCORE_INCREMENT_XLARGE);
+ Assert.greater(tracker.score, initialScore);
+ Assert.greaterOrEqual(tracker.score, SCORE_INCREMENT_XLARGE);
await tracker.stop();
@@ -425,8 +425,8 @@ add_task(async function test_fxa_device_id_change() {
changedIDs = await tracker.getChangedIDs();
equal(Object.keys(changedIDs).length, 1);
ok(engine.localID in changedIDs);
- ok(tracker.score > initialScore);
- ok(tracker.score >= SINGLE_USER_THRESHOLD);
+ Assert.greater(tracker.score, initialScore);
+ Assert.greaterOrEqual(tracker.score, SINGLE_USER_THRESHOLD);
await tracker.stop();
@@ -477,7 +477,10 @@ add_task(async function test_last_modified() {
await engine._uploadOutgoing();
_("Local record should have updated timestamp");
- ok(engine._store._remoteClients[activeID].serverLastModified >= now);
+ Assert.greaterOrEqual(
+ engine._store._remoteClients[activeID].serverLastModified,
+ now
+ );
_("Record on the server should have new name but not serverLastModified");
let payload = collection.cleartext(activeID);
@@ -732,7 +735,7 @@ add_task(async function test_filter_duplicate_names() {
strictEqual(engine.lastRecordUpload, 0);
ok(engine.isFirstSync);
await syncClientsEngine(server);
- ok(engine.lastRecordUpload > 0);
+ Assert.greater(engine.lastRecordUpload, 0);
ok(!engine.isFirstSync);
deepEqual(
user.collection("clients").keys().sort(),
@@ -776,7 +779,7 @@ add_task(async function test_filter_duplicate_names() {
// Check that a subsequent Sync doesn't report anything as being processed.
let counts;
- Svc.Obs.add("weave:engine:sync:applied", function observe(subject, data) {
+ Svc.Obs.add("weave:engine:sync:applied", function observe(subject) {
Svc.Obs.remove("weave:engine:sync:applied", observe);
counts = subject;
});
@@ -915,7 +918,7 @@ add_task(async function test_command_sync() {
_("Checking record was uploaded.");
notEqual(clientWBO(engine.localID).payload, undefined);
- ok(engine.lastRecordUpload > 0);
+ Assert.greater(engine.lastRecordUpload, 0);
ok(!engine.isFirstSync);
notEqual(clientWBO(remoteId).payload, undefined);
diff --git a/services/sync/tests/unit/test_declined.js b/services/sync/tests/unit/test_declined.js
index af7f8eb8c5..aecd33ee6e 100644
--- a/services/sync/tests/unit/test_declined.js
+++ b/services/sync/tests/unit/test_declined.js
@@ -79,7 +79,7 @@ add_task(async function testOldMeta() {
let declinedEngines = new DeclinedEngines(Service);
- function onNotDeclined(subject, topic, data) {
+ function onNotDeclined(subject) {
Observers.remove("weave:engines:notdeclined", onNotDeclined);
Assert.ok(
subject.undecided.has("actual"),
@@ -129,7 +129,7 @@ add_task(async function testDeclinedMeta() {
let declinedEngines = new DeclinedEngines(Service);
- function onNotDeclined(subject, topic, data) {
+ function onNotDeclined(subject) {
Observers.remove("weave:engines:notdeclined", onNotDeclined);
Assert.ok(
subject.undecided.has("actual"),
diff --git a/services/sync/tests/unit/test_engine_abort.js b/services/sync/tests/unit/test_engine_abort.js
index f9bbf9d338..a7c62afb4a 100644
--- a/services/sync/tests/unit/test_engine_abort.js
+++ b/services/sync/tests/unit/test_engine_abort.js
@@ -37,7 +37,7 @@ add_task(async function test_processIncoming_abort() {
);
meta_global.payload.engines = { rotary: { version: engine.version, syncID } };
_("Fake applyIncoming to abort.");
- engine._store.applyIncoming = async function (record) {
+ engine._store.applyIncoming = async function () {
let ex = {
code: SyncEngine.prototype.eEngineAbortApplyIncoming,
cause: "Nooo",
diff --git a/services/sync/tests/unit/test_errorhandler_1.js b/services/sync/tests/unit/test_errorhandler_1.js
index 2d52b93a02..f5e96ed44e 100644
--- a/services/sync/tests/unit/test_errorhandler_1.js
+++ b/services/sync/tests/unit/test_errorhandler_1.js
@@ -286,13 +286,10 @@ add_task(async function test_info_collections_login_server_maintenance_error() {
await configureIdentity({ username: "broken.info" }, server);
let backoffInterval;
- Svc.Obs.add(
- "weave:service:backoff:interval",
- function observe(subject, data) {
- Svc.Obs.remove("weave:service:backoff:interval", observe);
- backoffInterval = subject;
- }
- );
+ Svc.Obs.add("weave:service:backoff:interval", function observe(subject) {
+ Svc.Obs.remove("weave:service:backoff:interval", observe);
+ backoffInterval = subject;
+ });
Assert.ok(!Status.enforceBackoff);
Assert.equal(Status.service, STATUS_OK);
@@ -318,13 +315,10 @@ add_task(async function test_meta_global_login_server_maintenance_error() {
await configureIdentity({ username: "broken.meta" }, server);
let backoffInterval;
- Svc.Obs.add(
- "weave:service:backoff:interval",
- function observe(subject, data) {
- Svc.Obs.remove("weave:service:backoff:interval", observe);
- backoffInterval = subject;
- }
- );
+ Svc.Obs.add("weave:service:backoff:interval", function observe(subject) {
+ Svc.Obs.remove("weave:service:backoff:interval", observe);
+ backoffInterval = subject;
+ });
Assert.ok(!Status.enforceBackoff);
Assert.equal(Status.service, STATUS_OK);
diff --git a/services/sync/tests/unit/test_errorhandler_2.js b/services/sync/tests/unit/test_errorhandler_2.js
index 5cab4d832d..2a7e6ba619 100644
--- a/services/sync/tests/unit/test_errorhandler_2.js
+++ b/services/sync/tests/unit/test_errorhandler_2.js
@@ -74,13 +74,10 @@ add_task(async function test_crypto_keys_login_server_maintenance_error() {
Service.collectionKeys.clear();
let backoffInterval;
- Svc.Obs.add(
- "weave:service:backoff:interval",
- function observe(subject, data) {
- Svc.Obs.remove("weave:service:backoff:interval", observe);
- backoffInterval = subject;
- }
- );
+ Svc.Obs.add("weave:service:backoff:interval", function observe(subject) {
+ Svc.Obs.remove("weave:service:backoff:interval", observe);
+ backoffInterval = subject;
+ });
Assert.ok(!Status.enforceBackoff);
Assert.equal(Status.service, STATUS_OK);
@@ -178,13 +175,10 @@ add_task(
await configureIdentity({ username: "broken.info" }, server);
let backoffInterval;
- Svc.Obs.add(
- "weave:service:backoff:interval",
- function observe(subject, data) {
- Svc.Obs.remove("weave:service:backoff:interval", observe);
- backoffInterval = subject;
- }
- );
+ Svc.Obs.add("weave:service:backoff:interval", function observe(subject) {
+ Svc.Obs.remove("weave:service:backoff:interval", observe);
+ backoffInterval = subject;
+ });
Assert.ok(!Status.enforceBackoff);
Assert.equal(Status.service, STATUS_OK);
@@ -215,13 +209,10 @@ add_task(
await configureIdentity({ username: "broken.meta" }, server);
let backoffInterval;
- Svc.Obs.add(
- "weave:service:backoff:interval",
- function observe(subject, data) {
- Svc.Obs.remove("weave:service:backoff:interval", observe);
- backoffInterval = subject;
- }
- );
+ Svc.Obs.add("weave:service:backoff:interval", function observe(subject) {
+ Svc.Obs.remove("weave:service:backoff:interval", observe);
+ backoffInterval = subject;
+ });
Assert.ok(!Status.enforceBackoff);
Assert.equal(Status.service, STATUS_OK);
@@ -254,13 +245,10 @@ add_task(
Service.collectionKeys.clear();
let backoffInterval;
- Svc.Obs.add(
- "weave:service:backoff:interval",
- function observe(subject, data) {
- Svc.Obs.remove("weave:service:backoff:interval", observe);
- backoffInterval = subject;
- }
- );
+ Svc.Obs.add("weave:service:backoff:interval", function observe(subject) {
+ Svc.Obs.remove("weave:service:backoff:interval", observe);
+ backoffInterval = subject;
+ });
Assert.ok(!Status.enforceBackoff);
Assert.equal(Status.service, STATUS_OK);
@@ -291,13 +279,10 @@ add_task(
await configureIdentity({ username: "broken.keys" }, server);
let backoffInterval;
- Svc.Obs.add(
- "weave:service:backoff:interval",
- function observe(subject, data) {
- Svc.Obs.remove("weave:service:backoff:interval", observe);
- backoffInterval = subject;
- }
- );
+ Svc.Obs.add("weave:service:backoff:interval", function observe(subject) {
+ Svc.Obs.remove("weave:service:backoff:interval", observe);
+ backoffInterval = subject;
+ });
Assert.ok(!Status.enforceBackoff);
Assert.equal(Status.service, STATUS_OK);
@@ -328,13 +313,10 @@ add_task(
await configureIdentity({ username: "broken.wipe" }, server);
let backoffInterval;
- Svc.Obs.add(
- "weave:service:backoff:interval",
- function observe(subject, data) {
- Svc.Obs.remove("weave:service:backoff:interval", observe);
- backoffInterval = subject;
- }
- );
+ Svc.Obs.add("weave:service:backoff:interval", function observe(subject) {
+ Svc.Obs.remove("weave:service:backoff:interval", observe);
+ backoffInterval = subject;
+ });
Assert.ok(!Status.enforceBackoff);
Assert.equal(Status.service, STATUS_OK);
@@ -368,13 +350,10 @@ add_task(
engine.enabled = true;
let backoffInterval;
- Svc.Obs.add(
- "weave:service:backoff:interval",
- function observe(subject, data) {
- Svc.Obs.remove("weave:service:backoff:interval", observe);
- backoffInterval = subject;
- }
- );
+ Svc.Obs.add("weave:service:backoff:interval", function observe(subject) {
+ Svc.Obs.remove("weave:service:backoff:interval", observe);
+ backoffInterval = subject;
+ });
Assert.ok(!Status.enforceBackoff);
Assert.equal(Status.service, STATUS_OK);
diff --git a/services/sync/tests/unit/test_errorhandler_filelog.js b/services/sync/tests/unit/test_errorhandler_filelog.js
index 66260b3f59..357049276c 100644
--- a/services/sync/tests/unit/test_errorhandler_filelog.js
+++ b/services/sync/tests/unit/test_errorhandler_filelog.js
@@ -82,7 +82,7 @@ function readFile(file, callback) {
uri: NetUtil.newURI(file),
loadUsingSystemPrincipal: true,
},
- function (inputStream, statusCode, request) {
+ function (inputStream, statusCode) {
let data = NetUtil.readInputStreamToString(
inputStream,
inputStream.available()
diff --git a/services/sync/tests/unit/test_fxa_node_reassignment.js b/services/sync/tests/unit/test_fxa_node_reassignment.js
index 0b25df0183..0fa7ee922c 100644
--- a/services/sync/tests/unit/test_fxa_node_reassignment.js
+++ b/services/sync/tests/unit/test_fxa_node_reassignment.js
@@ -46,7 +46,7 @@ function prepareServer(cbAfterTokenFetch) {
// A server callback to ensure we don't accidentally hit the wrong endpoint
// after a node reassignment.
let callback = {
- onRequest(req, resp) {
+ onRequest(req) {
let full = `${req.scheme}://${req.host}:${req.port}${req.path}`;
let expected = config.fxaccount.token.endpoint;
Assert.ok(
diff --git a/services/sync/tests/unit/test_history_engine.js b/services/sync/tests/unit/test_history_engine.js
index 9cca379b0b..259338df09 100644
--- a/services/sync/tests/unit/test_history_engine.js
+++ b/services/sync/tests/unit/test_history_engine.js
@@ -16,13 +16,13 @@ XPCOMUtils.defineLazyServiceGetter(
"mozIAsyncHistory"
);
async function rawAddVisit(id, uri, visitPRTime, transitionType) {
- return new Promise((resolve, reject) => {
+ return new Promise(resolve => {
let results = [];
let handler = {
handleResult(result) {
results.push(result);
},
- handleError(resultCode, placeInfo) {
+ handleError(resultCode) {
do_throw(`updatePlaces gave error ${resultCode}!`);
},
handleCompletion(count) {
diff --git a/services/sync/tests/unit/test_history_store.js b/services/sync/tests/unit/test_history_store.js
index 07aee0dd01..1777664bb6 100644
--- a/services/sync/tests/unit/test_history_store.js
+++ b/services/sync/tests/unit/test_history_store.js
@@ -17,7 +17,7 @@ const TIMESTAMP3 = (Date.now() - 123894) * 1000;
function promiseOnVisitObserved() {
return new Promise(res => {
- let listener = new PlacesWeakCallbackWrapper(events => {
+ let listener = new PlacesWeakCallbackWrapper(() => {
PlacesObservers.removeListener(["page-visited"], listener);
res();
});
diff --git a/services/sync/tests/unit/test_history_tracker.js b/services/sync/tests/unit/test_history_tracker.js
index 6f351d6984..64433574b4 100644
--- a/services/sync/tests/unit/test_history_tracker.js
+++ b/services/sync/tests/unit/test_history_tracker.js
@@ -37,7 +37,7 @@ async function verifyTrackedItems(tracked) {
let trackedIDs = new Set(Object.keys(changes));
for (let guid of tracked) {
ok(guid in changes, `${guid} should be tracked`);
- ok(changes[guid] > 0, `${guid} should have a modified time`);
+ Assert.greater(changes[guid], 0, `${guid} should have a modified time`);
trackedIDs.delete(guid);
}
equal(
@@ -160,7 +160,7 @@ add_task(async function test_dont_track_expiration() {
let scorePromise = promiseOneObserver("weave:engine:score:updated");
// Observe expiration.
- Services.obs.addObserver(function onExpiration(aSubject, aTopic, aData) {
+ Services.obs.addObserver(function onExpiration(aSubject, aTopic) {
Services.obs.removeObserver(onExpiration, aTopic);
// Remove the remaining page to update its score.
PlacesUtils.history.remove(uriToRemove);
diff --git a/services/sync/tests/unit/test_hmac_error.js b/services/sync/tests/unit/test_hmac_error.js
index 26dbc12dea..a04e54f476 100644
--- a/services/sync/tests/unit/test_hmac_error.js
+++ b/services/sync/tests/unit/test_hmac_error.js
@@ -171,7 +171,7 @@ add_task(async function hmac_error_during_node_reassignment() {
}
let onSyncFinished = function () {};
let obs = {
- observe: function observe(subject, topic, data) {
+ observe: function observe(subject, topic) {
switch (topic) {
case "weave:service:sync:error":
onSyncError();
diff --git a/services/sync/tests/unit/test_httpd_sync_server.js b/services/sync/tests/unit/test_httpd_sync_server.js
index 6ac8ff5e04..23bb05b15d 100644
--- a/services/sync/tests/unit/test_httpd_sync_server.js
+++ b/services/sync/tests/unit/test_httpd_sync_server.js
@@ -160,7 +160,7 @@ add_task(async function test_storage_request() {
async function deleteWBONotExists() {
let req = localRequest(server, keysURL);
- server.callback.onItemDeleted = function (username, collection, wboID) {
+ server.callback.onItemDeleted = function () {
do_throw("onItemDeleted should not have been called.");
};
diff --git a/services/sync/tests/unit/test_interval_triggers.js b/services/sync/tests/unit/test_interval_triggers.js
index 6f2821ec45..eb0b39f636 100644
--- a/services/sync/tests/unit/test_interval_triggers.js
+++ b/services/sync/tests/unit/test_interval_triggers.js
@@ -51,7 +51,7 @@ add_task(async function setup() {
// Don't remove stale clients when syncing. This is a test-only workaround
// that lets us add clients directly to the store, without losing them on
// the next sync.
- clientsEngine._removeRemoteClient = async id => {};
+ clientsEngine._removeRemoteClient = async () => {};
});
add_task(async function test_successful_sync_adjustSyncInterval() {
diff --git a/services/sync/tests/unit/test_password_engine.js b/services/sync/tests/unit/test_password_engine.js
index 081403f63d..54fe8972f2 100644
--- a/services/sync/tests/unit/test_password_engine.js
+++ b/services/sync/tests/unit/test_password_engine.js
@@ -434,8 +434,9 @@ add_task(async function test_sync_outgoing() {
equal(deletedLogin.guid, guid, "deleted login guid");
equal(deletedLogin.everSynced, true, "deleted login everSynced");
equal(deletedLogin.syncCounter, 0, "deleted login syncCounter");
- ok(
- deletedLogin.timePasswordChanged > 0,
+ Assert.greater(
+ deletedLogin.timePasswordChanged,
+ 0,
"deleted login timePasswordChanged"
);
} finally {
@@ -525,7 +526,7 @@ add_task(async function test_sync_incoming() {
checkFields.forEach(field => {
equal(logins[0][field], details[field]);
});
- ok(logins[0].timePasswordChanged > details.timePasswordChanged);
+ Assert.greater(logins[0].timePasswordChanged, details.timePasswordChanged);
equal(logins[0].syncCounter, 0);
equal(logins[0].everSynced, true);
@@ -553,7 +554,7 @@ add_task(async function test_sync_incoming() {
checkFields.forEach(field => {
equal(logins[0][field], details[field]);
});
- ok(logins[0].timePasswordChanged > details.timePasswordChanged);
+ Assert.greater(logins[0].timePasswordChanged, details.timePasswordChanged);
equal(logins[0].syncCounter, 0);
equal(logins[0].everSynced, true);
diff --git a/services/sync/tests/unit/test_resource.js b/services/sync/tests/unit/test_resource.js
index 5182784639..5dee57b39a 100644
--- a/services/sync/tests/unit/test_resource.js
+++ b/services/sync/tests/unit/test_resource.js
@@ -480,7 +480,7 @@ add_task(async function test_post_override_content_type() {
add_task(async function test_weave_backoff() {
_("X-Weave-Backoff header notifies observer");
let backoffInterval;
- function onBackoff(subject, data) {
+ function onBackoff(subject) {
backoffInterval = subject;
}
Observers.add("weave:service:backoff:interval", onBackoff);
diff --git a/services/sync/tests/unit/test_service_sync_401.js b/services/sync/tests/unit/test_service_sync_401.js
index a0bde0b0ab..0c285872e9 100644
--- a/services/sync/tests/unit/test_service_sync_401.js
+++ b/services/sync/tests/unit/test_service_sync_401.js
@@ -48,7 +48,7 @@ add_task(async function run_test() {
Svc.PrefBranch.setIntPref("lastPing", Math.floor(Date.now() / 1000));
let threw = false;
- Svc.Obs.add("weave:service:sync:error", function (subject, data) {
+ Svc.Obs.add("weave:service:sync:error", function () {
threw = true;
});
diff --git a/services/sync/tests/unit/test_service_verifyLogin.js b/services/sync/tests/unit/test_service_verifyLogin.js
index b99b5c692c..b3afe6179a 100644
--- a/services/sync/tests/unit/test_service_verifyLogin.js
+++ b/services/sync/tests/unit/test_service_verifyLogin.js
@@ -78,13 +78,10 @@ add_task(async function test_verifyLogin() {
Service._updateCachedURLs();
Assert.ok(!Service.status.enforceBackoff);
let backoffInterval;
- Svc.Obs.add(
- "weave:service:backoff:interval",
- function observe(subject, data) {
- Svc.Obs.remove("weave:service:backoff:interval", observe);
- backoffInterval = subject;
- }
- );
+ Svc.Obs.add("weave:service:backoff:interval", function observe(subject) {
+ Svc.Obs.remove("weave:service:backoff:interval", observe);
+ backoffInterval = subject;
+ });
Assert.equal(false, await Service.verifyLogin());
Assert.ok(Service.status.enforceBackoff);
Assert.equal(backoffInterval, 42);
diff --git a/services/sync/tests/unit/test_sync_auth_manager.js b/services/sync/tests/unit/test_sync_auth_manager.js
index 9af40d26c6..f9fa669667 100644
--- a/services/sync/tests/unit/test_sync_auth_manager.js
+++ b/services/sync/tests/unit/test_sync_auth_manager.js
@@ -37,9 +37,8 @@ const { TokenServerClient, TokenServerClientServerError } =
ChromeUtils.importESModule(
"resource://services-common/tokenserverclient.sys.mjs"
);
-const { AccountState } = ChromeUtils.importESModule(
- "resource://gre/modules/FxAccounts.sys.mjs"
-);
+const { AccountState, ERROR_INVALID_ACCOUNT_STATE } =
+ ChromeUtils.importESModule("resource://gre/modules/FxAccounts.sys.mjs");
const SECOND_MS = 1000;
const MINUTE_MS = SECOND_MS * 60;
@@ -192,8 +191,11 @@ add_task(async function test_initialializeWithAuthErrorAndDeletedAccount() {
await Assert.rejects(
syncAuthManager._ensureValidToken(),
- AuthenticationError,
- "should reject due to an auth error"
+ err => {
+ Assert.equal(err.message, ERROR_INVALID_ACCOUNT_STATE);
+ return true; // expected error
+ },
+ "should reject because the account was deleted"
);
Assert.ok(accessTokenWithSessionTokenCalled);
@@ -801,14 +803,11 @@ add_task(async function test_getKeysMissing() {
storageManager.initialize(identityConfig.fxaccount.user);
return new AccountState(storageManager);
},
- // And the keys object with a mock that returns no keys.
- keys: {
- getKeyForScope() {
- return Promise.resolve(null);
- },
- },
});
-
+ fxa.getOAuthTokenAndKey = () => {
+ // And the keys object with a mock that returns no keys.
+ return Promise.resolve({ key: null, token: "fake token" });
+ };
syncAuthManager._fxaService = fxa;
await Assert.rejects(
@@ -844,14 +843,12 @@ add_task(async function test_getKeysUnexpecedError() {
storageManager.initialize(identityConfig.fxaccount.user);
return new AccountState(storageManager);
},
- // And the keys object with a mock that returns no keys.
- keys: {
- async getKeyForScope() {
- throw new Error("well that was unexpected");
- },
- },
});
+ fxa.getOAuthTokenAndKey = () => {
+ return Promise.reject("well that was unexpected");
+ };
+
syncAuthManager._fxaService = fxa;
await Assert.rejects(
@@ -1005,7 +1002,7 @@ function mockTokenServer(func) {
requestLog.addAppender(new Log.DumpAppender());
requestLog.level = Log.Level.Trace;
}
- function MockRESTRequest(url) {}
+ function MockRESTRequest() {}
MockRESTRequest.prototype = {
_log: requestLog,
setHeader() {},
diff --git a/services/sync/tests/unit/test_syncedtabs.js b/services/sync/tests/unit/test_syncedtabs.js
index 79ab3e0686..c915e12602 100644
--- a/services/sync/tests/unit/test_syncedtabs.js
+++ b/services/sync/tests/unit/test_syncedtabs.js
@@ -87,7 +87,7 @@ let MockClientsEngine = {
return tabsEngine.clients[id].fxaDeviceId;
},
- getClientType(id) {
+ getClientType() {
return "desktop";
},
};
diff --git a/services/sync/tests/unit/test_syncscheduler.js b/services/sync/tests/unit/test_syncscheduler.js
index 98b7937da3..8eb1ea3f40 100644
--- a/services/sync/tests/unit/test_syncscheduler.js
+++ b/services/sync/tests/unit/test_syncscheduler.js
@@ -92,7 +92,7 @@ add_task(async function setup() {
// Don't remove stale clients when syncing. This is a test-only workaround
// that lets us add clients directly to the store, without losing them on
// the next sync.
- clientsEngine._removeRemoteClient = async id => {};
+ clientsEngine._removeRemoteClient = async () => {};
await Service.engineManager.clear();
validate_all_future_pings();
diff --git a/services/sync/tests/unit/test_tab_quickwrite.js b/services/sync/tests/unit/test_tab_quickwrite.js
index 2a1c75c8c6..c363992d66 100644
--- a/services/sync/tests/unit/test_tab_quickwrite.js
+++ b/services/sync/tests/unit/test_tab_quickwrite.js
@@ -179,7 +179,7 @@ add_task(async function test_tab_quickWrite_telemetry() {
let telem = get_sync_test_telemetry();
telem.payloads = [];
let oldSubmit = telem.submit;
- let submitPromise = new Promise((resolve, reject) => {
+ let submitPromise = new Promise(resolve => {
telem.submit = function (ping) {
telem.submit = oldSubmit;
resolve(ping);
diff --git a/services/sync/tests/unit/test_telemetry.js b/services/sync/tests/unit/test_telemetry.js
index 961e96a01b..4f3a4e7c2b 100644
--- a/services/sync/tests/unit/test_telemetry.js
+++ b/services/sync/tests/unit/test_telemetry.js
@@ -734,7 +734,7 @@ add_task(async function test_clean_real_os_error() {
equal(failureReason.name, "unexpectederror");
equal(
failureReason.error,
- "OS error [File/Path not found] Could not open the file at [profileDir]/no/such/path.json"
+ "OS error [File/Path not found] Could not open `[profileDir]/no/such/path.json': file does not exist"
);
});
} finally {
@@ -1351,7 +1351,7 @@ add_task(async function test_no_node_type() {
await configureIdentity(null, server);
await sync_and_validate_telem(ping => {
- ok(ping.syncNodeType === undefined);
+ Assert.strictEqual(ping.syncNodeType, undefined);
}, true);
await promiseStopServer(server);
});
diff --git a/services/sync/tests/unit/test_uistate.js b/services/sync/tests/unit/test_uistate.js
index cb1ff1979e..136f274a71 100644
--- a/services/sync/tests/unit/test_uistate.js
+++ b/services/sync/tests/unit/test_uistate.js
@@ -292,7 +292,7 @@ add_task(async function test_syncFinished() {
const newState = Object.assign({}, UIState.get());
ok(!newState.syncing);
- ok(new Date(newState.lastSync) > new Date(oldState.lastSync));
+ Assert.greater(new Date(newState.lastSync), new Date(oldState.lastSync));
});
add_task(async function test_syncError() {
@@ -314,7 +314,7 @@ add_task(async function test_syncError() {
function observeUIUpdate() {
return new Promise(resolve => {
- let obs = (aSubject, aTopic, aData) => {
+ let obs = (aSubject, aTopic) => {
Services.obs.removeObserver(obs, aTopic);
const state = UIState.get();
resolve(state);