From 11bfa90d06370979577373f6bb7bf1e6c258d446 Mon Sep 17 00:00:00 2001 From: Mark Banner Date: Mon, 6 Sep 2021 09:53:52 +0000 Subject: [PATCH] Bug 1602940 - Automated replacements to use Services.uuid. r=Gijs,necko-reviewers,preferences-reviewers,kershaw Depends on D124391 Differential Revision: https://phabricator.services.mozilla.com/D124392 --- browser/base/content/test/plugins/BlocklistTestProxy.jsm | 4 +--- .../base/content/test/tabs/browser_reload_deleted_file.js | 4 +--- .../test/browser/browser_AttributionCode_Mac_telemetry.js | 3 +-- browser/components/ion/content/ion.js | 5 +---- .../preferences/tests/browser_advanced_update.js | 4 +--- browser/components/shell/test/browser_1119088.js | 4 +--- .../test/browser/browser_ProcessHangNotifications.js | 4 +--- .../test/browser/browser_UnsubmittedCrashHandler.js | 4 +--- chrome/test/unit/test_data_protocol_registration.js | 4 +--- chrome/test/unit/test_no_remote_registration.js | 4 +--- devtools/shared/generate-uuid.js | 4 +--- devtools/shared/tests/xpcshell/test_console_filtering.js | 4 +--- dom/push/PushServiceWebSocket.jsm | 4 +--- dom/tests/browser/browser_ConsoleAPI_originAttributes.js | 4 +--- .../test/unit/test_permmanager_migrate_4-7_no_history.js | 4 +--- netwerk/dns/mdns/libmdns/DNSServiceDiscovery.jsm | 4 +--- security/sandbox/test/browser_content_sandbox_utils.js | 4 +--- services/common/utils.js | 5 +---- services/fxaccounts/FxAccountsTelemetry.jsm | 3 +-- .../BrowserTestUtils/content/content-about-page-utils.js | 4 +--- testing/specialpowers/content/AppTestDelegateParent.jsm | 4 +--- testing/specialpowers/content/MockColorPicker.jsm | 4 +--- testing/specialpowers/content/MockFilePicker.jsm | 4 +--- testing/specialpowers/content/MockPermissionPrompt.jsm | 4 +--- testing/specialpowers/content/SpecialPowersChild.jsm | 8 ++------ .../browser/browser_staticPartition_CORS_preflight.js | 4 +--- .../test/browser/browser_staticPartition_saveAs.js | 8 ++------ .../autocomplete/tests/unit/head_autocomplete.js | 4 +--- toolkit/components/autocomplete/tests/unit/test_378079.js | 4 +--- toolkit/components/autocomplete/tests/unit/test_393191.js | 4 +--- toolkit/components/autocomplete/tests/unit/test_440866.js | 4 +--- .../autocomplete/tests/unit/test_autocomplete_multiple.js | 4 +--- .../autocomplete/tests/unit/test_previousResult.js | 4 +--- .../components/autocomplete/tests/unit/test_stopSearch.js | 4 +--- .../tests/xpcshell/test_backgroundtask_deletes_profile.js | 5 +---- .../tests/xpcshell/test_backgroundtask_unique_profile.js | 5 +---- .../cleardata/tests/browser/browser_preflight_cache.js | 4 +--- .../components/contentprefs/ContentPrefServiceChild.jsm | 5 +---- toolkit/components/crashes/CrashManager.jsm | 3 +-- toolkit/components/crashes/CrashManagerTest.jsm | 5 +---- .../components/extensions/ExtensionStorageSyncKinto.jsm | 4 +--- .../extensions/test/xpcshell/test_ext_networkStatus.js | 4 +--- .../test/xpcshell/test_ext_storage_sync_kinto.js | 4 +--- toolkit/components/prompts/src/Prompter.jsm | 7 +------ .../tests/xpcshell/test_TaskSchedulerMacOSImpl.js | 4 +--- .../tests/xpcshell/test_TaskSchedulerWinImpl.js | 4 +--- .../tests/xpcshell/test_WinTaskSchedulerService.js | 4 +--- toolkit/components/telemetry/app/TelemetryUtils.jsm | 5 +---- toolkit/components/telemetry/pings/TelemetrySession.jsm | 5 +---- toolkit/crashreporter/test/browser/head.js | 4 +--- toolkit/mozapps/extensions/test/xpcshell/head_addons.js | 4 +--- .../mozapps/extensions/test/xpcshell/test_system_reset.js | 4 +--- .../extensions/test/xpcshell/test_update_webextensions.js | 4 +--- .../mochitest/HelperAppLauncherDialog_chromeScript.js | 4 +--- 54 files changed, 56 insertions(+), 176 deletions(-) diff --git a/browser/base/content/test/plugins/BlocklistTestProxy.jsm b/browser/base/content/test/plugins/BlocklistTestProxy.jsm index 4575bb33264d..eed1413f76d6 100644 --- a/browser/base/content/test/plugins/BlocklistTestProxy.jsm +++ b/browser/base/content/test/plugins/BlocklistTestProxy.jsm @@ -29,9 +29,7 @@ var BlocklistProxy = { init() { if (!this._uuid) { - this._uuid = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID(); + this._uuid = Services.uuid.generateUUID(); Cm.nsIComponentRegistrar.registerFactory( this._uuid, "", diff --git a/browser/base/content/test/tabs/browser_reload_deleted_file.js b/browser/base/content/test/tabs/browser_reload_deleted_file.js index 15d4ae5f7422..8b787ec927cc 100644 --- a/browser/base/content/test/tabs/browser_reload_deleted_file.js +++ b/browser/base/content/test/tabs/browser_reload_deleted_file.js @@ -1,9 +1,7 @@ /* -*- indent-tabs-mode: nil; js-indent-level: 2 -*- */ /* vim: set ft=javascript ts=2 et sw=2 tw=80: */ -const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const uuidGenerator = Services.uuid; const DUMMY_FILE = "dummy_page.html"; diff --git a/browser/components/attribution/test/browser/browser_AttributionCode_Mac_telemetry.js b/browser/components/attribution/test/browser/browser_AttributionCode_Mac_telemetry.js index bc5a87e585fd..7ae53236b90d 100644 --- a/browser/components/attribution/test/browser/browser_AttributionCode_Mac_telemetry.js +++ b/browser/components/attribution/test/browser/browser_AttributionCode_Mac_telemetry.js @@ -198,8 +198,7 @@ add_task(async function test_broken_referrer() { // application has quarantine data but nothing will be pressent in the // quarantine database. This shouldn't happen in the wild. function generateQuarantineGUID() { - let str = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) + let str = Services.uuid .generateUUID() .toString() .toUpperCase(); diff --git a/browser/components/ion/content/ion.js b/browser/components/ion/content/ion.js index 769f82516a9e..ef230998a064 100644 --- a/browser/components/ion/content/ion.js +++ b/browser/components/ion/content/ion.js @@ -402,10 +402,7 @@ async function updateStudy(studyAddonId) { // equivalent to what we use for Telemetry IDs // https://searchfox.org/mozilla-central/rev/9193635dca8cfdcb68f114306194ffc860456044/toolkit/components/telemetry/app/TelemetryUtils.jsm#222 function generateUUID() { - let str = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID() - .toString(); + let str = Services.uuid.generateUUID().toString(); return str.substring(1, str.length - 1); } diff --git a/browser/components/preferences/tests/browser_advanced_update.js b/browser/components/preferences/tests/browser_advanced_update.js index b78242bfe443..dd277fbb90b0 100644 --- a/browser/components/preferences/tests/browser_advanced_update.js +++ b/browser/components/preferences/tests/browser_advanced_update.js @@ -5,9 +5,7 @@ const Cm = Components.manager; -const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const uuidGenerator = Services.uuid; const mockUpdateManager = { contractId: "@mozilla.org/updates/update-manager;1", diff --git a/browser/components/shell/test/browser_1119088.js b/browser/components/shell/test/browser_1119088.js index 492af305d3dd..f097699565b4 100644 --- a/browser/components/shell/test/browser_1119088.js +++ b/browser/components/shell/test/browser_1119088.js @@ -105,9 +105,7 @@ add_task(async function() { let dirSvc = Cc["@mozilla.org/file/directory_service;1"].getService( Ci.nsIDirectoryServiceProvider ); - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; let shellSvc = Cc["@mozilla.org/browser/shell-service;1"].getService( Ci.nsIShellService ); diff --git a/browser/modules/test/browser/browser_ProcessHangNotifications.js b/browser/modules/test/browser/browser_ProcessHangNotifications.js index fa276044acac..e2102b84bbd6 100644 --- a/browser/modules/test/browser/browser_ProcessHangNotifications.js +++ b/browser/modules/test/browser/browser_ProcessHangNotifications.js @@ -109,9 +109,7 @@ let buttonCount = AppConstants.MOZ_DEV_EDITION ? 2 : 1; add_task(async function setup() { // Create a fake WebExtensionPolicy that we can use for // the add-on hang notification. - const uuidGen = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + const uuidGen = Services.uuid; const uuid = uuidGen.generateUUID().number.slice(1, -1); let policy = new WebExtensionPolicy({ name: "Scapegoat", diff --git a/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js b/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js index a614c9c7dc94..c3a613b04a21 100644 --- a/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js +++ b/browser/modules/test/browser/browser_UnsubmittedCrashHandler.js @@ -106,9 +106,7 @@ function createPendingCrashReports(howMany, accessDate) { return Promise.all(promises); }; - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; // Some annotations are always present in the .extra file and CrashSubmit.jsm // expects there to be a ServerURL entry, so we'll add them here. let extraFileContents = JSON.stringify({ diff --git a/chrome/test/unit/test_data_protocol_registration.js b/chrome/test/unit/test_data_protocol_registration.js index e6dfcf355c4b..3682fc4f4302 100644 --- a/chrome/test/unit/test_data_protocol_registration.js +++ b/chrome/test/unit/test_data_protocol_registration.js @@ -8,9 +8,7 @@ var manifests = [do_get_file("data/test_data_protocol_registration.manifest")]; registerManifests(manifests); function run_test() { - const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + const uuidGenerator = Services.uuid; let newAppInfo = ChromeUtils.import( "resource://testing-common/AppInfo.jsm", diff --git a/chrome/test/unit/test_no_remote_registration.js b/chrome/test/unit/test_no_remote_registration.js index 39c472ae876e..7bb0f1a77d21 100644 --- a/chrome/test/unit/test_no_remote_registration.js +++ b/chrome/test/unit/test_no_remote_registration.js @@ -66,9 +66,7 @@ function run_test() { platformVersion: "1.9", }); - const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + const uuidGenerator = Services.uuid; let XULAppInfoFactory = { // These two are used when we register all our factories (and unregister) diff --git a/devtools/shared/generate-uuid.js b/devtools/shared/generate-uuid.js index f8e6e1fb2a49..cbb38f652f9d 100644 --- a/devtools/shared/generate-uuid.js +++ b/devtools/shared/generate-uuid.js @@ -5,9 +5,7 @@ "use strict"; const { Cc, Ci } = require("chrome"); -const { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const { generateUUID } = Services.uuid; /** * Returns a new `uuid`. diff --git a/devtools/shared/tests/xpcshell/test_console_filtering.js b/devtools/shared/tests/xpcshell/test_console_filtering.js index 7b5bbdf44b89..6f5a12f1ffdf 100644 --- a/devtools/shared/tests/xpcshell/test_console_filtering.js +++ b/devtools/shared/tests/xpcshell/test_console_filtering.js @@ -34,9 +34,7 @@ registerCleanupFunction(() => { }); function createFakeAddonWindow({ addonId } = {}) { - const uuidGen = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + const uuidGen = Services.uuid; const uuid = uuidGen.generateUUID().number.slice(1, -1); if (policy) { diff --git a/dom/push/PushServiceWebSocket.jsm b/dom/push/PushServiceWebSocket.jsm index 4f942aaca9c6..965d370adfef 100644 --- a/dom/push/PushServiceWebSocket.jsm +++ b/dom/push/PushServiceWebSocket.jsm @@ -867,9 +867,7 @@ var PushServiceWebSocket = { }, _generateID() { - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; // generateUUID() gives a UUID surrounded by {...}, slice them off. return uuidGenerator .generateUUID() diff --git a/dom/tests/browser/browser_ConsoleAPI_originAttributes.js b/dom/tests/browser/browser_ConsoleAPI_originAttributes.js index ecacfbb0abf4..72a82380a241 100644 --- a/dom/tests/browser/browser_ConsoleAPI_originAttributes.js +++ b/dom/tests/browser/browser_ConsoleAPI_originAttributes.js @@ -64,9 +64,7 @@ function test() { waitForExplicitFinish(); - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; let uuid = uuidGenerator.generateUUID().number; uuid = uuid.slice(1, -1); // Strip { and } off the UUID. diff --git a/extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js b/extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js index 4013e0a5e236..e60d66219dcf 100644 --- a/extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js +++ b/extensions/permissions/test/unit/test_permmanager_migrate_4-7_no_history.js @@ -18,9 +18,7 @@ var factory = { QueryInterface: ChromeUtils.generateQI(["nsIFactory"]), }; -var newClassID = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID(); +var newClassID = Services.uuid.generateUUID(); var registrar = Components.manager.QueryInterface(Ci.nsIComponentRegistrar); var oldClassID = registrar.contractIDToCID(CONTRACT_ID); diff --git a/netwerk/dns/mdns/libmdns/DNSServiceDiscovery.jsm b/netwerk/dns/mdns/libmdns/DNSServiceDiscovery.jsm index bf153ea1bdc8..ed6ab90abba8 100644 --- a/netwerk/dns/mdns/libmdns/DNSServiceDiscovery.jsm +++ b/netwerk/dns/mdns/libmdns/DNSServiceDiscovery.jsm @@ -23,9 +23,7 @@ function log(aMsg) { } function generateUuid() { - var uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + var uuidGenerator = Services.uuid; return uuidGenerator.generateUUID().toString(); } diff --git a/security/sandbox/test/browser_content_sandbox_utils.js b/security/sandbox/test/browser_content_sandbox_utils.js index e045d2c0f269..38deb23eca70 100644 --- a/security/sandbox/test/browser_content_sandbox_utils.js +++ b/security/sandbox/test/browser_content_sandbox_utils.js @@ -2,9 +2,7 @@ * http://creativecommons.org/publicdomain/zero/1.0/ */ "use strict"; -const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const uuidGenerator = Services.uuid; const environment = Cc["@mozilla.org/process/environment;1"].getService( Ci.nsIEnvironment ); diff --git a/services/common/utils.js b/services/common/utils.js index 45723eb7de4f..f7494ca8faf7 100644 --- a/services/common/utils.js +++ b/services/common/utils.js @@ -513,10 +513,7 @@ var CommonUtils = { * @return string A hex-formatted UUID string. */ generateUUID: function generateUUID() { - let uuid = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID() - .toString(); + let uuid = Services.uuid.generateUUID().toString(); return uuid.substring(1, uuid.length - 1); }, diff --git a/services/fxaccounts/FxAccountsTelemetry.jsm b/services/fxaccounts/FxAccountsTelemetry.jsm index aade054edaf5..2fce6ea60941 100644 --- a/services/fxaccounts/FxAccountsTelemetry.jsm +++ b/services/fxaccounts/FxAccountsTelemetry.jsm @@ -48,8 +48,7 @@ class FxAccountsTelemetry { } generateUUID() { - return Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) + return Services.uuid .generateUUID() .toString() .slice(1, -1); diff --git a/testing/mochitest/BrowserTestUtils/content/content-about-page-utils.js b/testing/mochitest/BrowserTestUtils/content/content-about-page-utils.js index e35f7efd1ddd..f056cd9b1c74 100644 --- a/testing/mochitest/BrowserTestUtils/content/content-about-page-utils.js +++ b/testing/mochitest/BrowserTestUtils/content/content-about-page-utils.js @@ -6,9 +6,7 @@ var Cm = Components.manager; const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); -const { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const { generateUUID } = Services.uuid; function AboutPage(aboutHost, chromeURL, uriFlags) { this.chromeURL = chromeURL; diff --git a/testing/specialpowers/content/AppTestDelegateParent.jsm b/testing/specialpowers/content/AppTestDelegateParent.jsm index 563367cd55c0..7ce14f07c4a8 100644 --- a/testing/specialpowers/content/AppTestDelegateParent.jsm +++ b/testing/specialpowers/content/AppTestDelegateParent.jsm @@ -15,9 +15,7 @@ XPCOMUtils.defineLazyModuleGetters(this, { AppUiTestDelegate: "resource://testing-common/AppUiTestDelegate.jsm", }); -const UUIDGen = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const UUIDGen = Services.uuid; class AppTestDelegateParent extends JSWindowActorParent { constructor() { diff --git a/testing/specialpowers/content/MockColorPicker.jsm b/testing/specialpowers/content/MockColorPicker.jsm index b091cf6eb2e8..aa9c54e74c2c 100644 --- a/testing/specialpowers/content/MockColorPicker.jsm +++ b/testing/specialpowers/content/MockColorPicker.jsm @@ -18,9 +18,7 @@ Cu.crashIfNotInAutomation(); var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar); var oldClassID = ""; -var newClassID = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID(); +var newClassID = Services.uuid.generateUUID(); var newFactory = function(window) { return { createInstance(aOuter, aIID) { diff --git a/testing/specialpowers/content/MockFilePicker.jsm b/testing/specialpowers/content/MockFilePicker.jsm index 2b331cf6c521..5060a4fc8639 100644 --- a/testing/specialpowers/content/MockFilePicker.jsm +++ b/testing/specialpowers/content/MockFilePicker.jsm @@ -28,9 +28,7 @@ if (__URI__.includes("specialpowers")) { var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar); var oldClassID; -var newClassID = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID(); +var newClassID = Services.uuid.generateUUID(); var newFactory = function(window) { return { createInstance(aOuter, aIID) { diff --git a/testing/specialpowers/content/MockPermissionPrompt.jsm b/testing/specialpowers/content/MockPermissionPrompt.jsm index 099c4c37c5b5..43e861d262e4 100644 --- a/testing/specialpowers/content/MockPermissionPrompt.jsm +++ b/testing/specialpowers/content/MockPermissionPrompt.jsm @@ -12,9 +12,7 @@ const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); var registrar = Cm.QueryInterface(Ci.nsIComponentRegistrar); var oldClassID, oldFactory; -var newClassID = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID(); +var newClassID = Services.uuid.generateUUID(); var newFactory = { createInstance(aOuter, aIID) { if (aOuter) { diff --git a/testing/specialpowers/content/SpecialPowersChild.jsm b/testing/specialpowers/content/SpecialPowersChild.jsm index 650e0995ea7c..0d9f120486b6 100644 --- a/testing/specialpowers/content/SpecialPowersChild.jsm +++ b/testing/specialpowers/content/SpecialPowersChild.jsm @@ -594,9 +594,7 @@ class SpecialPowersChild extends JSWindowActorChild { loadChromeScript(urlOrFunction, sandboxOptions) { // Create a unique id for this chrome script - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; let id = uuidGenerator.generateUUID().toString(); // Tells chrome code to evaluate this chrome script @@ -1784,9 +1782,7 @@ class SpecialPowersChild extends JSWindowActorChild { if (cid) { componentRegistrar.unregisterFactory(currentCID, currentFactory); } else { - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; cid = uuidGenerator.generateUUID(); } diff --git a/toolkit/components/antitracking/test/browser/browser_staticPartition_CORS_preflight.js b/toolkit/components/antitracking/test/browser/browser_staticPartition_CORS_preflight.js index b6b46be03d21..2bc898107cbd 100644 --- a/toolkit/components/antitracking/test/browser/browser_staticPartition_CORS_preflight.js +++ b/toolkit/components/antitracking/test/browser/browser_staticPartition_CORS_preflight.js @@ -12,9 +12,7 @@ const TEST_PREFLIGHT_PAGE = "http://example.net/browser/toolkit/components/antitracking/test/browser/browser_staticPartition_CORS_preflight.sjs"; add_task(async function() { - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; for (let networkIsolation of [true, false]) { for (let partitionPerSite of [true, false]) { diff --git a/toolkit/components/antitracking/test/browser/browser_staticPartition_saveAs.js b/toolkit/components/antitracking/test/browser/browser_staticPartition_saveAs.js index cceccc247ea7..d62bba9876eb 100644 --- a/toolkit/components/antitracking/test/browser/browser_staticPartition_saveAs.js +++ b/toolkit/components/antitracking/test/browser/browser_staticPartition_saveAs.js @@ -95,9 +95,7 @@ add_task(async function setup() { }); add_task(async function testContextMenuSaveImage() { - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; for (let networkIsolation of [true, false]) { for (let partitionPerSite of [true, false]) { @@ -192,9 +190,7 @@ add_task(async function testContextMenuSaveImage() { }); add_task(async function testContextMenuSaveVideo() { - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; for (let networkIsolation of [true, false]) { for (let partitionPerSite of [true, false]) { diff --git a/toolkit/components/autocomplete/tests/unit/head_autocomplete.js b/toolkit/components/autocomplete/tests/unit/head_autocomplete.js index 0989ff2788e0..fc63f2ce99e7 100644 --- a/toolkit/components/autocomplete/tests/unit/head_autocomplete.js +++ b/toolkit/components/autocomplete/tests/unit/head_autocomplete.js @@ -176,9 +176,7 @@ AutocompletePopupBase.prototype = { */ function registerAutoCompleteSearch(aSearch) { var name = "@mozilla.org/autocomplete/search;1?name=" + aSearch.name; - var cid = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID(); + var cid = Services.uuid.generateUUID(); var desc = "Test AutoCompleteSearch"; var componentManager = Components.manager.QueryInterface( diff --git a/toolkit/components/autocomplete/tests/unit/test_378079.js b/toolkit/components/autocomplete/tests/unit/test_378079.js index bb240417e9a3..ca17b7fbdee4 100644 --- a/toolkit/components/autocomplete/tests/unit/test_378079.js +++ b/toolkit/components/autocomplete/tests/unit/test_378079.js @@ -162,9 +162,7 @@ AutoCompleteSearch.prototype = { function registerAutoCompleteSearch(aSearch) { var name = "@mozilla.org/autocomplete/search;1?name=" + aSearch.name; - var uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + var uuidGenerator = Services.uuid; var cid = uuidGenerator.generateUUID(); var desc = "Test AutoCompleteSearch"; diff --git a/toolkit/components/autocomplete/tests/unit/test_393191.js b/toolkit/components/autocomplete/tests/unit/test_393191.js index 47e5ded0d4c7..59f5de00cc3f 100644 --- a/toolkit/components/autocomplete/tests/unit/test_393191.js +++ b/toolkit/components/autocomplete/tests/unit/test_393191.js @@ -161,9 +161,7 @@ AutoCompleteSearch.prototype = { function registerAutoCompleteSearch(aSearch) { var name = "@mozilla.org/autocomplete/search;1?name=" + aSearch.name; - var uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + var uuidGenerator = Services.uuid; var cid = uuidGenerator.generateUUID(); var desc = "Test AutoCompleteSearch"; diff --git a/toolkit/components/autocomplete/tests/unit/test_440866.js b/toolkit/components/autocomplete/tests/unit/test_440866.js index 26ed8e9d11ea..aa03b032bb84 100644 --- a/toolkit/components/autocomplete/tests/unit/test_440866.js +++ b/toolkit/components/autocomplete/tests/unit/test_440866.js @@ -160,9 +160,7 @@ AutoCompleteSearch.prototype = { function registerAutoCompleteSearch(aSearch) { var name = "@mozilla.org/autocomplete/search;1?name=" + aSearch.name; - var uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + var uuidGenerator = Services.uuid; var cid = uuidGenerator.generateUUID(); var desc = "Test AutoCompleteSearch"; diff --git a/toolkit/components/autocomplete/tests/unit/test_autocomplete_multiple.js b/toolkit/components/autocomplete/tests/unit/test_autocomplete_multiple.js index 1b1cd04a8038..3e7284a8329f 100644 --- a/toolkit/components/autocomplete/tests/unit/test_autocomplete_multiple.js +++ b/toolkit/components/autocomplete/tests/unit/test_autocomplete_multiple.js @@ -164,9 +164,7 @@ AutoCompleteSearch.prototype = { function registerAutoCompleteSearch(aSearch) { var name = "@mozilla.org/autocomplete/search;1?name=" + aSearch.name; - var uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + var uuidGenerator = Services.uuid; var cid = uuidGenerator.generateUUID(); var desc = "Test AutoCompleteSearch"; diff --git a/toolkit/components/autocomplete/tests/unit/test_previousResult.js b/toolkit/components/autocomplete/tests/unit/test_previousResult.js index 4d5d62e4170e..3b2448b6321d 100644 --- a/toolkit/components/autocomplete/tests/unit/test_previousResult.js +++ b/toolkit/components/autocomplete/tests/unit/test_previousResult.js @@ -164,9 +164,7 @@ AutoCompleteSearch.prototype = { function registerAutoCompleteSearch(aSearch) { var name = "@mozilla.org/autocomplete/search;1?name=" + aSearch.name; - var uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + var uuidGenerator = Services.uuid; var cid = uuidGenerator.generateUUID(); var desc = "Test AutoCompleteSearch"; diff --git a/toolkit/components/autocomplete/tests/unit/test_stopSearch.js b/toolkit/components/autocomplete/tests/unit/test_stopSearch.js index 1211f03d660e..1487e0293c6a 100644 --- a/toolkit/components/autocomplete/tests/unit/test_stopSearch.js +++ b/toolkit/components/autocomplete/tests/unit/test_stopSearch.js @@ -83,9 +83,7 @@ AutoCompleteSearch.prototype = { */ function registerAutoCompleteSearch(aSearch) { let name = "@mozilla.org/autocomplete/search;1?name=" + aSearch.name; - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; let cid = uuidGenerator.generateUUID(); let desc = "Test AutoCompleteSearch"; let componentManager = Components.manager.QueryInterface( diff --git a/toolkit/components/backgroundtasks/tests/xpcshell/test_backgroundtask_deletes_profile.js b/toolkit/components/backgroundtasks/tests/xpcshell/test_backgroundtask_deletes_profile.js index b0649fd96f79..4dc6dfc6e698 100644 --- a/toolkit/components/backgroundtasks/tests/xpcshell/test_backgroundtask_deletes_profile.js +++ b/toolkit/components/backgroundtasks/tests/xpcshell/test_backgroundtask_deletes_profile.js @@ -5,10 +5,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ add_task(async function test_backgroundtask_deletes_profile() { - let sentinel = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID() - .toString(); + let sentinel = Services.uuid.generateUUID().toString(); sentinel = sentinel.substring(1, sentinel.length - 1); let stdoutLines = []; diff --git a/toolkit/components/backgroundtasks/tests/xpcshell/test_backgroundtask_unique_profile.js b/toolkit/components/backgroundtasks/tests/xpcshell/test_backgroundtask_unique_profile.js index 5c09bce8e458..edbf845b2a5b 100644 --- a/toolkit/components/backgroundtasks/tests/xpcshell/test_backgroundtask_unique_profile.js +++ b/toolkit/components/backgroundtasks/tests/xpcshell/test_backgroundtask_unique_profile.js @@ -8,10 +8,7 @@ // launched background task, etc. This is an easy way to ensure that tasks are running concurrently // without requiring concurrency primitives. add_task(async function test_backgroundtask_unique_profile() { - let sentinel = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID() - .toString(); + let sentinel = Services.uuid.generateUUID().toString(); sentinel = sentinel.substring(1, sentinel.length - 1); let count = 3; diff --git a/toolkit/components/cleardata/tests/browser/browser_preflight_cache.js b/toolkit/components/cleardata/tests/browser/browser_preflight_cache.js index b684d1505822..210a764d1116 100644 --- a/toolkit/components/cleardata/tests/browser/browser_preflight_cache.js +++ b/toolkit/components/cleardata/tests/browser/browser_preflight_cache.js @@ -7,9 +7,7 @@ const { SiteDataTestUtils } = ChromeUtils.import( "resource://testing-common/SiteDataTestUtils.jsm" ); -const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const uuidGenerator = Services.uuid; const ORIGIN_A = "http://example.net"; const ORIGIN_B = "http://example.org"; diff --git a/toolkit/components/contentprefs/ContentPrefServiceChild.jsm b/toolkit/components/contentprefs/ContentPrefServiceChild.jsm index edde557fcbf5..b34e9e7205e7 100644 --- a/toolkit/components/contentprefs/ContentPrefServiceChild.jsm +++ b/toolkit/components/contentprefs/ContentPrefServiceChild.jsm @@ -60,10 +60,7 @@ class ContentPrefsChild extends JSProcessActorChild { } _getRandomId() { - return Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID() - .toString(); + return Services.uuid.generateUUID().toString(); } receiveMessage(msg) { diff --git a/toolkit/components/crashes/CrashManager.jsm b/toolkit/components/crashes/CrashManager.jsm index 3df3c9f9f9f7..f9876df2c342 100644 --- a/toolkit/components/crashes/CrashManager.jsm +++ b/toolkit/components/crashes/CrashManager.jsm @@ -529,8 +529,7 @@ CrashManager.prototype = Object.freeze({ generateSubmissionID() { return ( "sub-" + - Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) + Services.uuid .generateUUID() .toString() .slice(1, -1) diff --git a/toolkit/components/crashes/CrashManagerTest.jsm b/toolkit/components/crashes/CrashManagerTest.jsm index 1ed349ae8c9c..4b81bc6b786c 100644 --- a/toolkit/components/crashes/CrashManagerTest.jsm +++ b/toolkit/components/crashes/CrashManagerTest.jsm @@ -54,10 +54,7 @@ TestingCrashManager.prototype = { __proto__: CrashManager.prototype, createDummyDump(submitted = false, date = new Date(), hr = false) { - let uuid = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID() - .toString(); + let uuid = Services.uuid.generateUUID().toString(); uuid = uuid.substring(1, uuid.length - 1); let path; diff --git a/toolkit/components/extensions/ExtensionStorageSyncKinto.jsm b/toolkit/components/extensions/ExtensionStorageSyncKinto.jsm index 71bdb34c86bb..3076fab0f70d 100644 --- a/toolkit/components/extensions/ExtensionStorageSyncKinto.jsm +++ b/toolkit/components/extensions/ExtensionStorageSyncKinto.jsm @@ -497,9 +497,7 @@ class CryptoCollection { // This is a new keyring. Invent an ID for this record. If this // changes, it means a client replaced the keyring, so we need to // reupload everything. - const uuidgen = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + const uuidgen = Services.uuid; const uuid = uuidgen.generateUUID().toString(); data = { uuid, id: STORAGE_SYNC_CRYPTO_KEYRING_RECORD_ID }; } diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_networkStatus.js b/toolkit/components/extensions/test/xpcshell/test_ext_networkStatus.js index 758bf48d0b5d..a5470c5a8887 100644 --- a/toolkit/components/extensions/test/xpcshell/test_ext_networkStatus.js +++ b/toolkit/components/extensions/test/xpcshell/test_ext_networkStatus.js @@ -2,9 +2,7 @@ const Cm = Components.manager; -const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const uuidGenerator = Services.uuid; var mockNetworkStatusService = { contractId: "@mozilla.org/network/network-link-service;1", diff --git a/toolkit/components/extensions/test/xpcshell/test_ext_storage_sync_kinto.js b/toolkit/components/extensions/test/xpcshell/test_ext_storage_sync_kinto.js index db7091db8d41..9f95024988cb 100644 --- a/toolkit/components/extensions/test/xpcshell/test_ext_storage_sync_kinto.js +++ b/toolkit/components/extensions/test/xpcshell/test_ext_storage_sync_kinto.js @@ -649,9 +649,7 @@ const loggedInUser = { }; function uuid() { - const uuidgen = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + const uuidgen = Services.uuid; return uuidgen.generateUUID().toString(); } diff --git a/toolkit/components/prompts/src/Prompter.jsm b/toolkit/components/prompts/src/Prompter.jsm index 9e2662f34544..4a3b74321eca 100644 --- a/toolkit/components/prompts/src/Prompter.jsm +++ b/toolkit/components/prompts/src/Prompter.jsm @@ -1166,12 +1166,7 @@ class ModalPrompter { // It is technically possible for multiple prompts to be sent from a single // BrowsingContext. See bug 1266353. We use a randomly generated UUID to // differentiate between the different prompts. - let id = - "id" + - Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID() - .toString(); + let id = "id" + Services.uuid.generateUUID().toString(); args._remoteId = id; diff --git a/toolkit/components/taskscheduler/tests/xpcshell/test_TaskSchedulerMacOSImpl.js b/toolkit/components/taskscheduler/tests/xpcshell/test_TaskSchedulerMacOSImpl.js index 2cc1a0e990e2..9586a6b99f9e 100644 --- a/toolkit/components/taskscheduler/tests/xpcshell/test_TaskSchedulerMacOSImpl.js +++ b/toolkit/components/taskscheduler/tests/xpcshell/test_TaskSchedulerMacOSImpl.js @@ -41,9 +41,7 @@ function getFirefoxExecutableFile() { return file; } -const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const uuidGenerator = Services.uuid; function randomName() { return ( diff --git a/toolkit/components/taskscheduler/tests/xpcshell/test_TaskSchedulerWinImpl.js b/toolkit/components/taskscheduler/tests/xpcshell/test_TaskSchedulerWinImpl.js index ef944580030b..7a36465ea836 100644 --- a/toolkit/components/taskscheduler/tests/xpcshell/test_TaskSchedulerWinImpl.js +++ b/toolkit/components/taskscheduler/tests/xpcshell/test_TaskSchedulerWinImpl.js @@ -24,9 +24,7 @@ const WinSvc = Cc["@mozilla.org/win-task-scheduler-service;1"].getService( Ci.nsIWinTaskSchedulerService ); -const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const uuidGenerator = Services.uuid; function randomName() { return ( diff --git a/toolkit/components/taskscheduler/tests/xpcshell/test_WinTaskSchedulerService.js b/toolkit/components/taskscheduler/tests/xpcshell/test_WinTaskSchedulerService.js index 5ffe018573e1..71ecdc0f77bc 100644 --- a/toolkit/components/taskscheduler/tests/xpcshell/test_WinTaskSchedulerService.js +++ b/toolkit/components/taskscheduler/tests/xpcshell/test_WinTaskSchedulerService.js @@ -9,9 +9,7 @@ const svc = Cc["@mozilla.org/win-task-scheduler-service;1"].getService( Ci.nsIWinTaskSchedulerService ); -const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const uuidGenerator = Services.uuid; function randomName() { return ( diff --git a/toolkit/components/telemetry/app/TelemetryUtils.jsm b/toolkit/components/telemetry/app/TelemetryUtils.jsm index a9a55ae464d6..9ad8b0a6991b 100644 --- a/toolkit/components/telemetry/app/TelemetryUtils.jsm +++ b/toolkit/components/telemetry/app/TelemetryUtils.jsm @@ -207,10 +207,7 @@ var TelemetryUtils = { }, generateUUID() { - let str = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID() - .toString(); + let str = Services.uuid.generateUUID().toString(); // strip {} return str.substring(1, str.length - 1); }, diff --git a/toolkit/components/telemetry/pings/TelemetrySession.jsm b/toolkit/components/telemetry/pings/TelemetrySession.jsm index 76d7b5ed6b38..8447ad3468fd 100644 --- a/toolkit/components/telemetry/pings/TelemetrySession.jsm +++ b/toolkit/components/telemetry/pings/TelemetrySession.jsm @@ -68,10 +68,7 @@ XPCOMUtils.defineLazyServiceGetters(this, { }); function generateUUID() { - let str = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID() - .toString(); + let str = Services.uuid.generateUUID().toString(); // strip {} return str.substring(1, str.length - 1); } diff --git a/toolkit/crashreporter/test/browser/head.js b/toolkit/crashreporter/test/browser/head.js index 55a30e02b950..d9ba22a1387d 100644 --- a/toolkit/crashreporter/test/browser/head.js +++ b/toolkit/crashreporter/test/browser/head.js @@ -11,9 +11,7 @@ function create_subdir(dir, subdirname) { } function generate_uuid() { - let uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGenerator = Services.uuid; let uuid = uuidGenerator.generateUUID().toString(); // ditch the {} return uuid.substring(1, uuid.length - 1); diff --git a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js index 439ecec5bd1f..886c88693248 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/head_addons.js +++ b/toolkit/mozapps/extensions/test/xpcshell/head_addons.js @@ -1199,9 +1199,7 @@ async function mockGfxBlocklistItemsFromDisk(path) { } async function mockGfxBlocklistItems(items) { - const { generateUUID } = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + const { generateUUID } = Services.uuid; let bsPass = ChromeUtils.import("resource://gre/modules/Blocklist.jsm", null); const client = RemoteSettings( Services.prefs.getCharPref("services.blocklist.gfx.collection"), diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js index fd711094a6eb..16091167e753 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_system_reset.js @@ -35,9 +35,7 @@ registerDirectory("XREAppFeat", distroDir); createAppInfo("xpcshell@tests.mozilla.org", "XPCShell", "0"); function makeUUID() { - let uuidGen = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator - ); + let uuidGen = Services.uuid; return uuidGen.generateUUID().toString(); } diff --git a/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js b/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js index 02155e11966e..b07e862fb8cd 100644 --- a/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js +++ b/toolkit/mozapps/extensions/test/xpcshell/test_update_webextensions.js @@ -6,9 +6,7 @@ Services.prefs.setBoolPref(PREF_EM_CHECK_UPDATE_SECURITY, false); var testserver = createHttpServer(); gPort = testserver.identity.primaryPort; -const uuidGenerator = Cc["@mozilla.org/uuid-generator;1"].getService( - Ci.nsIUUIDGenerator -); +const uuidGenerator = Services.uuid; const extensionsDir = gProfD.clone(); extensionsDir.append("extensions"); diff --git a/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js b/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js index d08d72b0486b..7d8ec70ad24d 100644 --- a/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js +++ b/uriloader/exthandler/tests/mochitest/HelperAppLauncherDialog_chromeScript.js @@ -7,9 +7,7 @@ const HELPERAPP_DIALOG_CID = Components.ID( Cc[HELPERAPP_DIALOG_CONTRACT].number ); -const FAKE_CID = Cc["@mozilla.org/uuid-generator;1"] - .getService(Ci.nsIUUIDGenerator) - .generateUUID(); +const FAKE_CID = Services.uuid.generateUUID(); /* eslint-env mozilla/frame-script */ function HelperAppLauncherDialog() {} HelperAppLauncherDialog.prototype = {