test_addons_validator.js (1643B)
1 /* Any copyright is dedicated to the Public Domain. 2 http://creativecommons.org/publicdomain/zero/1.0/ */ 3 4 const { AddonValidator } = ChromeUtils.importESModule( 5 "resource://services-sync/engines/addons.sys.mjs" 6 ); 7 8 function getDummyServerAndClient() { 9 return { 10 server: [ 11 { 12 id: "1111", 13 applicationID: Services.appinfo.ID, 14 addonID: "synced-addon@example.com", 15 enabled: true, 16 source: "amo", 17 understood: true, 18 }, 19 ], 20 client: [ 21 { 22 syncGUID: "1111", 23 id: "synced-addon@example.com", 24 type: "extension", 25 isSystem: false, 26 isSyncable: true, 27 }, 28 { 29 syncGUID: "2222", 30 id: "system-addon@example.com", 31 type: "extension", 32 isSystem: true, 33 isSyncable: false, 34 }, 35 { 36 // Plugins don't have a `syncedGUID`, but we don't sync them, so we 37 // shouldn't report them as client duplicates. 38 id: "some-plugin", 39 type: "plugin", 40 }, 41 { 42 id: "another-plugin", 43 type: "plugin", 44 }, 45 ], 46 }; 47 } 48 49 add_task(async function test_valid() { 50 let { server, client } = getDummyServerAndClient(); 51 let validator = new AddonValidator({ 52 _findDupe() { 53 return null; 54 }, 55 isAddonSyncable(item) { 56 return item.type != "plugin"; 57 }, 58 }); 59 let { problemData, clientRecords, records, deletedRecords } = 60 await validator.compareClientWithServer(client, server); 61 equal(clientRecords.length, 4); 62 equal(records.length, 1); 63 equal(deletedRecords.length, 0); 64 deepEqual(problemData, validator.emptyProblemData()); 65 });