diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-06-12 05:43:14 +0000 |
commit | 8dd16259287f58f9273002717ec4d27e97127719 (patch) | |
tree | 3863e62a53829a84037444beab3abd4ed9dfc7d0 /services/settings | |
parent | Releasing progress-linux version 126.0.1-1~progress7.99u1. (diff) | |
download | firefox-8dd16259287f58f9273002717ec4d27e97127719.tar.xz firefox-8dd16259287f58f9273002717ec4d27e97127719.zip |
Merging upstream version 127.0.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'services/settings')
23 files changed, 429 insertions, 264 deletions
diff --git a/services/settings/Attachments.sys.mjs b/services/settings/Attachments.sys.mjs index 345bf1e8e6..7724afd5b8 100644 --- a/services/settings/Attachments.sys.mjs +++ b/services/settings/Attachments.sys.mjs @@ -10,6 +10,8 @@ ChromeUtils.defineESModuleGetters(lazy, { Utils: "resource://services-settings/Utils.sys.mjs", }); +ChromeUtils.defineLazyGetter(lazy, "console", () => lazy.Utils.log); + class DownloadError extends Error { constructor(url, resp) { super(`Could not download ${url}`); @@ -212,6 +214,15 @@ export class Downloader { ); } + if (!lazy.Utils.LOAD_DUMPS) { + if (fallbackToDump) { + lazy.console.warn( + "#fetchAttachment: Forcing fallbackToDump to false due to Utils.LOAD_DUMPS being false" + ); + } + fallbackToDump = false; + } + const dumpInfo = new LazyRecordAndBuffer(() => this._readAttachmentDump(attachmentId) ); diff --git a/services/settings/RemoteSettingsClient.sys.mjs b/services/settings/RemoteSettingsClient.sys.mjs index c521b72123..2153520adb 100644 --- a/services/settings/RemoteSettingsClient.sys.mjs +++ b/services/settings/RemoteSettingsClient.sys.mjs @@ -469,9 +469,10 @@ export class RemoteSettingsClient extends EventEmitter { } else { lazy.console.debug(`${this.identifier} Awaiting existing import.`); } - } else if (hasLocalData && loadDumpIfNewer) { + } else if (hasLocalData && loadDumpIfNewer && lazy.Utils.LOAD_DUMPS) { // Check whether the local data is older than the packaged dump. - // If it is, load the packaged dump (which overwrites the local data). + // If it is and we are on production, load the packaged dump (which + // overwrites the local data). let lastModifiedDump = await lazy.Utils.getLocalDumpLastModified( this.bucketName, this.collectionName diff --git a/services/settings/dumps/blocklists/addons-bloomfilters.json b/services/settings/dumps/blocklists/addons-bloomfilters.json index 489a3dc429..6cdec41139 100644 --- a/services/settings/dumps/blocklists/addons-bloomfilters.json +++ b/services/settings/dumps/blocklists/addons-bloomfilters.json @@ -3,6 +3,35 @@ { "stash": { "blocked": [ + "{a5eff3e0-fd15-4905-8799-a3c8a3a1eb56}:1.6", + "{437c932f-fa9f-459d-8dab-ea6219d23513}:1.7", + "{2aeb7e23-47e4-4a41-9125-f5a28e9b62cf}:1.4" + ], + "unblocked": [] + }, + "schema": 1717054814742, + "key_format": "{guid}:{version}", + "stash_time": 1717094105559, + "id": "410c26fe-3975-49d7-9926-511f891fcfcf", + "last_modified": 1717094162111 + }, + { + "stash": { + "blocked": [ + "superiorblock@ext:1.0", + "charityaff@testnet:2024.1" + ], + "unblocked": [] + }, + "schema": 1716455304678, + "key_format": "{guid}:{version}", + "stash_time": 1716834906988, + "id": "dcd0b6d7-76ec-4c93-a447-c90fb79a8376", + "last_modified": 1716834963648 + }, + { + "stash": { + "blocked": [ "hiddenads@addon:1.2", "hiddenads@addon:1.1" ], @@ -678,5 +707,5 @@ "last_modified": 1707395854769 } ], - "timestamp": 1715085361954 + "timestamp": 1717094162111 } diff --git a/services/settings/dumps/main/cookie-banner-rules-list.json b/services/settings/dumps/main/cookie-banner-rules-list.json index e1757708ea..440c43ec92 100644 --- a/services/settings/dumps/main/cookie-banner-rules-list.json +++ b/services/settings/dumps/main/cookie-banner-rules-list.json @@ -2,6 +2,96 @@ "data": [ { "click": { + "optIn": "custom-button#consentAccept", + "presence": "main[data-consent-main]" + }, + "schema": 1717015159283, + "domains": [ + "rp-online.de" + ], + "id": "06ae9b8e-909a-4f50-be66-0046a1a75ddf", + "last_modified": 1717071078321 + }, + { + "click": { + "optIn": ".cookie-consent-banner__btn-primary", + "presence": "#cookie-consent-banner" + }, + "schema": 1717015159283, + "cookies": { + "optOut": [ + { + "name": "__tnw_cookieConsent", + "value": "{%22ad_storage%22:%22denied%22%2C%22analytics_storage%22:%22denied%22}" + } + ] + }, + "domains": [ + "thenextweb.com" + ], + "id": "02c3c5e1-03a6-426a-b00b-fa34f62322fd", + "last_modified": 1717071078318 + }, + { + "click": { + "optIn": "div[data-tracking-opt-in-accept=\"true\"]", + "optOut": "div[data-tracking-opt-in-reject=\"true\"]", + "presence": "div[data-tracking-opt-in-overlay=\"true\"]" + }, + "schema": 1717015159283, + "domains": [ + "fandom.com" + ], + "id": "D168AF87-F481-4AD7-BE78-28A59F798406", + "last_modified": 1717071078313 + }, + { + "schema": 1717015159283, + "cookies": { + "optIn": [ + { + "name": "d_prefs", + "value": "MToxLGNvbnNlbnRfdmVyc2lvbjoyLHRleHRfdmVyc2lvbjoxMDAw" + } + ], + "optOut": [ + { + "name": "d_prefs", + "value": "MjoxLGNvbnNlbnRfdmVyc2lvbjoyLHRleHRfdmVyc2lvbjoxMDAw" + }, + { + "name": "twtr_pixel_opt_in", + "value": "N" + } + ] + }, + "domains": [ + "twitter.com", + "x.com" + ], + "id": "05b3b417-c4c7-4ed0-a3cf-43053e8b33ab", + "last_modified": 1717071078310 + }, + { + "click": { + "optIn": "[data-cookiebanner=\"accept_button\"]", + "optOut": "[data-cookiebanner=\"accept_only_essential_button\"]", + "presence": "[data-testid=\"cookie-policy-manage-dialog\"]" + }, + "schema": 1717015159283, + "domains": [ + "facebook.com", + "instagram.com", + "messenger.com", + "meta.com", + "oculus.com", + "workplace.com" + ], + "id": "d1d8ba36-ced7-4453-8b17-2e051e0ab1eb", + "last_modified": 1717071078306 + }, + { + "click": { "optIn": "#shopify-pc__banner__btn-accept", "optOut": "#shopify-pc__banner__btn-decline", "presence": "#shopify-pc__banner" @@ -1368,32 +1458,6 @@ "last_modified": 1714811639827 }, { - "schema": 1714780808679, - "cookies": { - "optIn": [ - { - "name": "d_prefs", - "value": "MToxLGNvbnNlbnRfdmVyc2lvbjoyLHRleHRfdmVyc2lvbjoxMDAw" - } - ], - "optOut": [ - { - "name": "d_prefs", - "value": "MjoxLGNvbnNlbnRfdmVyc2lvbjoyLHRleHRfdmVyc2lvbjoxMDAw" - }, - { - "name": "twtr_pixel_opt_in", - "value": "N" - } - ] - }, - "domains": [ - "twitter.com" - ], - "id": "05b3b417-c4c7-4ed0-a3cf-43053e8b33ab", - "last_modified": 1714811639824 - }, - { "click": { "optIn": "button#CybotCookiebotDialogBodyLevelButtonLevelOptinAllowAll", "optOut": "button#CybotCookiebotDialogBodyButtonDecline", @@ -2182,22 +2246,6 @@ }, { "click": { - "optIn": "[data-cookiebanner=\"accept_button\"]", - "optOut": "[data-cookiebanner=\"accept_only_essential_button\"]", - "presence": "[data-testid=\"cookie-policy-manage-dialog\"]" - }, - "schema": 1710174339269, - "domains": [ - "facebook.com", - "messenger.com", - "oculus.com", - "workplace.com" - ], - "id": "d1d8ba36-ced7-4453-8b17-2e051e0ab1eb", - "last_modified": 1710331175381 - }, - { - "click": { "optIn": "#cookiescript_accept", "optOut": "#cookiescript_reject", "presence": "#cookiescript_injected_wrapper" @@ -4212,18 +4260,6 @@ "last_modified": 1697710931635 }, { - "click": { - "optIn": "div[data-tracking-opt-in-accept=\"true\"]", - "presence": "div[data-tracking-opt-in-overlay=\"true\"]" - }, - "schema": 1697557061727, - "domains": [ - "fandom.com" - ], - "id": "D168AF87-F481-4AD7-BE78-28A59F798406", - "last_modified": 1697710931628 - }, - { "schema": 1697557061727, "cookies": { "optOut": [ @@ -10115,5 +10151,5 @@ "last_modified": 1670498155651 } ], - "timestamp": 1714811640008 + "timestamp": 1717071078321 } diff --git a/services/settings/dumps/main/devtools-compatibility-browsers.json b/services/settings/dumps/main/devtools-compatibility-browsers.json index 4f78ce96d0..0f422a8f37 100644 --- a/services/settings/dumps/main/devtools-compatibility-browsers.json +++ b/services/settings/dumps/main/devtools-compatibility-browsers.json @@ -1,6 +1,15 @@ { "data": [ { + "name": "Edge", + "schema": 1716941107417, + "status": "current", + "version": "125", + "browserid": "edge", + "id": "f1147d5f-d690-43d0-879d-117c6ca24a16", + "last_modified": 1716966331501 + }, + { "name": "Firefox", "schema": 1715731507143, "status": "planned", @@ -182,15 +191,6 @@ }, { "name": "Edge", - "schema": 1714638388703, - "status": "beta", - "version": "125", - "browserid": "edge", - "id": "f1147d5f-d690-43d0-879d-117c6ca24a16", - "last_modified": 1715003394958 - }, - { - "name": "Edge", "schema": 1714867506401, "status": "nightly", "version": "126", @@ -208,15 +208,6 @@ "last_modified": 1714638388565 }, { - "name": "Edge", - "schema": 1714521906580, - "status": "current", - "version": "124", - "browserid": "edge", - "id": "3837dc37-38b7-483b-82b3-c5593e7a4c91", - "last_modified": 1714638388557 - }, - { "name": "Opera", "schema": 1713917107636, "status": "current", @@ -289,5 +280,5 @@ "last_modified": 1665656484764 } ], - "timestamp": 1715839095932 + "timestamp": 1716966331504 } diff --git a/services/settings/dumps/main/search-config-v2.json b/services/settings/dumps/main/search-config-v2.json index ec2e2cd829..3848d688ae 100644 --- a/services/settings/dumps/main/search-config-v2.json +++ b/services/settings/dumps/main/search-config-v2.json @@ -2524,10 +2524,10 @@ } }, "id": "8111d157-e064-40fa-993d-e1d972534754", - "identifier": "mercadolibre", - "last_modified": 1702906502289, + "identifier": "mercadolibre-ar", + "last_modified": 1717416922456, "recordType": "engine", - "schema": 1702901827142, + "schema": 1717411267717, "variants": [ { "environment": { @@ -7219,10 +7219,10 @@ } }, "id": "7c9d2fc3-1e6b-40f6-80ad-080bd94fe24b", - "identifier": "wiktionary", - "last_modified": 1702906502251, + "identifier": "wiktionary-oc", + "last_modified": 1717416922458, "recordType": "engine", - "schema": 1702901835738, + "schema": 1717411323291, "variants": [ { "environment": { @@ -7420,5 +7420,5 @@ "schema": 1707824831520 } ], - "timestamp": 1715090108535 + "timestamp": 1717416922458 } diff --git a/services/settings/dumps/security-state/intermediates.json b/services/settings/dumps/security-state/intermediates.json index 35b0b0893d..49a76e2cec 100644 --- a/services/settings/dumps/security-state/intermediates.json +++ b/services/settings/dumps/security-state/intermediates.json @@ -1,6 +1,114 @@ { "data": [ { + "schema": 1717559643220, + "derHash": "zBufnkNw+2gUHSihFeqoY/jq23oE4r0js8YvnZ8XwmM=", + "subject": "CN=FIRMAPROFESIONAL ICA A01 QWAC 2022,O=Firmaprofesional SA,C=ES", + "subjectDN": "MHIxCzAJBgNVBAYTAkVTMRwwGgYDVQQKDBNGaXJtYXByb2Zlc2lvbmFsIFNBMRgwFgYDVQRhDA9WQVRFUy1BNjI2MzQwNjgxKzApBgNVBAMMIkZJUk1BUFJPRkVTSU9OQUwgSUNBIEEwMSBRV0FDIDIwMjI=", + "whitelist": false, + "attachment": { + "hash": "d736a3e7ddd478034b9ce53949685d8115e8a539876acfe978db47a7cda1e5c6", + "size": 1447, + "filename": "bVle95d2TFsMug2xpivw0fPUY7VsTluskvwQa1q1hms=.pem", + "location": "security-state-staging/intermediates/ef18664d-a3b4-4937-86fa-040d42090680.pem", + "mimetype": "application/x-pem-file" + }, + "pubKeyHash": "bVle95d2TFsMug2xpivw0fPUY7VsTluskvwQa1q1hms=", + "crlite_enrolled": false, + "id": "b693d627-7f28-4463-adb8-51bd4f3c2712", + "last_modified": 1717559823094 + }, + { + "schema": 1717559643616, + "derHash": "Iv1U+TOxf0WJQsNF465iXkBc5AsZGzFriHyj0CzKw7E=", + "subject": "CN=FIRMAPROFESIONAL ICA A02 NO QWAC 2022,O=Firmaprofesional SA,C=ES", + "subjectDN": "MHUxCzAJBgNVBAYTAkVTMRwwGgYDVQQKDBNGaXJtYXByb2Zlc2lvbmFsIFNBMRgwFgYDVQRhDA9WQVRFUy1BNjI2MzQwNjgxLjAsBgNVBAMMJUZJUk1BUFJPRkVTSU9OQUwgSUNBIEEwMiBOTyBRV0FDIDIwMjI=", + "whitelist": false, + "attachment": { + "hash": "c1332c5b2b17a40d7e1c836a6cff328b9adb70daa8683b785dd00bc661c36f89", + "size": 1451, + "filename": "d96AQ4m8-YeSRHUqkGB8vTJPwsoHOcOVl8BS6_lfdXM=.pem", + "location": "security-state-staging/intermediates/01df6fff-e459-4353-a8c7-56a5333a7ebe.pem", + "mimetype": "application/x-pem-file" + }, + "pubKeyHash": "d96AQ4m8+YeSRHUqkGB8vTJPwsoHOcOVl8BS6/lfdXM=", + "crlite_enrolled": false, + "id": "27e327c4-059e-49c9-8697-35cb673ccf87", + "last_modified": 1717559823092 + }, + { + "schema": 1717192455323, + "derHash": "158fDIFBgEs50EslktV6/r50+UYGVK/0kUkNu3xaLXQ=", + "subject": "CN=XinChaCha Trust EV TLS G2 R34 CA,O=Beijing Xinchacha Credit Management Co.\\, Ltd.,C=CN", + "subjectDN": "MHAxCzAJBgNVBAYTAkNOMTYwNAYDVQQKDC1CZWlqaW5nIFhpbmNoYWNoYSBDcmVkaXQgTWFuYWdlbWVudCBDby4sIEx0ZC4xKTAnBgNVBAMMIFhpbkNoYUNoYSBUcnVzdCBFViBUTFMgRzIgUjM0IENB", + "whitelist": false, + "attachment": { + "hash": "cf9549b1295f7f5940d1eecd85224fe71746a9062b3324375a1ba76e6d1076db", + "size": 2393, + "filename": "-NirAYepPYxIIKyEoNgiZNqhl8nplSzI0S3gILMyP48=.pem", + "location": "security-state-staging/intermediates/3304fe4e-f870-45ba-8df0-81b2a42b4266.pem", + "mimetype": "application/x-pem-file" + }, + "pubKeyHash": "+NirAYepPYxIIKyEoNgiZNqhl8nplSzI0S3gILMyP48=", + "crlite_enrolled": false, + "id": "6b1982a7-6538-4496-a5ea-475ad795dca4", + "last_modified": 1717192623098 + }, + { + "schema": 1717192454914, + "derHash": "tch6CyI52v4KUoXjQGJiaayl6Q9XSSw46QUMpdGLwho=", + "subject": "CN=XinChaCha Trust DV TLS G2 R34 CA,O=Beijing Xinchacha Credit Management Co.\\, Ltd.,C=CN", + "subjectDN": "MHAxCzAJBgNVBAYTAkNOMTYwNAYDVQQKDC1CZWlqaW5nIFhpbmNoYWNoYSBDcmVkaXQgTWFuYWdlbWVudCBDby4sIEx0ZC4xKTAnBgNVBAMMIFhpbkNoYUNoYSBUcnVzdCBEViBUTFMgRzIgUjM0IENB", + "whitelist": false, + "attachment": { + "hash": "46a17eb3357831af3e72dd3e752ae9d06b7ab5c7e2bde38c552efac33da3c3e7", + "size": 2393, + "filename": "ia3jA8mRz8AVBO57iULX9U3eGAXK9KzaSydFhjkVQp8=.pem", + "location": "security-state-staging/intermediates/d7185123-3b86-4d58-897d-92ce9c326347.pem", + "mimetype": "application/x-pem-file" + }, + "pubKeyHash": "ia3jA8mRz8AVBO57iULX9U3eGAXK9KzaSydFhjkVQp8=", + "crlite_enrolled": false, + "id": "0c74406b-6c55-4aa5-a137-e7f059e08b40", + "last_modified": 1717192623095 + }, + { + "schema": 1717192454523, + "derHash": "tdRtwCcTDlztO+UIPrNAKN2SMPTVo2rRkk0hwO+YTLo=", + "subject": "CN=XinChaCha Trust OV TLS G2 R34 CA,O=Beijing Xinchacha Credit Management Co.\\, Ltd.,C=CN", + "subjectDN": "MHAxCzAJBgNVBAYTAkNOMTYwNAYDVQQKDC1CZWlqaW5nIFhpbmNoYWNoYSBDcmVkaXQgTWFuYWdlbWVudCBDby4sIEx0ZC4xKTAnBgNVBAMMIFhpbkNoYUNoYSBUcnVzdCBPViBUTFMgRzIgUjM0IENB", + "whitelist": false, + "attachment": { + "hash": "f3b04dbb9ce45e317a43dd7e0bb1f2d617cf950b6c4f4dcd9041ba8c29903ca9", + "size": 2393, + "filename": "BTYzRPrLbl9bgC2AezB8r8c6OQbO2yNxAWm2wTdHcPM=.pem", + "location": "security-state-staging/intermediates/5b4a4976-5c36-4f3c-ad2c-c646050b9449.pem", + "mimetype": "application/x-pem-file" + }, + "pubKeyHash": "BTYzRPrLbl9bgC2AezB8r8c6OQbO2yNxAWm2wTdHcPM=", + "crlite_enrolled": false, + "id": "6ab4c9cc-76f0-46fa-a224-955f948b8672", + "last_modified": 1717192623093 + }, + { + "schema": 1717192453960, + "derHash": "UJq7uShkwsRNfLxGa2OVDjUBZe53KjA3roFo6SImpG8=", + "subject": "CN=Shoper DV TLS G2 R34 CA,O=Shoper S.A.,C=PL", + "subjectDN": "MEUxCzAJBgNVBAYTAlBMMRQwEgYDVQQKDAtTaG9wZXIgUy5BLjEgMB4GA1UEAwwXU2hvcGVyIERWIFRMUyBHMiBSMzQgQ0E=", + "whitelist": false, + "attachment": { + "hash": "89370aee0f5144d748f03671a40cd353d07ebc3e624152b697c93eac8414ae0c", + "size": 2337, + "filename": "-g6X50iw1KjEyqdAsOvTe7IZ3ChaEo_P0UMuuNWHp4s=.pem", + "location": "security-state-staging/intermediates/90e3e772-6b7e-49ca-ad56-1ad21d0e3c6b.pem", + "mimetype": "application/x-pem-file" + }, + "pubKeyHash": "+g6X50iw1KjEyqdAsOvTe7IZ3ChaEo/P0UMuuNWHp4s=", + "crlite_enrolled": false, + "id": "9de0322b-3852-44e0-a52c-20c5398fb224", + "last_modified": 1717192623090 + }, + { "schema": 1714791237384, "derHash": "5b/O2dIW66faNjSBn7U0+5zroez55jee2DWD0usXfBs=", "subject": "CN=CrowdStrike TLS RSA CA G5,O=CrowdStrike\\, Inc.,C=US", @@ -30907,5 +31015,5 @@ "last_modified": 1559865884636 } ], - "timestamp": 1715637423088 + "timestamp": 1717559823094 } diff --git a/services/settings/test/unit/head_settings.js b/services/settings/test/unit/head_settings.js new file mode 100644 index 0000000000..96573a9fcb --- /dev/null +++ b/services/settings/test/unit/head_settings.js @@ -0,0 +1,25 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +/* import-globals-from ../../../common/tests/unit/head_global.js */ +/* import-globals-from ../../../common/tests/unit/head_helpers.js */ + +"use strict"; + +ChromeUtils.defineESModuleGetters(this, { + AppConstants: "resource://gre/modules/AppConstants.sys.mjs", + Database: "resource://services-settings/Database.sys.mjs", + Policy: "resource://services-common/uptake-telemetry.sys.mjs", + RemoteSettings: "resource://services-settings/remote-settings.sys.mjs", + RemoteSettingsClient: + "resource://services-settings/RemoteSettingsClient.sys.mjs", + RemoteSettingsWorker: + "resource://services-settings/RemoteSettingsWorker.sys.mjs", + setTimeout: "resource://gre/modules/Timer.sys.mjs", + SharedUtils: "resource://services-settings/SharedUtils.sys.mjs", + SyncHistory: "resource://services-settings/SyncHistory.sys.mjs", + TelemetryTestUtils: "resource://testing-common/TelemetryTestUtils.sys.mjs", + TestUtils: "resource://testing-common/TestUtils.sys.mjs", + UptakeTelemetry: "resource://services-common/uptake-telemetry.sys.mjs", + Utils: "resource://services-settings/Utils.sys.mjs", +}); diff --git a/services/settings/test/unit/test_attachments_downloader.js b/services/settings/test/unit/test_attachments_downloader.js index 284294cfde..2f7db36d8b 100644 --- a/services/settings/test/unit/test_attachments_downloader.js +++ b/services/settings/test/unit/test_attachments_downloader.js @@ -1,17 +1,6 @@ -/* import-globals-from ../../../common/tests/unit/head_helpers.js */ - -const { RemoteSettings } = ChromeUtils.importESModule( - "resource://services-settings/remote-settings.sys.mjs" -); -const { UptakeTelemetry } = ChromeUtils.importESModule( - "resource://services-common/uptake-telemetry.sys.mjs" -); const { Downloader } = ChromeUtils.importESModule( "resource://services-settings/Attachments.sys.mjs" ); -const { TelemetryTestUtils } = ChromeUtils.importESModule( - "resource://testing-common/TelemetryTestUtils.sys.mjs" -); const RECORD = { id: "1f3a0802-648d-11ea-bd79-876a8b69c377", @@ -56,6 +45,11 @@ add_setup(() => { "/cdn/main-workspace/some-collection/", do_get_file("test_attachments_downloader") ); + + // For this test, we are using a server other than production. Force + // LOAD_DUMPS to true so that we can still load attachments from dumps. + delete Utils.LOAD_DUMPS; + Utils.LOAD_DUMPS = true; }); async function clear_state() { @@ -619,6 +613,80 @@ add_task(async function test_download_from_dump() { // but added for consistency with other tests tasks around here. add_task(clear_state); +add_task( + async function test_download_from_dump_fails_when_load_dumps_is_false() { + const client = RemoteSettings("dump-collection", { + bucketName: "dump-bucket", + }); + + // Temporarily replace the resource:-URL with another resource:-URL. + const orig_RESOURCE_BASE_URL = Downloader._RESOURCE_BASE_URL; + Downloader._RESOURCE_BASE_URL = "resource://rs-downloader-test"; + const resProto = Services.io + .getProtocolHandler("resource") + .QueryInterface(Ci.nsIResProtocolHandler); + resProto.setSubstitution( + "rs-downloader-test", + Services.io.newFileURI(do_get_file("test_attachments_downloader")) + ); + + function checkInfo( + result, + expectedSource, + expectedRecord = RECORD_OF_DUMP + ) { + Assert.equal( + new TextDecoder().decode(new Uint8Array(result.buffer)), + "This would be a RS dump.\n", + "expected content from dump" + ); + Assert.deepEqual( + result.record, + expectedRecord, + "expected record for dump" + ); + Assert.equal(result._source, expectedSource, "expected source of dump"); + } + + // Download the dump so that we can use it to fill the cache. + const dump1 = await client.attachments.download(RECORD_OF_DUMP, { + // Note: attachmentId not set, so should fall back to record.id. + fallbackToDump: true, + }); + checkInfo(dump1, "dump_match"); + + // Fill the cache with the same data as the dump for the next part. + await client.db.saveAttachment(RECORD_OF_DUMP.id, { + record: RECORD_OF_DUMP, + blob: new Blob([dump1.buffer]), + }); + + // Now turn off loading dumps, and check we no longer load from the dump, + // but use the cache instead. + Utils.LOAD_DUMPS = false; + + const dump2 = await client.attachments.download(RECORD_OF_DUMP, { + // Note: attachmentId not set, so should fall back to record.id. + fallbackToDump: true, + }); + checkInfo(dump2, "cache_match"); + + // When the record is not given, the dump would take precedence over the + // cache but we have disabled dumps, so we should load from the cache. + const dump4 = await client.attachments.download(null, { + attachmentId: RECORD_OF_DUMP.id, + fallbackToCache: true, + fallbackToDump: true, + }); + checkInfo(dump4, "cache_fallback"); + + // Restore, just in case. + Utils.LOAD_DUMPS = true; + Downloader._RESOURCE_BASE_URL = orig_RESOURCE_BASE_URL; + resProto.setSubstitution("rs-downloader-test", null); + } +); + add_task(async function test_attachment_get() { // Since get() is largely a wrapper around the same code as download(), // we only test a couple of parts to check it functions as expected, and diff --git a/services/settings/test/unit/test_remote_settings.js b/services/settings/test/unit/test_remote_settings.js index 382d1aa983..07007a755f 100644 --- a/services/settings/test/unit/test_remote_settings.js +++ b/services/settings/test/unit/test_remote_settings.js @@ -1,27 +1,8 @@ /* import-globals-from ../../../common/tests/unit/head_helpers.js */ -const { AppConstants } = ChromeUtils.importESModule( - "resource://gre/modules/AppConstants.sys.mjs" -); const { ObjectUtils } = ChromeUtils.importESModule( "resource://gre/modules/ObjectUtils.sys.mjs" ); -const { setTimeout } = ChromeUtils.importESModule( - "resource://gre/modules/Timer.sys.mjs" -); - -const { RemoteSettings } = ChromeUtils.importESModule( - "resource://services-settings/remote-settings.sys.mjs" -); -const { Utils } = ChromeUtils.importESModule( - "resource://services-settings/Utils.sys.mjs" -); -const { UptakeTelemetry, Policy } = ChromeUtils.importESModule( - "resource://services-common/uptake-telemetry.sys.mjs" -); -const { TelemetryTestUtils } = ChromeUtils.importESModule( - "resource://testing-common/TelemetryTestUtils.sys.mjs" -); const IS_ANDROID = AppConstants.platform == "android"; @@ -54,7 +35,7 @@ async function clear_state() { TelemetryTestUtils.assertEvents([], {}, { process: "dummy" }); } -function run_test() { +add_task(() => { // Set up an HTTP Server server = new HttpServer(); server.start(-1); @@ -93,13 +74,11 @@ function run_test() { ); server.registerPathHandler("/fake-x5u", handleResponse); - run_next_test(); - registerCleanupFunction(() => { Policy.getChannel = oldGetChannel; server.stop(() => {}); }); -} +}); add_task(clear_state); add_task(async function test_records_obtained_from_server_are_stored_in_db() { diff --git a/services/settings/test/unit/test_remote_settings_dump_lastmodified.js b/services/settings/test/unit/test_remote_settings_dump_lastmodified.js index 25de34c1be..6dd925281a 100644 --- a/services/settings/test/unit/test_remote_settings_dump_lastmodified.js +++ b/services/settings/test/unit/test_remote_settings_dump_lastmodified.js @@ -1,9 +1,5 @@ "use strict"; -const { Utils } = ChromeUtils.importESModule( - "resource://services-settings/Utils.sys.mjs" -); - async function getLocalDumpLastModified(bucket, collection) { let res; try { diff --git a/services/settings/test/unit/test_remote_settings_jexl_filters.js b/services/settings/test/unit/test_remote_settings_jexl_filters.js index 56d35bdd2b..b7496332dc 100644 --- a/services/settings/test/unit/test_remote_settings_jexl_filters.js +++ b/services/settings/test/unit/test_remote_settings_jexl_filters.js @@ -1,7 +1,3 @@ -const { RemoteSettings } = ChromeUtils.importESModule( - "resource://services-settings/remote-settings.sys.mjs" -); - let client; async function createRecords(records) { @@ -18,11 +14,9 @@ async function createRecords(records) { ); } -function run_test() { +add_setup(() => { client = RemoteSettings("some-key"); - - run_next_test(); -} +}); add_task(async function test_returns_all_without_target() { await createRecords([ diff --git a/services/settings/test/unit/test_remote_settings_offline.js b/services/settings/test/unit/test_remote_settings_offline.js index 0a250c3e0a..cb194677e1 100644 --- a/services/settings/test/unit/test_remote_settings_offline.js +++ b/services/settings/test/unit/test_remote_settings_offline.js @@ -1,13 +1,3 @@ -const { RemoteSettingsClient } = ChromeUtils.importESModule( - "resource://services-settings/RemoteSettingsClient.sys.mjs" -); -const { RemoteSettingsWorker } = ChromeUtils.importESModule( - "resource://services-settings/RemoteSettingsWorker.sys.mjs" -); -const { SharedUtils } = ChromeUtils.importESModule( - "resource://services-settings/SharedUtils.sys.mjs" -); - // A collection with a dump that's packaged on all builds where this test runs, // including on Android at mobile/android/installer/package-manifest.in const TEST_BUCKET = "main"; @@ -17,7 +7,7 @@ let client; let DUMP_RECORDS; let DUMP_LAST_MODIFIED; -add_task(async function setup() { +add_setup(async () => { // "services.settings.server" pref is not set. // Test defaults to an unreachable server, // and will only load from the dump if any. diff --git a/services/settings/test/unit/test_remote_settings_poll.js b/services/settings/test/unit/test_remote_settings_poll.js index c8025f4b7b..7146429427 100644 --- a/services/settings/test/unit/test_remote_settings_poll.js +++ b/services/settings/test/unit/test_remote_settings_poll.js @@ -1,34 +1,11 @@ -/* import-globals-from ../../../common/tests/unit/head_helpers.js */ - -const { AppConstants } = ChromeUtils.importESModule( - "resource://gre/modules/AppConstants.sys.mjs" -); -const { setTimeout } = ChromeUtils.importESModule( - "resource://gre/modules/Timer.sys.mjs" -); - -const { UptakeTelemetry, Policy } = ChromeUtils.importESModule( - "resource://services-common/uptake-telemetry.sys.mjs" -); -const { RemoteSettingsClient } = ChromeUtils.importESModule( - "resource://services-settings/RemoteSettingsClient.sys.mjs" -); const { pushBroadcastService } = ChromeUtils.importESModule( "resource://gre/modules/PushBroadcastService.sys.mjs" ); -const { SyncHistory } = ChromeUtils.importESModule( - "resource://services-settings/SyncHistory.sys.mjs" -); -const { RemoteSettings, remoteSettingsBroadcastHandler, BROADCAST_ID } = + +const { remoteSettingsBroadcastHandler, BROADCAST_ID } = ChromeUtils.importESModule( "resource://services-settings/remote-settings.sys.mjs" ); -const { Utils } = ChromeUtils.importESModule( - "resource://services-settings/Utils.sys.mjs" -); -const { TelemetryTestUtils } = ChromeUtils.importESModule( - "resource://testing-common/TelemetryTestUtils.sys.mjs" -); const IS_ANDROID = AppConstants.platform == "android"; @@ -80,7 +57,7 @@ function serveChangesEntries(serverTime, entriesOrFunc) { }; } -function run_test() { +add_setup(() => { // Set up an HTTP Server server = new HttpServer(); server.start(-1); @@ -89,13 +66,11 @@ function run_test() { let oldGetChannel = Policy.getChannel; Policy.getChannel = () => "nightly"; - run_next_test(); - registerCleanupFunction(() => { Policy.getChannel = oldGetChannel; server.stop(() => {}); }); -} +}); add_task(clear_state); diff --git a/services/settings/test/unit/test_remote_settings_recover_broken.js b/services/settings/test/unit/test_remote_settings_recover_broken.js index c5f82d6949..5bb047c8af 100644 --- a/services/settings/test/unit/test_remote_settings_recover_broken.js +++ b/services/settings/test/unit/test_remote_settings_recover_broken.js @@ -1,18 +1,3 @@ -/* import-globals-from ../../../common/tests/unit/head_helpers.js */ - -const { SyncHistory } = ChromeUtils.importESModule( - "resource://services-settings/SyncHistory.sys.mjs" -); -const { RemoteSettingsClient } = ChromeUtils.importESModule( - "resource://services-settings/RemoteSettingsClient.sys.mjs" -); -const { RemoteSettings } = ChromeUtils.importESModule( - "resource://services-settings/remote-settings.sys.mjs" -); -const { Utils } = ChromeUtils.importESModule( - "resource://services-settings/Utils.sys.mjs" -); - const PREF_SETTINGS_SERVER = "services.settings.server"; const CHANGES_PATH = "/v1" + Utils.CHANGES_PATH; const BROKEN_SYNC_THRESHOLD = 10; // See default pref value diff --git a/services/settings/test/unit/test_remote_settings_release_prefs.js b/services/settings/test/unit/test_remote_settings_release_prefs.js index 251c407631..5d1a9f2e28 100644 --- a/services/settings/test/unit/test_remote_settings_release_prefs.js +++ b/services/settings/test/unit/test_remote_settings_release_prefs.js @@ -1,9 +1,5 @@ "use strict"; -const { AppConstants } = ChromeUtils.importESModule( - "resource://gre/modules/AppConstants.sys.mjs" -); - var nextUniqId = 0; function getNewUtils() { const { Utils } = ChromeUtils.importESModule( @@ -12,7 +8,21 @@ function getNewUtils() { return Utils; } -function clear_state() { +// A collection with a dump that's packaged on all builds where this test runs, +// including on Android at mobile/android/installer/package-manifest.in +const TEST_BUCKET = "main"; +const TEST_COLLECTION = "password-recipes"; + +async function importData(records) { + await RemoteSettingsWorker._execute("_test_only_import", [ + TEST_BUCKET, + TEST_COLLECTION, + records, + records[0]?.last_modified || 0, + ]); +} + +async function clear_state() { Services.env.set("MOZ_REMOTE_SETTINGS_DEVTOOLS", "0"); Services.prefs.clearUserPref("services.settings.server"); Services.prefs.clearUserPref("services.settings.preview_enabled"); @@ -186,6 +196,42 @@ add_task( const Utils = getNewUtils(); Assert.ok(!Utils.LOAD_DUMPS, "Dumps won't be loaded"); + + // The section below ensures that the LOAD_DUMPS flag properly takes effect. + // The client is set up here rather than add_setup to avoid triggering the + // lazy getters that are behind the global Utils.LOAD_DUMPS. If they are + // triggered too early, then they will potentially cache different values + // for the server urls and environment variables and this test then won't be + // testing what we expect it to. + + let client = new RemoteSettingsClient(TEST_COLLECTION); + + const dump = await SharedUtils.loadJSONDump(TEST_BUCKET, TEST_COLLECTION); + let DUMP_LAST_MODIFIED = dump.timestamp; + + // Dump is updated regularly, verify that the dump matches our expectations + // before running the test. + Assert.greater( + DUMP_LAST_MODIFIED, + 1234, + "Assuming dump to be newer than dummy 1234" + ); + + await client.db.clear(); + await importData([{ last_modified: 1234, id: "dummy" }]); + + const after = await client.get(); + Assert.deepEqual( + after, + [{ last_modified: 1234, id: "dummy" }], + "Should have kept the original import" + ); + Assert.equal( + await client.getLastModified(), + 1234, + "Should have kept the import's timestamp" + ); + await client.db.clear(); } ); add_task(clear_state); diff --git a/services/settings/test/unit/test_remote_settings_signatures.js b/services/settings/test/unit/test_remote_settings_signatures.js index a730ba185e..6d3b01468e 100644 --- a/services/settings/test/unit/test_remote_settings_signatures.js +++ b/services/settings/test/unit/test_remote_settings_signatures.js @@ -1,19 +1,6 @@ /* import-globals-from ../../../common/tests/unit/head_helpers.js */ "use strict"; -const { RemoteSettings } = ChromeUtils.importESModule( - "resource://services-settings/remote-settings.sys.mjs" -); -const { RemoteSettingsClient } = ChromeUtils.importESModule( - "resource://services-settings/RemoteSettingsClient.sys.mjs" -); -const { UptakeTelemetry, Policy } = ChromeUtils.importESModule( - "resource://services-common/uptake-telemetry.sys.mjs" -); -const { TelemetryTestUtils } = ChromeUtils.importESModule( - "resource://testing-common/TelemetryTestUtils.sys.mjs" -); - const PREF_SETTINGS_SERVER = "services.settings.server"; const SIGNER_NAME = "onecrl.content-signature.mozilla.org"; const TELEMETRY_COMPONENT = "remotesettings"; @@ -42,7 +29,7 @@ function getCertChain() { let server; let client; -function run_test() { +add_setup(() => { // Signature verification is enabled by default. We use a custom signer // because these tests were originally written for OneCRL. client = RemoteSettings("signed", { signerName: SIGNER_NAME }); @@ -57,13 +44,11 @@ function run_test() { let oldGetChannel = Policy.getChannel; Policy.getChannel = () => "nightly"; - run_next_test(); - registerCleanupFunction(() => { Policy.getChannel = oldGetChannel; server.stop(() => {}); }); -} +}); add_task(async function test_check_signatures() { // First, perform a signature verification with known data and signature diff --git a/services/settings/test/unit/test_remote_settings_sync_history.js b/services/settings/test/unit/test_remote_settings_sync_history.js index 1fdc3d1adc..cc1c5c2dab 100644 --- a/services/settings/test/unit/test_remote_settings_sync_history.js +++ b/services/settings/test/unit/test_remote_settings_sync_history.js @@ -1,9 +1,5 @@ "use strict"; -const { SyncHistory } = ChromeUtils.importESModule( - "resource://services-settings/SyncHistory.sys.mjs" -); - async function clear_state() { await new SyncHistory("").clear(); } diff --git a/services/settings/test/unit/test_remote_settings_utils.js b/services/settings/test/unit/test_remote_settings_utils.js index de372b3e44..e2b4ddf8e3 100644 --- a/services/settings/test/unit/test_remote_settings_utils.js +++ b/services/settings/test/unit/test_remote_settings_utils.js @@ -1,12 +1,3 @@ -/* import-globals-from ../../../common/tests/unit/head_helpers.js */ - -const { TestUtils } = ChromeUtils.importESModule( - "resource://testing-common/TestUtils.sys.mjs" -); -const { Utils } = ChromeUtils.importESModule( - "resource://services-settings/Utils.sys.mjs" -); - const BinaryOutputStream = Components.Constructor( "@mozilla.org/binaryoutputstream;1", "nsIBinaryOutputStream", diff --git a/services/settings/test/unit/test_remote_settings_utils_telemetry.js b/services/settings/test/unit/test_remote_settings_utils_telemetry.js index f12b0d7f9a..87b72c5f4d 100644 --- a/services/settings/test/unit/test_remote_settings_utils_telemetry.js +++ b/services/settings/test/unit/test_remote_settings_utils_telemetry.js @@ -3,17 +3,9 @@ "use strict"; -/* import-globals-from ../../../common/tests/unit/head_helpers.js */ - const { TelemetryController } = ChromeUtils.importESModule( "resource://gre/modules/TelemetryController.sys.mjs" ); -const { TelemetryTestUtils } = ChromeUtils.importESModule( - "resource://testing-common/TelemetryTestUtils.sys.mjs" -); -const { Utils } = ChromeUtils.importESModule( - "resource://services-settings/Utils.sys.mjs" -); const server = new HttpServer(); server.start(-1); @@ -36,7 +28,7 @@ async function assertTelemetryEvents(expectedEvents) { }); } -add_task(async function setup() { +add_setup(async () => { await TelemetryController.testSetup(); }); diff --git a/services/settings/test/unit/test_remote_settings_worker.js b/services/settings/test/unit/test_remote_settings_worker.js index e2dcdb0063..083beb1a73 100644 --- a/services/settings/test/unit/test_remote_settings_worker.js +++ b/services/settings/test/unit/test_remote_settings_worker.js @@ -1,22 +1,3 @@ -/* import-globals-from ../../../common/tests/unit/head_helpers.js */ - -const { AppConstants } = ChromeUtils.importESModule( - "resource://gre/modules/AppConstants.sys.mjs" -); -const { TestUtils } = ChromeUtils.importESModule( - "resource://testing-common/TestUtils.sys.mjs" -); - -const { RemoteSettingsWorker } = ChromeUtils.importESModule( - "resource://services-settings/RemoteSettingsWorker.sys.mjs" -); -const { RemoteSettingsClient } = ChromeUtils.importESModule( - "resource://services-settings/RemoteSettingsClient.sys.mjs" -); -const { Database } = ChromeUtils.importESModule( - "resource://services-settings/Database.sys.mjs" -); - const IS_ANDROID = AppConstants.platform == "android"; add_task(async function test_canonicaljson() { diff --git a/services/settings/test/unit/test_shutdown_handling.js b/services/settings/test/unit/test_shutdown_handling.js index 2c98f0ab9b..418b25a62d 100644 --- a/services/settings/test/unit/test_shutdown_handling.js +++ b/services/settings/test/unit/test_shutdown_handling.js @@ -3,20 +3,6 @@ http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; -const { TestUtils } = ChromeUtils.importESModule( - "resource://testing-common/TestUtils.sys.mjs" -); - -const { Database } = ChromeUtils.importESModule( - "resource://services-settings/Database.sys.mjs" -); -const { RemoteSettingsWorker } = ChromeUtils.importESModule( - "resource://services-settings/RemoteSettingsWorker.sys.mjs" -); -const { RemoteSettingsClient } = ChromeUtils.importESModule( - "resource://services-settings/RemoteSettingsClient.sys.mjs" -); - add_task(async function test_shutdown_abort_after_start() { // Start a forever transaction: let counter = 0; diff --git a/services/settings/test/unit/xpcshell.toml b/services/settings/test/unit/xpcshell.toml index b305ea39f3..728767e604 100644 --- a/services/settings/test/unit/xpcshell.toml +++ b/services/settings/test/unit/xpcshell.toml @@ -1,5 +1,5 @@ [DEFAULT] -head = "../../../common/tests/unit/head_global.js ../../../common/tests/unit/head_helpers.js" +head = "../../../common/tests/unit/head_global.js ../../../common/tests/unit/head_helpers.js head_settings.js" firefox-appdir = "browser" tags = "remote-settings" support-files = ["test_remote_settings_signatures/**"] |