mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-11-23 21:01:08 +00:00
Bug 1891788 - Create a head file for services/settings/test/unit/. r=leplatrem
Also switch tests to add_setup. Differential Revision: https://phabricator.services.mozilla.com/D208348
This commit is contained in:
parent
5c081fb009
commit
55bb3a0999
25
services/settings/test/unit/head_settings.js
Normal file
25
services/settings/test/unit/head_settings.js
Normal file
@ -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",
|
||||
});
|
@ -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",
|
||||
|
@ -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() {
|
||||
|
@ -1,9 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
const { Utils } = ChromeUtils.importESModule(
|
||||
"resource://services-settings/Utils.sys.mjs"
|
||||
);
|
||||
|
||||
async function getLocalDumpLastModified(bucket, collection) {
|
||||
let res;
|
||||
try {
|
||||
|
@ -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([
|
||||
|
@ -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.
|
||||
|
@ -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);
|
||||
|
||||
|
@ -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
|
||||
|
@ -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(
|
||||
|
@ -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
|
||||
|
@ -1,9 +1,5 @@
|
||||
"use strict";
|
||||
|
||||
const { SyncHistory } = ChromeUtils.importESModule(
|
||||
"resource://services-settings/SyncHistory.sys.mjs"
|
||||
);
|
||||
|
||||
async function clear_state() {
|
||||
await new SyncHistory("").clear();
|
||||
}
|
||||
|
@ -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",
|
||||
|
@ -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();
|
||||
});
|
||||
|
||||
|
@ -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() {
|
||||
|
@ -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;
|
||||
|
@ -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/**"]
|
||||
|
Loading…
Reference in New Issue
Block a user