Bug 1874276 - Convert PlacesFeed into an ESM. r=thecount,places-reviewers

Differential Revision: https://phabricator.services.mozilla.com/D199360
This commit is contained in:
Mike Conley 2024-01-26 00:29:59 +00:00
Родитель e20dbd646e
Коммит c6a25b888c
6 изменённых файлов: 21 добавлений и 24 удалений

Просмотреть файл

@ -739,7 +739,7 @@ module.exports = {
"browser/components/newtab/content-src/components/DiscoveryStreamComponents/TopSites/TopSites.jsx ",
"browser/components/newtab/content-src/components/TopSites/TopSiteForm.jsx ",
"browser/components/newtab/lib/CFRMessageProvider.sys.mjs ",
"browser/components/newtab/lib/PlacesFeed.jsm ",
"browser/components/newtab/lib/PlacesFeed.sys.mjs ",
"browser/components/originattributes/test/browser/browser_broadcastChannel.js",
"browser/components/originattributes/test/browser/browser_cache.js",
"browser/components/originattributes/test/browser/browser_favicon_firstParty.js",

Просмотреть файл

@ -134,9 +134,9 @@ module.exports = function (config) {
branches: 78,
},
/**
* PlacesFeed.jsm is tested via an xpcshell test
* PlacesFeed.sys.mjs is tested via an xpcshell test
*/
"lib/PlacesFeed.jsm": {
"lib/PlacesFeed.sys.mjs": {
statements: 7,
lines: 7,
functions: 8,

Просмотреть файл

@ -14,6 +14,7 @@ ChromeUtils.defineESModuleGetters(lazy, {
DefaultPrefs: "resource://activity-stream/lib/ActivityStreamPrefs.sys.mjs",
HighlightsFeed: "resource://activity-stream/lib/HighlightsFeed.sys.mjs",
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
PlacesFeed: "resource://activity-stream/lib/PlacesFeed.sys.mjs",
Region: "resource://gre/modules/Region.sys.mjs",
TelemetryFeed: "resource://activity-stream/lib/TelemetryFeed.sys.mjs",
});
@ -43,11 +44,6 @@ ChromeUtils.defineModuleGetter(
"RecommendationProvider",
"resource://activity-stream/lib/RecommendationProvider.jsm"
);
ChromeUtils.defineModuleGetter(
lazy,
"PlacesFeed",
"resource://activity-stream/lib/PlacesFeed.jsm"
);
ChromeUtils.defineModuleGetter(
lazy,
"PrefsFeed",

Просмотреть файл

@ -1,18 +1,24 @@
/* This Source Code Form is subject to the terms of the Mozilla Public
* 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 {
actionCreators: ac,
actionTypes: at,
actionUtils: au,
} = ChromeUtils.importESModule(
"resource://activity-stream/common/Actions.sys.mjs"
);
import {
actionCreators as ac,
actionTypes as at,
actionUtils as au,
} from "resource://activity-stream/common/Actions.sys.mjs";
const { shortURL } = ChromeUtils.import(
"resource://activity-stream/lib/ShortURL.jsm"
);
// We use importESModule here instead of static import so that
// the Karma test environment won't choke on this module. This
// is because the Karma test environment already stubs out
// AboutNewTab, and overrides importESModule to be a no-op (which
// can't be done for a static import statement).
// eslint-disable-next-line mozilla/use-static-import
const { AboutNewTab } = ChromeUtils.importESModule(
"resource:///modules/AboutNewTab.sys.mjs"
);
@ -133,7 +139,7 @@ class PlacesObserver {
}
}
class PlacesFeed {
export class PlacesFeed {
constructor() {
this.placesChangedTimer = null;
this.customDispatch = this.customDispatch.bind(this);
@ -562,5 +568,3 @@ class PlacesFeed {
// Exported for testing only
PlacesFeed.PlacesObserver = PlacesObserver;
const EXPORTED_SYMBOLS = ["PlacesFeed"];

Просмотреть файл

@ -8,7 +8,7 @@ import { DefaultPrefs } from "lib/ActivityStreamPrefs.sys.mjs";
import { NewTabInit } from "lib/NewTabInit.jsm";
import { SectionsFeed } from "lib/SectionsManager.jsm";
import { RecommendationProvider } from "lib/RecommendationProvider.jsm";
import { PlacesFeed } from "lib/PlacesFeed.jsm";
import { PlacesFeed } from "lib/PlacesFeed.sys.mjs";
import { PrefsFeed } from "lib/PrefsFeed.jsm";
import { SystemTickFeed } from "lib/SystemTickFeed.jsm";
import { TelemetryFeed } from "lib/TelemetryFeed.sys.mjs";

Просмотреть файл

@ -14,6 +14,7 @@ ChromeUtils.defineESModuleGetters(this, {
NimbusFeatures: "resource://nimbus/ExperimentAPI.sys.mjs",
PartnerLinkAttribution: "resource:///modules/PartnerLinkAttribution.sys.mjs",
pktApi: "chrome://pocket/content/pktApi.sys.mjs",
PlacesFeed: "resource://activity-stream/lib/PlacesFeed.sys.mjs",
PlacesUtils: "resource://gre/modules/PlacesUtils.sys.mjs",
PrivateBrowsingUtils: "resource://gre/modules/PrivateBrowsingUtils.sys.mjs",
SearchService: "resource://gre/modules/SearchService.sys.mjs",
@ -21,10 +22,6 @@ ChromeUtils.defineESModuleGetters(this, {
TestUtils: "resource://testing-common/TestUtils.sys.mjs",
});
const { PlacesFeed } = ChromeUtils.import(
"resource://activity-stream/lib/PlacesFeed.jsm"
);
const { PlacesObserver } = PlacesFeed;
const FAKE_BOOKMARK = {