Skip to content

Commit

Permalink
Bug 1823715 - Convert toolkit/components/cookiebanners to ES modules …
Browse files Browse the repository at this point in the history
…r=Standard8

Differential Revision: https://phabricator.services.mozilla.com/D173367
  • Loading branch information
dannycolin committed Mar 26, 2023
1 parent 474d136 commit 7ee7cdd
Show file tree
Hide file tree
Showing 8 changed files with 14 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand Down Expand Up @@ -63,7 +57,7 @@ XPCOMUtils.defineLazyGetter(lazy, "logConsole", () => {
});
});

class CookieBannerChild extends JSWindowActorChild {
export class CookieBannerChild extends JSWindowActorChild {
#clickRules;
#originalBannerDisplay = null;
#observerCleanUp;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down Expand Up @@ -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"]);

Expand Down Expand Up @@ -359,5 +355,3 @@ class CookieBannerListService {
);
}
}

var EXPORTED_SYMBOLS = ["CookieBannerListService"];
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {};

Expand All @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion toolkit/components/cookiebanners/components.conf
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
Expand Down
6 changes: 3 additions & 3 deletions toolkit/components/cookiebanners/moz.build
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ XPIDL_SOURCES += [
XPIDL_MODULE = "toolkit_cookiebanners"

EXTRA_JS_MODULES += [
"CookieBannerListService.jsm",
"CookieBannerListService.sys.mjs",
]

XPCOM_MANIFESTS += [
Expand All @@ -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")
Expand Down
4 changes: 2 additions & 2 deletions toolkit/modules/ActorManagerParent.sys.mjs
Original file line number Diff line number Diff line change
Expand Up @@ -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 },
Expand Down

0 comments on commit 7ee7cdd

Please sign in to comment.