From 7ee7cdddd9a4141cb161bdc76aec69fa77132290 Mon Sep 17 00:00:00 2001 From: Danny Colin Date: Sun, 26 Mar 2023 18:03:42 +0000 Subject: [PATCH] Bug 1823715 - Convert toolkit/components/cookiebanners to ES modules r=Standard8 Differential Revision: https://phabricator.services.mozilla.com/D173367 --- .../test/performance/browser_startup_content.js | 2 +- .../performance/browser_startup_content_subframe.js | 2 +- ...CookieBannerChild.jsm => CookieBannerChild.sys.mjs} | 10 ++-------- ...ListService.jsm => CookieBannerListService.sys.mjs} | 10 ++-------- ...okieBannerParent.jsm => CookieBannerParent.sys.mjs} | 10 ++-------- toolkit/components/cookiebanners/components.conf | 2 +- toolkit/components/cookiebanners/moz.build | 6 +++--- toolkit/modules/ActorManagerParent.sys.mjs | 4 ++-- 8 files changed, 14 insertions(+), 32 deletions(-) rename toolkit/components/cookiebanners/{CookieBannerChild.jsm => CookieBannerChild.sys.mjs} (99%) rename toolkit/components/cookiebanners/{CookieBannerListService.jsm => CookieBannerListService.sys.mjs} (98%) rename toolkit/components/cookiebanners/{CookieBannerParent.jsm => CookieBannerParent.sys.mjs} (95%) diff --git a/browser/base/content/test/performance/browser_startup_content.js b/browser/base/content/test/performance/browser_startup_content.js index 861ba22dd7175..c512ff97b6ca2 100644 --- a/browser/base/content/test/performance/browser_startup_content.js +++ b/browser/base/content/test/performance/browser_startup_content.js @@ -81,7 +81,7 @@ const intermittently_loaded_scripts = { "resource://webcompat/AboutCompat.jsm", // Cookie banner handling. - "resource://gre/actors/CookieBannerChild.jsm", + "resource://gre/actors/CookieBannerChild.sys.mjs", "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", // Test related diff --git a/browser/base/content/test/performance/browser_startup_content_subframe.js b/browser/base/content/test/performance/browser_startup_content_subframe.js index ea4aba81b8567..ea2945bbcf2ea 100644 --- a/browser/base/content/test/performance/browser_startup_content_subframe.js +++ b/browser/base/content/test/performance/browser_startup_content_subframe.js @@ -65,7 +65,7 @@ const intermittently_loaded_scripts = { "resource://gre/modules/nsAsyncShutdown.sys.mjs", // Cookie banner handling. - "resource://gre/actors/CookieBannerChild.jsm", + "resource://gre/actors/CookieBannerChild.sys.mjs", "resource://gre/modules/PrivateBrowsingUtils.sys.mjs", // Test related diff --git a/toolkit/components/cookiebanners/CookieBannerChild.jsm b/toolkit/components/cookiebanners/CookieBannerChild.sys.mjs similarity index 99% rename from toolkit/components/cookiebanners/CookieBannerChild.jsm rename to toolkit/components/cookiebanners/CookieBannerChild.sys.mjs index 7f7ccb7b51cac..7ee81ec0d8da8 100644 --- a/toolkit/components/cookiebanners/CookieBannerChild.jsm +++ b/toolkit/components/cookiebanners/CookieBannerChild.sys.mjs @@ -3,13 +3,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - -var EXPORTED_SYMBOLS = ["CookieBannerChild"]; - -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; const lazy = {}; @@ -63,7 +57,7 @@ XPCOMUtils.defineLazyGetter(lazy, "logConsole", () => { }); }); -class CookieBannerChild extends JSWindowActorChild { +export class CookieBannerChild extends JSWindowActorChild { #clickRules; #originalBannerDisplay = null; #observerCleanUp; diff --git a/toolkit/components/cookiebanners/CookieBannerListService.jsm b/toolkit/components/cookiebanners/CookieBannerListService.sys.mjs similarity index 98% rename from toolkit/components/cookiebanners/CookieBannerListService.jsm rename to toolkit/components/cookiebanners/CookieBannerListService.sys.mjs index 70e9a33e23b43..abca9ab5b5d98 100644 --- a/toolkit/components/cookiebanners/CookieBannerListService.jsm +++ b/toolkit/components/cookiebanners/CookieBannerListService.sys.mjs @@ -2,14 +2,10 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - const lazy = {}; const { Services } = ChromeUtils.import("resource://gre/modules/Services.jsm"); -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; ChromeUtils.defineESModuleGetters(lazy, { JsonSchema: "resource://gre/modules/JsonSchema.sys.mjs", @@ -57,7 +53,7 @@ XPCOMUtils.defineLazyGetter(lazy, "CookieBannerRuleSchema", async () => { /** * See nsICookieBannerListService */ -class CookieBannerListService { +export class CookieBannerListService { classId = Components.ID("{1d8d9470-97d3-4885-a108-44a5c4fb36e2}"); QueryInterface = ChromeUtils.generateQI(["nsICookieBannerListService"]); @@ -359,5 +355,3 @@ class CookieBannerListService { ); } } - -var EXPORTED_SYMBOLS = ["CookieBannerListService"]; diff --git a/toolkit/components/cookiebanners/CookieBannerParent.jsm b/toolkit/components/cookiebanners/CookieBannerParent.sys.mjs similarity index 95% rename from toolkit/components/cookiebanners/CookieBannerParent.jsm rename to toolkit/components/cookiebanners/CookieBannerParent.sys.mjs index 066f17dc35d42..8c84180d0af4b 100644 --- a/toolkit/components/cookiebanners/CookieBannerParent.jsm +++ b/toolkit/components/cookiebanners/CookieBannerParent.sys.mjs @@ -2,13 +2,7 @@ * License, v. 2.0. If a copy of the MPL was not distributed with this * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ -"use strict"; - -var EXPORTED_SYMBOLS = ["CookieBannerParent"]; - -const { XPCOMUtils } = ChromeUtils.importESModule( - "resource://gre/modules/XPCOMUtils.sys.mjs" -); +import { XPCOMUtils } from "resource://gre/modules/XPCOMUtils.sys.mjs"; const lazy = {}; @@ -29,7 +23,7 @@ XPCOMUtils.defineLazyPreferenceGetter( Ci.nsICookieBannerService.MODE_DISABLED ); -class CookieBannerParent extends JSWindowActorParent { +export class CookieBannerParent extends JSWindowActorParent { /** * Get the browser associated with this window which is the top level embedder * element. Returns null if the top embedder isn't a browser. diff --git a/toolkit/components/cookiebanners/components.conf b/toolkit/components/cookiebanners/components.conf index 75454bcaf4cbe..adf85f8d2dd86 100644 --- a/toolkit/components/cookiebanners/components.conf +++ b/toolkit/components/cookiebanners/components.conf @@ -32,7 +32,7 @@ Classes = [ { 'cid': '{1d8d9470-97d3-4885-a108-44a5c4fb36e2}', 'contract_ids': ['@mozilla.org/cookie-banner-list-service;1'], - 'jsm': 'resource://gre/modules/CookieBannerListService.jsm', + 'esModule': 'resource://gre/modules/CookieBannerListService.sys.mjs', 'constructor': 'CookieBannerListService', 'processes': ProcessSelector.MAIN_PROCESS_ONLY, }, diff --git a/toolkit/components/cookiebanners/moz.build b/toolkit/components/cookiebanners/moz.build index 2ae10eb1a7e0c..537f6a294b0dd 100644 --- a/toolkit/components/cookiebanners/moz.build +++ b/toolkit/components/cookiebanners/moz.build @@ -20,7 +20,7 @@ XPIDL_SOURCES += [ XPIDL_MODULE = "toolkit_cookiebanners" EXTRA_JS_MODULES += [ - "CookieBannerListService.jsm", + "CookieBannerListService.sys.mjs", ] XPCOM_MANIFESTS += [ @@ -45,8 +45,8 @@ UNIFIED_SOURCES += [ ] FINAL_TARGET_FILES.actors += [ - "CookieBannerChild.jsm", - "CookieBannerParent.jsm", + "CookieBannerChild.sys.mjs", + "CookieBannerParent.sys.mjs", ] include("/ipc/chromium/chromium-config.mozbuild") diff --git a/toolkit/modules/ActorManagerParent.sys.mjs b/toolkit/modules/ActorManagerParent.sys.mjs index 679390437bdf9..fe29117c81c83 100644 --- a/toolkit/modules/ActorManagerParent.sys.mjs +++ b/toolkit/modules/ActorManagerParent.sys.mjs @@ -218,10 +218,10 @@ let JSWINDOWACTORS = { CookieBanner: { parent: { - moduleURI: "resource://gre/actors/CookieBannerParent.jsm", + esModuleURI: "resource://gre/actors/CookieBannerParent.sys.mjs", }, child: { - moduleURI: "resource://gre/actors/CookieBannerChild.jsm", + esModuleURI: "resource://gre/actors/CookieBannerChild.sys.mjs", events: { DOMContentLoaded: {}, load: { capture: true },