From a813ee80ce3d84e521b9c23eeb561f8ce755c52c Mon Sep 17 00:00:00 2001 From: Ed Lee Date: Tue, 29 Jan 2019 08:12:21 -0800 Subject: [PATCH 1/2] Port Bug 1518426 - Add another domain to FilterAdult. r=Mardak (#4744) --- lib/FilterAdult.jsm | 1 + 1 file changed, 1 insertion(+) diff --git a/lib/FilterAdult.jsm b/lib/FilterAdult.jsm index b85ebda7a..e03dfd685 100644 --- a/lib/FilterAdult.jsm +++ b/lib/FilterAdult.jsm @@ -325,6 +325,7 @@ gAdultSet = new Set([ "3xw8+0/WU51Yz4TWIMK8mw==", "3y5Xk65ShGvWFbQxcZaQAQ==", "3yDD+xT8iRfUVdxcc7RxKw==", + "3yavzOJ1mM44pOSFLLszgA==", "4+htiqjEz9oq0YcI/ErBVg==", "40HzgVKYnqIb6NJhpSIF0A==", "40gCrW4YWi+2lkqMSPKBPg==", From 01a4d1659bfe76763250f6d6756b67ae3d4d66d2 Mon Sep 17 00:00:00 2001 From: Ed Lee Date: Tue, 29 Jan 2019 13:41:48 -0800 Subject: [PATCH 2/2] Port Bug 1514594: Part 3a - Change ChromeUtils.import to return an exports object; not pollute global. r=mccr8 (#4746) Update to eslint-plugin-mozilla@1.1.0, babel-plugin-jsm-to-commonjs@0.5.0 and babel-plugin-jsm-to-esmodules@0.6.0. Fix up eslint and general test failures to work with locally scoped imports. --- aboutNewTabService.js | 8 +-- common/PerfService.jsm | 10 ++-- common/Reducers.jsm | 4 +- karma.mc.config.js | 2 +- lib/ASRouter.jsm | 18 +++--- lib/ASRouterFeed.jsm | 4 +- lib/ASRouterPreferences.jsm | 2 +- lib/ASRouterTargeting.jsm | 4 +- lib/ASRouterTriggerListeners.jsm | 2 +- lib/AboutPreferences.jsm | 6 +- lib/ActivityStream.jsm | 38 ++++++------- lib/ActivityStreamMessageChannel.jsm | 6 +- lib/ActivityStreamPrefs.jsm | 4 +- lib/CFRPageActions.jsm | 6 +- lib/DiscoveryStreamFeed.jsm | 8 +-- lib/DownloadsManager.jsm | 6 +- lib/FaviconFeed.jsm | 6 +- lib/HighlightsFeed.jsm | 12 ++-- lib/ManualMigration.jsm | 4 +- lib/NaiveBayesTextTagger.jsm | 2 +- lib/NewTabInit.jsm | 2 +- lib/NmfTextTagger.jsm | 2 +- lib/OnboardingMessageProvider.jsm | 8 +-- lib/PersistentCache.jsm | 2 +- lib/PersonalityProvider.jsm | 14 ++--- lib/PlacesFeed.jsm | 4 +- lib/PrefsFeed.jsm | 8 +-- lib/RecipeExecutor.jsm | 2 +- lib/SearchShortcuts.jsm | 2 +- lib/SectionsManager.jsm | 8 +-- lib/ShortURL.jsm | 4 +- lib/SiteClassifier.jsm | 2 +- lib/SnippetsFeed.jsm | 4 +- lib/Store.jsm | 10 ++-- lib/SystemTickFeed.jsm | 2 +- lib/TelemetryFeed.jsm | 10 ++-- lib/TippyTopProvider.jsm | 2 +- lib/TopSitesFeed.jsm | 18 +++--- lib/TopStoriesFeed.jsm | 20 +++---- lib/UTEventReporting.jsm | 2 +- lib/UserDomainAffinityProvider.jsm | 2 +- package-lock.json | 56 +++++++++++++++---- package.json | 6 +- ping-centre/PingCentre.jsm | 4 +- .../browser_activity_stream_strings.js | 1 - test/browser/browser_asrouter_cfr.js | 6 +- test/browser/browser_asrouter_targeting.js | 4 +- .../browser_asrouter_trigger_listeners.js | 1 - test/browser/browser_enabled_newtabpage.js | 2 - test/browser/browser_getScreenshots.js | 2 - test/browser/browser_newtab_overrides.js | 3 - test/browser/browser_packaged_as_locales.js | 1 - test/unit/unit-entry.js | 7 +-- .../test_ASRouterTargeting_attribution.js | 6 +- test/xpcshell/test_AboutNewTabService.js | 7 +-- webpack.system-addon.config.js | 2 +- 56 files changed, 205 insertions(+), 183 deletions(-) diff --git a/aboutNewTabService.js b/aboutNewTabService.js index fae6c7f7a..6d5c4a0e8 100644 --- a/aboutNewTabService.js +++ b/aboutNewTabService.js @@ -6,10 +6,10 @@ "use strict"; -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); -ChromeUtils.import("resource://gre/modules/E10SUtils.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); +const {E10SUtils} = ChromeUtils.import("resource://gre/modules/E10SUtils.jsm"); ChromeUtils.defineModuleGetter(this, "AboutNewTab", "resource:///modules/AboutNewTab.jsm"); diff --git a/common/PerfService.jsm b/common/PerfService.jsm index 5bc3374a1..43f82db29 100644 --- a/common/PerfService.jsm +++ b/common/PerfService.jsm @@ -1,17 +1,19 @@ -/* globals Services */ "use strict"; -/* istanbul ignore if */ if (typeof ChromeUtils !== "undefined") { - ChromeUtils.import("resource://gre/modules/Services.jsm"); + // Use a var here instead of let outside to avoid creating a locally scoped + // variable that hides the global, which we modify for testing. + // eslint-disable-next-line no-var, vars-on-top + var {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); } let usablePerfObj; -/* istanbul ignore if */ /* istanbul ignore else */ +// eslint-disable-next-line block-scoped-var if (typeof Services !== "undefined") { // Borrow the high-resolution timer from the hidden window.... + // eslint-disable-next-line block-scoped-var usablePerfObj = Services.appShell.hiddenDOMWindow.performance; } else if (typeof performance !== "undefined") { // we must be running in content space diff --git a/common/Reducers.jsm b/common/Reducers.jsm index da66a374c..f10a732c0 100644 --- a/common/Reducers.jsm +++ b/common/Reducers.jsm @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {Dedupe} = ChromeUtils.import("resource://activity-stream/common/Dedupe.jsm", {}); +const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {Dedupe} = ChromeUtils.import("resource://activity-stream/common/Dedupe.jsm"); const TOP_SITES_DEFAULT_ROWS = 1; const TOP_SITES_MAX_SITES_PER_ROW = 8; diff --git a/karma.mc.config.js b/karma.mc.config.js index 181ea546b..6ca1b48fd 100644 --- a/karma.mc.config.js +++ b/karma.mc.config.js @@ -91,7 +91,7 @@ module.exports = function(config) { options: { plugins: [ // Converts .jsm files into common-js modules - ["jsm-to-commonjs", {basePath: PATHS.resourcePathRegEx, replace: true}], // require("babel-plugin-jsm-to-commonjs") + ["jsm-to-commonjs", {basePath: PATHS.resourcePathRegEx, removeOtherImports: true, replace: true}], // require("babel-plugin-jsm-to-commonjs") ["transform-async-to-module-method", {module: "co-task", method: "async"}], // require("babel-plugin-transform-async-to-module-method") "transform-es2015-modules-commonjs", // require("babel-plugin-transform-es2015-modules-commonjs") ["transform-object-rest-spread", {"useBuiltIns": true}], // require("babel-plugin-transform-object-rest-spread") diff --git a/lib/ASRouter.jsm b/lib/ASRouter.jsm index 6096cd8f5..28ac2b940 100644 --- a/lib/ASRouter.jsm +++ b/lib/ASRouter.jsm @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]); XPCOMUtils.defineLazyModuleGetters(this, { AddonManager: "resource://gre/modules/AddonManager.jsm", @@ -13,12 +13,12 @@ XPCOMUtils.defineLazyModuleGetters(this, { AppConstants: "resource://gre/modules/AppConstants.jsm", OS: "resource://gre/modules/osfile.jsm", }); -const {ASRouterActions: ra, actionTypes: at, actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {CFRMessageProvider} = ChromeUtils.import("resource://activity-stream/lib/CFRMessageProvider.jsm", {}); -const {OnboardingMessageProvider} = ChromeUtils.import("resource://activity-stream/lib/OnboardingMessageProvider.jsm", {}); -const {SnippetsTestMessageProvider} = ChromeUtils.import("resource://activity-stream/lib/SnippetsTestMessageProvider.jsm", {}); -const {RemoteSettings} = ChromeUtils.import("resource://services-settings/remote-settings.js", {}); -const {CFRPageActions} = ChromeUtils.import("resource://activity-stream/lib/CFRPageActions.jsm", {}); +const {ASRouterActions: ra, actionTypes: at, actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {CFRMessageProvider} = ChromeUtils.import("resource://activity-stream/lib/CFRMessageProvider.jsm"); +const {OnboardingMessageProvider} = ChromeUtils.import("resource://activity-stream/lib/OnboardingMessageProvider.jsm"); +const {SnippetsTestMessageProvider} = ChromeUtils.import("resource://activity-stream/lib/SnippetsTestMessageProvider.jsm"); +const {RemoteSettings} = ChromeUtils.import("resource://services-settings/remote-settings.js"); +const {CFRPageActions} = ChromeUtils.import("resource://activity-stream/lib/CFRPageActions.jsm"); ChromeUtils.defineModuleGetter(this, "ASRouterPreferences", "resource://activity-stream/lib/ASRouterPreferences.jsm"); @@ -28,7 +28,7 @@ ChromeUtils.defineModuleGetter(this, "QueryCache", "resource://activity-stream/lib/ASRouterTargeting.jsm"); ChromeUtils.defineModuleGetter(this, "ASRouterTriggerListeners", "resource://activity-stream/lib/ASRouterTriggerListeners.jsm"); -ChromeUtils.import("resource:///modules/AttributionCode.jsm"); +const {AttributionCode} = ChromeUtils.import("resource:///modules/AttributionCode.jsm"); const INCOMING_MESSAGE_NAME = "ASRouter:child-to-parent"; const OUTGOING_MESSAGE_NAME = "ASRouter:parent-to-child"; diff --git a/lib/ASRouterFeed.jsm b/lib/ASRouterFeed.jsm index 425aaca06..2da014a2f 100644 --- a/lib/ASRouterFeed.jsm +++ b/lib/ASRouterFeed.jsm @@ -1,5 +1,5 @@ -const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {ASRouter} = ChromeUtils.import("resource://activity-stream/lib/ASRouter.jsm", {}); +const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {ASRouter} = ChromeUtils.import("resource://activity-stream/lib/ASRouter.jsm"); /** * @class ASRouterFeed - Connects ASRouter singleton (see above) to Activity Stream's diff --git a/lib/ASRouterPreferences.jsm b/lib/ASRouterPreferences.jsm index fa09b6735..b0b7e1805 100644 --- a/lib/ASRouterPreferences.jsm +++ b/lib/ASRouterPreferences.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); const PROVIDER_PREF_BRANCH = "browser.newtabpage.activity-stream.asrouter.providers."; const DEVTOOLS_PREF = "browser.newtabpage.activity-stream.asrouter.devtoolsEnabled"; diff --git a/lib/ASRouterTargeting.jsm b/lib/ASRouterTargeting.jsm index 3669681a6..7d8f6b19c 100644 --- a/lib/ASRouterTargeting.jsm +++ b/lib/ASRouterTargeting.jsm @@ -1,5 +1,5 @@ -ChromeUtils.import("resource://gre/modules/components-utils/FilterExpressions.jsm"); -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {FilterExpressions} = ChromeUtils.import("resource://gre/modules/components-utils/FilterExpressions.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.defineModuleGetter(this, "ASRouterPreferences", "resource://activity-stream/lib/ASRouterPreferences.jsm"); diff --git a/lib/ASRouterTriggerListeners.jsm b/lib/ASRouterTriggerListeners.jsm index dc0e6b6ee..83005eb24 100644 --- a/lib/ASRouterTriggerListeners.jsm +++ b/lib/ASRouterTriggerListeners.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); diff --git a/lib/AboutPreferences.jsm b/lib/AboutPreferences.jsm index 755d6a847..9241ada69 100644 --- a/lib/AboutPreferences.jsm +++ b/lib/AboutPreferences.jsm @@ -3,10 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.defineModuleGetter(this, "PluralForm", "resource://gre/modules/PluralForm.jsm"); -const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); +const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]); diff --git a/lib/ActivityStream.jsm b/lib/ActivityStream.jsm index ace07289d..3a7e2b8ab 100644 --- a/lib/ActivityStream.jsm +++ b/lib/ActivityStream.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.defineModuleGetter(this, "AppConstants", "resource://gre/modules/AppConstants.jsm"); @@ -12,24 +12,24 @@ ChromeUtils.defineModuleGetter(this, "UpdateUtils", // NB: Eagerly load modules that will be loaded/constructed/initialized in the // common case to avoid the overhead of wrapping and detecting lazy loading. -const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {AboutPreferences} = ChromeUtils.import("resource://activity-stream/lib/AboutPreferences.jsm", {}); -const {DefaultPrefs} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm", {}); -const {ManualMigration} = ChromeUtils.import("resource://activity-stream/lib/ManualMigration.jsm", {}); -const {NewTabInit} = ChromeUtils.import("resource://activity-stream/lib/NewTabInit.jsm", {}); -const {SectionsFeed} = ChromeUtils.import("resource://activity-stream/lib/SectionsManager.jsm", {}); -const {PlacesFeed} = ChromeUtils.import("resource://activity-stream/lib/PlacesFeed.jsm", {}); -const {PrefsFeed} = ChromeUtils.import("resource://activity-stream/lib/PrefsFeed.jsm", {}); -const {Store} = ChromeUtils.import("resource://activity-stream/lib/Store.jsm", {}); -const {SnippetsFeed} = ChromeUtils.import("resource://activity-stream/lib/SnippetsFeed.jsm", {}); -const {SystemTickFeed} = ChromeUtils.import("resource://activity-stream/lib/SystemTickFeed.jsm", {}); -const {TelemetryFeed} = ChromeUtils.import("resource://activity-stream/lib/TelemetryFeed.jsm", {}); -const {FaviconFeed} = ChromeUtils.import("resource://activity-stream/lib/FaviconFeed.jsm", {}); -const {TopSitesFeed} = ChromeUtils.import("resource://activity-stream/lib/TopSitesFeed.jsm", {}); -const {TopStoriesFeed} = ChromeUtils.import("resource://activity-stream/lib/TopStoriesFeed.jsm", {}); -const {HighlightsFeed} = ChromeUtils.import("resource://activity-stream/lib/HighlightsFeed.jsm", {}); -const {ASRouterFeed} = ChromeUtils.import("resource://activity-stream/lib/ASRouterFeed.jsm", {}); -const {DiscoveryStreamFeed} = ChromeUtils.import("resource://activity-stream/lib/DiscoveryStreamFeed.jsm", {}); +const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {AboutPreferences} = ChromeUtils.import("resource://activity-stream/lib/AboutPreferences.jsm"); +const {DefaultPrefs} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm"); +const {ManualMigration} = ChromeUtils.import("resource://activity-stream/lib/ManualMigration.jsm"); +const {NewTabInit} = ChromeUtils.import("resource://activity-stream/lib/NewTabInit.jsm"); +const {SectionsFeed} = ChromeUtils.import("resource://activity-stream/lib/SectionsManager.jsm"); +const {PlacesFeed} = ChromeUtils.import("resource://activity-stream/lib/PlacesFeed.jsm"); +const {PrefsFeed} = ChromeUtils.import("resource://activity-stream/lib/PrefsFeed.jsm"); +const {Store} = ChromeUtils.import("resource://activity-stream/lib/Store.jsm"); +const {SnippetsFeed} = ChromeUtils.import("resource://activity-stream/lib/SnippetsFeed.jsm"); +const {SystemTickFeed} = ChromeUtils.import("resource://activity-stream/lib/SystemTickFeed.jsm"); +const {TelemetryFeed} = ChromeUtils.import("resource://activity-stream/lib/TelemetryFeed.jsm"); +const {FaviconFeed} = ChromeUtils.import("resource://activity-stream/lib/FaviconFeed.jsm"); +const {TopSitesFeed} = ChromeUtils.import("resource://activity-stream/lib/TopSitesFeed.jsm"); +const {TopStoriesFeed} = ChromeUtils.import("resource://activity-stream/lib/TopStoriesFeed.jsm"); +const {HighlightsFeed} = ChromeUtils.import("resource://activity-stream/lib/HighlightsFeed.jsm"); +const {ASRouterFeed} = ChromeUtils.import("resource://activity-stream/lib/ASRouterFeed.jsm"); +const {DiscoveryStreamFeed} = ChromeUtils.import("resource://activity-stream/lib/DiscoveryStreamFeed.jsm"); const DEFAULT_SITES = new Map([ // This first item is the global list fallback for any unexpected geos diff --git a/lib/ActivityStreamMessageChannel.jsm b/lib/ActivityStreamMessageChannel.jsm index df93fe160..c7a40603d 100644 --- a/lib/ActivityStreamMessageChannel.jsm +++ b/lib/ActivityStreamMessageChannel.jsm @@ -4,11 +4,11 @@ "use strict"; -ChromeUtils.import("resource:///modules/AboutNewTab.jsm"); +const {AboutNewTab} = ChromeUtils.import("resource:///modules/AboutNewTab.jsm"); /* globals RemotePages */ // Remove when updating eslint-plugin-mozilla 0.14.0+ -ChromeUtils.import("resource://gre/modules/remotepagemanager/RemotePageManagerParent.jsm"); +const {RemotePages} = ChromeUtils.import("resource://gre/modules/remotepagemanager/RemotePageManagerParent.jsm"); -const {actionCreators: ac, actionTypes: at, actionUtils: au} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); +const {actionCreators: ac, actionTypes: at, actionUtils: au} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); const ABOUT_NEW_TAB_URL = "about:newtab"; const ABOUT_HOME_URL = "about:home"; diff --git a/lib/ActivityStreamPrefs.jsm b/lib/ActivityStreamPrefs.jsm index 744bd97ac..539d0581f 100644 --- a/lib/ActivityStreamPrefs.jsm +++ b/lib/ActivityStreamPrefs.jsm @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); -ChromeUtils.import("resource://gre/modules/Preferences.jsm"); +const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); +const {Preferences} = ChromeUtils.import("resource://gre/modules/Preferences.jsm"); const ACTIVITY_STREAM_PREF_BRANCH = "browser.newtabpage.activity-stream."; diff --git a/lib/CFRPageActions.jsm b/lib/CFRPageActions.jsm index a6cd63e39..ef0b8e6e5 100644 --- a/lib/CFRPageActions.jsm +++ b/lib/CFRPageActions.jsm @@ -3,9 +3,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -ChromeUtils.import("resource://gre/modules/Localization.jsm"); -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Localization} = ChromeUtils.import("resource://gre/modules/Localization.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]); ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils", diff --git a/lib/DiscoveryStreamFeed.jsm b/lib/DiscoveryStreamFeed.jsm index 2cf57c27c..e65cff718 100644 --- a/lib/DiscoveryStreamFeed.jsm +++ b/lib/DiscoveryStreamFeed.jsm @@ -3,12 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]); -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); -const {actionTypes: at, actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {PersistentCache} = ChromeUtils.import("resource://activity-stream/lib/PersistentCache.jsm", {}); +const {actionTypes: at, actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {PersistentCache} = ChromeUtils.import("resource://activity-stream/lib/PersistentCache.jsm"); const CACHE_KEY = "discovery_stream"; const LAYOUT_UPDATE_TIME = 30 * 60 * 1000; // 30 minutes diff --git a/lib/DownloadsManager.jsm b/lib/DownloadsManager.jsm index 90443698f..7a273c8e6 100644 --- a/lib/DownloadsManager.jsm +++ b/lib/DownloadsManager.jsm @@ -1,8 +1,8 @@ -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyGlobalGetters(this, ["URL"]); -const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); +const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); XPCOMUtils.defineLazyModuleGetters(this, { DownloadsCommon: "resource:///modules/DownloadsCommon.jsm", diff --git a/lib/FaviconFeed.jsm b/lib/FaviconFeed.jsm index caf38e710..f91c5dcb1 100644 --- a/lib/FaviconFeed.jsm +++ b/lib/FaviconFeed.jsm @@ -3,9 +3,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {getDomain} = ChromeUtils.import("resource://activity-stream/lib/TippyTopProvider.jsm", {}); -const {RemoteSettings} = ChromeUtils.import("resource://services-settings/remote-settings.js", {}); +const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {getDomain} = ChromeUtils.import("resource://activity-stream/lib/TippyTopProvider.jsm"); +const {RemoteSettings} = ChromeUtils.import("resource://services-settings/remote-settings.js"); ChromeUtils.defineModuleGetter(this, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm"); diff --git a/lib/HighlightsFeed.jsm b/lib/HighlightsFeed.jsm index 8eccf474a..884215f4f 100644 --- a/lib/HighlightsFeed.jsm +++ b/lib/HighlightsFeed.jsm @@ -3,14 +3,14 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); -const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); +const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); -const {shortURL} = ChromeUtils.import("resource://activity-stream/lib/ShortURL.jsm", {}); -const {SectionsManager} = ChromeUtils.import("resource://activity-stream/lib/SectionsManager.jsm", {}); -const {TOP_SITES_DEFAULT_ROWS, TOP_SITES_MAX_SITES_PER_ROW} = ChromeUtils.import("resource://activity-stream/common/Reducers.jsm", {}); -const {Dedupe} = ChromeUtils.import("resource://activity-stream/common/Dedupe.jsm", {}); +const {shortURL} = ChromeUtils.import("resource://activity-stream/lib/ShortURL.jsm"); +const {SectionsManager} = ChromeUtils.import("resource://activity-stream/lib/SectionsManager.jsm"); +const {TOP_SITES_DEFAULT_ROWS, TOP_SITES_MAX_SITES_PER_ROW} = ChromeUtils.import("resource://activity-stream/common/Reducers.jsm"); +const {Dedupe} = ChromeUtils.import("resource://activity-stream/common/Dedupe.jsm"); ChromeUtils.defineModuleGetter(this, "filterAdult", "resource://activity-stream/lib/FilterAdult.jsm"); diff --git a/lib/ManualMigration.jsm b/lib/ManualMigration.jsm index bd48f0e82..ac234289f 100644 --- a/lib/ManualMigration.jsm +++ b/lib/ManualMigration.jsm @@ -3,12 +3,12 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); +const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); const MIGRATION_ENDED_EVENT = "Migration:Ended"; const MS_PER_DAY = 86400000; -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.defineModuleGetter(this, "MigrationUtils", "resource:///modules/MigrationUtils.jsm"); ChromeUtils.defineModuleGetter(this, "ProfileAge", "resource://gre/modules/ProfileAge.jsm"); diff --git a/lib/NaiveBayesTextTagger.jsm b/lib/NaiveBayesTextTagger.jsm index 205d27fac..9355c937d 100644 --- a/lib/NaiveBayesTextTagger.jsm +++ b/lib/NaiveBayesTextTagger.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {toksToTfIdfVector} = ChromeUtils.import("resource://activity-stream/lib/Tokenize.jsm", {}); +const {toksToTfIdfVector} = ChromeUtils.import("resource://activity-stream/lib/Tokenize.jsm"); this.NaiveBayesTextTagger = class NaiveBayesTextTagger { constructor(model) { diff --git a/lib/NewTabInit.jsm b/lib/NewTabInit.jsm index 82094b6b8..899fd8164 100644 --- a/lib/NewTabInit.jsm +++ b/lib/NewTabInit.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); +const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); /** * NewTabInit - A placeholder for now. This will send a copy of the state to all diff --git a/lib/NmfTextTagger.jsm b/lib/NmfTextTagger.jsm index dc275207a..29fe91c8f 100644 --- a/lib/NmfTextTagger.jsm +++ b/lib/NmfTextTagger.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {toksToTfIdfVector} = ChromeUtils.import("resource://activity-stream/lib/Tokenize.jsm", {}); +const {toksToTfIdfVector} = ChromeUtils.import("resource://activity-stream/lib/Tokenize.jsm"); this.NmfTextTagger = class NmfTextTagger { constructor(model) { diff --git a/lib/OnboardingMessageProvider.jsm b/lib/OnboardingMessageProvider.jsm index ab1872cd3..0929c512f 100644 --- a/lib/OnboardingMessageProvider.jsm +++ b/lib/OnboardingMessageProvider.jsm @@ -2,10 +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"; -ChromeUtils.import("resource://gre/modules/Localization.jsm"); -ChromeUtils.import("resource://gre/modules/FxAccountsConfig.jsm"); -ChromeUtils.import("resource:///modules/AttributionCode.jsm"); -ChromeUtils.import("resource://gre/modules/addons/AddonRepository.jsm"); +const {Localization} = ChromeUtils.import("resource://gre/modules/Localization.jsm"); +const {FxAccountsConfig} = ChromeUtils.import("resource://gre/modules/FxAccountsConfig.jsm"); +const {AttributionCode} = ChromeUtils.import("resource:///modules/AttributionCode.jsm"); +const {AddonRepository} = ChromeUtils.import("resource://gre/modules/addons/AddonRepository.jsm"); async function getAddonInfo() { try { diff --git a/lib/PersistentCache.jsm b/lib/PersistentCache.jsm index a741684e2..9dfba6ad8 100644 --- a/lib/PersistentCache.jsm +++ b/lib/PersistentCache.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.defineModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm"); XPCOMUtils.defineLazyGetter(this, "gTextDecoder", () => new TextDecoder()); diff --git a/lib/PersonalityProvider.jsm b/lib/PersonalityProvider.jsm index 781f2f503..6aab620e7 100644 --- a/lib/PersonalityProvider.jsm +++ b/lib/PersonalityProvider.jsm @@ -3,20 +3,20 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {RemoteSettings} = ChromeUtils.import("resource://services-settings/remote-settings.js", {}); +const {RemoteSettings} = ChromeUtils.import("resource://services-settings/remote-settings.js"); -const {actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); +const {actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); ChromeUtils.defineModuleGetter(this, "perfService", "resource://activity-stream/common/PerfService.jsm"); -const {NaiveBayesTextTagger} = ChromeUtils.import("resource://activity-stream/lib/NaiveBayesTextTagger.jsm", {}); -const {NmfTextTagger} = ChromeUtils.import("resource://activity-stream/lib/NmfTextTagger.jsm", {}); -const {RecipeExecutor} = ChromeUtils.import("resource://activity-stream/lib/RecipeExecutor.jsm", {}); +const {NaiveBayesTextTagger} = ChromeUtils.import("resource://activity-stream/lib/NaiveBayesTextTagger.jsm"); +const {NmfTextTagger} = ChromeUtils.import("resource://activity-stream/lib/NmfTextTagger.jsm"); +const {RecipeExecutor} = ChromeUtils.import("resource://activity-stream/lib/RecipeExecutor.jsm"); ChromeUtils.defineModuleGetter(this, "NewTabUtils", "resource://gre/modules/NewTabUtils.jsm"); -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); ChromeUtils.defineModuleGetter(this, "OS", "resource://gre/modules/osfile.jsm"); XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]); diff --git a/lib/PlacesFeed.jsm b/lib/PlacesFeed.jsm index 84ec5ce94..0d947867e 100644 --- a/lib/PlacesFeed.jsm +++ b/lib/PlacesFeed.jsm @@ -3,9 +3,9 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); -const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); +const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); ChromeUtils.defineModuleGetter(this, "NewTabUtils", "resource://gre/modules/NewTabUtils.jsm"); diff --git a/lib/PrefsFeed.jsm b/lib/PrefsFeed.jsm index 66b7e74cf..99b7b8358 100644 --- a/lib/PrefsFeed.jsm +++ b/lib/PrefsFeed.jsm @@ -3,10 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {Prefs} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm", {}); -const {PrerenderData} = ChromeUtils.import("resource://activity-stream/common/PrerenderData.jsm", {}); -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {Prefs} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm"); +const {PrerenderData} = ChromeUtils.import("resource://activity-stream/common/PrerenderData.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils", "resource://gre/modules/PrivateBrowsingUtils.jsm"); diff --git a/lib/RecipeExecutor.jsm b/lib/RecipeExecutor.jsm index 745623b38..795f59687 100644 --- a/lib/RecipeExecutor.jsm +++ b/lib/RecipeExecutor.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {tokenize} = ChromeUtils.import("resource://activity-stream/lib/Tokenize.jsm", {}); +const {tokenize} = ChromeUtils.import("resource://activity-stream/lib/Tokenize.jsm"); /** * RecipeExecutor is the core feature engineering pipeline for the in-browser diff --git a/lib/SearchShortcuts.jsm b/lib/SearchShortcuts.jsm index 426862d0a..92dadc51a 100644 --- a/lib/SearchShortcuts.jsm +++ b/lib/SearchShortcuts.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); // List of sites we match against Topsites in order to identify sites // that should be converted to search Topsites diff --git a/lib/SectionsManager.jsm b/lib/SectionsManager.jsm index 88c645888..6ed044a17 100644 --- a/lib/SectionsManager.jsm +++ b/lib/SectionsManager.jsm @@ -3,10 +3,10 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/EventEmitter.jsm"); -ChromeUtils.import("resource://gre/modules/Services.jsm"); -const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {getDefaultOptions} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamStorage.jsm", {}); +const {EventEmitter} = ChromeUtils.import("resource://gre/modules/EventEmitter.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {getDefaultOptions} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamStorage.jsm"); ChromeUtils.defineModuleGetter(this, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm"); diff --git a/lib/ShortURL.jsm b/lib/ShortURL.jsm index 357776a22..8012115dc 100644 --- a/lib/ShortURL.jsm +++ b/lib/ShortURL.jsm @@ -1,5 +1,5 @@ -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "IDNService", "@mozilla.org/network/idn-service;1", "nsIIDNService"); diff --git a/lib/SiteClassifier.jsm b/lib/SiteClassifier.jsm index 6c11a3b89..5c979a1de 100644 --- a/lib/SiteClassifier.jsm +++ b/lib/SiteClassifier.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {RemoteSettings} = ChromeUtils.import("resource://services-settings/remote-settings.js", {}); +const {RemoteSettings} = ChromeUtils.import("resource://services-settings/remote-settings.js"); // Returns whether the passed in params match the criteria. // To match, they must contain all the params specified in criteria and the values diff --git a/lib/SnippetsFeed.jsm b/lib/SnippetsFeed.jsm index b5a5c6fc7..522110945 100644 --- a/lib/SnippetsFeed.jsm +++ b/lib/SnippetsFeed.jsm @@ -3,8 +3,8 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); -const {actionTypes: at, actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {actionTypes: at, actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); ChromeUtils.defineModuleGetter(this, "AddonManager", "resource://gre/modules/AddonManager.jsm"); diff --git a/lib/Store.jsm b/lib/Store.jsm index 0f562d5f1..70ec13fda 100644 --- a/lib/Store.jsm +++ b/lib/Store.jsm @@ -3,11 +3,11 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {ActivityStreamMessageChannel} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamMessageChannel.jsm", {}); -const {ActivityStreamStorage} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamStorage.jsm", {}); -const {Prefs} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm", {}); -const {reducers} = ChromeUtils.import("resource://activity-stream/common/Reducers.jsm", {}); -const {redux} = ChromeUtils.import("resource://activity-stream/vendor/Redux.jsm", {}); +const {ActivityStreamMessageChannel} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamMessageChannel.jsm"); +const {ActivityStreamStorage} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamStorage.jsm"); +const {Prefs} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm"); +const {reducers} = ChromeUtils.import("resource://activity-stream/common/Reducers.jsm"); +const {redux} = ChromeUtils.import("resource://activity-stream/vendor/Redux.jsm"); /** * Store - This has a similar structure to a redux store, but includes some extra diff --git a/lib/SystemTickFeed.jsm b/lib/SystemTickFeed.jsm index a365cab43..84d87b8ae 100644 --- a/lib/SystemTickFeed.jsm +++ b/lib/SystemTickFeed.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); +const {actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); ChromeUtils.defineModuleGetter(this, "setInterval", "resource://gre/modules/Timer.jsm"); ChromeUtils.defineModuleGetter(this, "clearInterval", "resource://gre/modules/Timer.jsm"); diff --git a/lib/TelemetryFeed.jsm b/lib/TelemetryFeed.jsm index 3d80a3fd6..d88efdb7a 100644 --- a/lib/TelemetryFeed.jsm +++ b/lib/TelemetryFeed.jsm @@ -5,12 +5,12 @@ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -const {actionTypes: at, actionUtils: au} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {Prefs} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm", {}); -const {classifySite} = ChromeUtils.import("resource://activity-stream/lib/SiteClassifier.jsm", {}); +const {actionTypes: at, actionUtils: au} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {Prefs} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm"); +const {classifySite} = ChromeUtils.import("resource://activity-stream/lib/SiteClassifier.jsm"); ChromeUtils.defineModuleGetter(this, "ASRouterPreferences", "resource://activity-stream/lib/ASRouterPreferences.jsm"); diff --git a/lib/TippyTopProvider.jsm b/lib/TippyTopProvider.jsm index ac4b26166..33afd5853 100644 --- a/lib/TippyTopProvider.jsm +++ b/lib/TippyTopProvider.jsm @@ -2,7 +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/. */ -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyGlobalGetters(this, ["fetch", "URL"]); diff --git a/lib/TopSitesFeed.jsm b/lib/TopSitesFeed.jsm index 015e8fee9..f0ce30e78 100644 --- a/lib/TopSitesFeed.jsm +++ b/lib/TopSitesFeed.jsm @@ -3,15 +3,15 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {TippyTopProvider} = ChromeUtils.import("resource://activity-stream/lib/TippyTopProvider.jsm", {}); -const {insertPinned, TOP_SITES_MAX_SITES_PER_ROW} = ChromeUtils.import("resource://activity-stream/common/Reducers.jsm", {}); -const {Dedupe} = ChromeUtils.import("resource://activity-stream/common/Dedupe.jsm", {}); -const {shortURL} = ChromeUtils.import("resource://activity-stream/lib/ShortURL.jsm", {}); -const {getDefaultOptions} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamStorage.jsm", {}); +const {actionCreators: ac, actionTypes: at} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {TippyTopProvider} = ChromeUtils.import("resource://activity-stream/lib/TippyTopProvider.jsm"); +const {insertPinned, TOP_SITES_MAX_SITES_PER_ROW} = ChromeUtils.import("resource://activity-stream/common/Reducers.jsm"); +const {Dedupe} = ChromeUtils.import("resource://activity-stream/common/Dedupe.jsm"); +const {shortURL} = ChromeUtils.import("resource://activity-stream/lib/ShortURL.jsm"); +const {getDefaultOptions} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamStorage.jsm"); const { CUSTOM_SEARCH_SHORTCUTS, SEARCH_SHORTCUTS_EXPERIMENT, @@ -19,7 +19,7 @@ const { SEARCH_SHORTCUTS_HAVE_PINNED_PREF, checkHasSearchEngine, getSearchProvider, -} = ChromeUtils.import("resource://activity-stream/lib/SearchShortcuts.jsm", {}); +} = ChromeUtils.import("resource://activity-stream/lib/SearchShortcuts.jsm"); ChromeUtils.defineModuleGetter(this, "filterAdult", "resource://activity-stream/lib/FilterAdult.jsm"); diff --git a/lib/TopStoriesFeed.jsm b/lib/TopStoriesFeed.jsm index 68b815848..a849bdd7c 100644 --- a/lib/TopStoriesFeed.jsm +++ b/lib/TopStoriesFeed.jsm @@ -3,18 +3,18 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/NewTabUtils.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {NewTabUtils} = ChromeUtils.import("resource://gre/modules/NewTabUtils.jsm"); XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]); -const {actionTypes: at, actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm", {}); -const {Prefs} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm", {}); -const {shortURL} = ChromeUtils.import("resource://activity-stream/lib/ShortURL.jsm", {}); -const {SectionsManager} = ChromeUtils.import("resource://activity-stream/lib/SectionsManager.jsm", {}); -const {UserDomainAffinityProvider} = ChromeUtils.import("resource://activity-stream/lib/UserDomainAffinityProvider.jsm", {}); -const {PersonalityProvider} = ChromeUtils.import("resource://activity-stream/lib/PersonalityProvider.jsm", {}); -const {PersistentCache} = ChromeUtils.import("resource://activity-stream/lib/PersistentCache.jsm", {}); +const {actionTypes: at, actionCreators: ac} = ChromeUtils.import("resource://activity-stream/common/Actions.jsm"); +const {Prefs} = ChromeUtils.import("resource://activity-stream/lib/ActivityStreamPrefs.jsm"); +const {shortURL} = ChromeUtils.import("resource://activity-stream/lib/ShortURL.jsm"); +const {SectionsManager} = ChromeUtils.import("resource://activity-stream/lib/SectionsManager.jsm"); +const {UserDomainAffinityProvider} = ChromeUtils.import("resource://activity-stream/lib/UserDomainAffinityProvider.jsm"); +const {PersonalityProvider} = ChromeUtils.import("resource://activity-stream/lib/PersonalityProvider.jsm"); +const {PersistentCache} = ChromeUtils.import("resource://activity-stream/lib/PersistentCache.jsm"); ChromeUtils.defineModuleGetter(this, "perfService", "resource://activity-stream/common/PerfService.jsm"); ChromeUtils.defineModuleGetter(this, "pktApi", "chrome://pocket/content/pktApi.jsm"); diff --git a/lib/UTEventReporting.jsm b/lib/UTEventReporting.jsm index e08f88f6e..bcafcc0ce 100644 --- a/lib/UTEventReporting.jsm +++ b/lib/UTEventReporting.jsm @@ -5,7 +5,7 @@ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); /** * Note: the schema can be found in diff --git a/lib/UserDomainAffinityProvider.jsm b/lib/UserDomainAffinityProvider.jsm index e84fc97a2..9e7982b55 100644 --- a/lib/UserDomainAffinityProvider.jsm +++ b/lib/UserDomainAffinityProvider.jsm @@ -3,7 +3,7 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.defineModuleGetter(this, "PlacesUtils", "resource://gre/modules/PlacesUtils.jsm"); diff --git a/package-lock.json b/package-lock.json index c1ff96b0d..e7d974e98 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1055,15 +1055,15 @@ } }, "babel-plugin-jsm-to-commonjs": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/babel-plugin-jsm-to-commonjs/-/babel-plugin-jsm-to-commonjs-0.4.0.tgz", - "integrity": "sha1-eBgITBlMWsH/yUokv6Dtxzfxi/s=", + "version": "0.5.0", + "resolved": "https://registry.npmjs.org/babel-plugin-jsm-to-commonjs/-/babel-plugin-jsm-to-commonjs-0.5.0.tgz", + "integrity": "sha512-2+84X/eEYxs+ig3ZVfQhcnvFrYPKKCYmdTs6RZp00MKoIOZ2zET3+mK7gyO6IN922oIv6NGrizOtSEJqLxl/RA==", "dev": true }, "babel-plugin-jsm-to-esmodules": { - "version": "0.4.0", - "resolved": "https://registry.npmjs.org/babel-plugin-jsm-to-esmodules/-/babel-plugin-jsm-to-esmodules-0.4.0.tgz", - "integrity": "sha1-UJLJUW/YX7UBGMOPFG4MyA36d8k=", + "version": "0.6.0", + "resolved": "https://registry.npmjs.org/babel-plugin-jsm-to-esmodules/-/babel-plugin-jsm-to-esmodules-0.6.0.tgz", + "integrity": "sha512-463Yuq2sLkjoGHl5vPYUQQONnDjxnmxZuhsR1swL5N76hDFGyYZAVd6HoS4E02jBF8bORpS4aFmdr1XjEZ0buQ==", "dev": true }, "babel-plugin-syntax-async-functions": { @@ -3493,14 +3493,50 @@ } }, "eslint-plugin-mozilla": { - "version": "0.16.3", - "resolved": "https://registry.npmjs.org/eslint-plugin-mozilla/-/eslint-plugin-mozilla-0.16.3.tgz", - "integrity": "sha512-ZvseeV3flenYTZP/B6SUTnwmfMkW99o0FNm3DaM4ZlyahTGXHepmAEPLkwIvY5eKrcRmo8On+kNmUqelDmxwKw==", + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/eslint-plugin-mozilla/-/eslint-plugin-mozilla-1.1.0.tgz", + "integrity": "sha512-LmmwR+/B5MDC/50aGIqMsuRnGBSLjBBHTIfm9IawLap5GHwOWN7BcP0x4AFiWwgUQMr+PScQniW5W+olFLuk+Q==", "dev": true, "requires": { - "htmlparser2": "3.9.2", + "htmlparser2": "3.10.0", "ini-parser": "0.0.2", "sax": "1.2.4" + }, + "dependencies": { + "htmlparser2": { + "version": "3.10.0", + "resolved": "https://registry.npmjs.org/htmlparser2/-/htmlparser2-3.10.0.tgz", + "integrity": "sha512-J1nEUGv+MkXS0weHNWVKJJ+UrLfePxRWpN3C9bEi9fLxL2+ggW94DQvgYVXsaT30PGwYRIZKNZXuyMhp3Di4bQ==", + "dev": true, + "requires": { + "domelementtype": "^1.3.0", + "domhandler": "^2.3.0", + "domutils": "^1.5.1", + "entities": "^1.1.1", + "inherits": "^2.0.1", + "readable-stream": "^3.0.6" + } + }, + "readable-stream": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-3.1.1.tgz", + "integrity": "sha512-DkN66hPyqDhnIQ6Jcsvx9bFjhw214O4poMBcIMgPVpQvNy9a0e0Uhg5SqySyDKAmUlwt8LonTBz1ezOnM8pUdA==", + "dev": true, + "requires": { + "inherits": "^2.0.3", + "string_decoder": "^1.1.1", + "util-deprecate": "^1.0.1" + } + }, + "string_decoder": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-1.2.0.tgz", + "integrity": "sha512-6YqyX6ZWEYguAxgZzHGL7SsCeGx3V2TtOTqZz1xSTSWnqsbWwbptafNyvf/ACquZUXV3DANr5BDIwNYe1mN42w==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.0" + } + } } }, "eslint-plugin-no-unsanitized": { diff --git a/package.json b/package.json index 723204db4..4f8fee4d1 100644 --- a/package.json +++ b/package.json @@ -22,8 +22,8 @@ "babel-core": "6.26.3", "babel-eslint": "10.0.1", "babel-loader": "7.1.4", - "babel-plugin-jsm-to-commonjs": "0.4.0", - "babel-plugin-jsm-to-esmodules": "0.4.0", + "babel-plugin-jsm-to-commonjs": "0.5.0", + "babel-plugin-jsm-to-esmodules": "0.6.0", "babel-plugin-transform-async-generator-functions": "6.24.1", "babel-plugin-transform-async-to-generator": "6.24.1", "babel-plugin-transform-async-to-module-method": "6.24.1", @@ -39,7 +39,7 @@ "eslint": "5.9.0", "eslint-plugin-import": "2.14.0", "eslint-plugin-json": "1.2.1", - "eslint-plugin-mozilla": "0.16.3", + "eslint-plugin-mozilla": "1.1.0", "eslint-plugin-no-unsanitized": "3.0.2", "eslint-plugin-promise": "4.0.1", "eslint-plugin-react": "7.11.1", diff --git a/ping-centre/PingCentre.jsm b/ping-centre/PingCentre.jsm index 6d60f9af3..4e0607a23 100644 --- a/ping-centre/PingCentre.jsm +++ b/ping-centre/PingCentre.jsm @@ -2,8 +2,8 @@ * 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/. */ -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); XPCOMUtils.defineLazyGlobalGetters(this, ["fetch"]); ChromeUtils.defineModuleGetter(this, "AppConstants", diff --git a/test/browser/browser_activity_stream_strings.js b/test/browser/browser_activity_stream_strings.js index fdc9b33ed..c599e1fb8 100644 --- a/test/browser/browser_activity_stream_strings.js +++ b/test/browser/browser_activity_stream_strings.js @@ -1,4 +1,3 @@ -ChromeUtils.import("resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService", "@mozilla.org/browser/aboutnewtab-service;1", "nsIAboutNewTabService"); diff --git a/test/browser/browser_asrouter_cfr.js b/test/browser/browser_asrouter_cfr.js index 500f06c2f..0958ee3d8 100644 --- a/test/browser/browser_asrouter_cfr.js +++ b/test/browser/browser_asrouter_cfr.js @@ -1,9 +1,9 @@ const {CFRPageActions} = - ChromeUtils.import("resource://activity-stream/lib/CFRPageActions.jsm", {}); + ChromeUtils.import("resource://activity-stream/lib/CFRPageActions.jsm"); const {ASRouterTriggerListeners} = - ChromeUtils.import("resource://activity-stream/lib/ASRouterTriggerListeners.jsm", {}); + ChromeUtils.import("resource://activity-stream/lib/ASRouterTriggerListeners.jsm"); const {ASRouter} = - ChromeUtils.import("resource://activity-stream/lib/ASRouter.jsm", {}); + ChromeUtils.import("resource://activity-stream/lib/ASRouter.jsm"); function trigger_cfr_panel(browser, trigger, action = {type: "FOO"}) { // a fake action type will result in the action being ignored return CFRPageActions.addRecommendation( diff --git a/test/browser/browser_asrouter_targeting.js b/test/browser/browser_asrouter_targeting.js index 2d2c02b7e..912c593d7 100644 --- a/test/browser/browser_asrouter_targeting.js +++ b/test/browser/browser_asrouter_targeting.js @@ -1,7 +1,7 @@ const {ASRouterTargeting, QueryCache} = - ChromeUtils.import("resource://activity-stream/lib/ASRouterTargeting.jsm", {}); + ChromeUtils.import("resource://activity-stream/lib/ASRouterTargeting.jsm"); const {AddonTestUtils} = - ChromeUtils.import("resource://testing-common/AddonTestUtils.jsm", {}); + ChromeUtils.import("resource://testing-common/AddonTestUtils.jsm"); ChromeUtils.defineModuleGetter(this, "ProfileAge", "resource://gre/modules/ProfileAge.jsm"); ChromeUtils.defineModuleGetter(this, "AddonManager", diff --git a/test/browser/browser_asrouter_trigger_listeners.js b/test/browser/browser_asrouter_trigger_listeners.js index 74b7934bb..d13fed14a 100644 --- a/test/browser/browser_asrouter_trigger_listeners.js +++ b/test/browser/browser_asrouter_trigger_listeners.js @@ -1,6 +1,5 @@ ChromeUtils.defineModuleGetter(this, "ASRouterTriggerListeners", "resource://activity-stream/lib/ASRouterTriggerListeners.jsm"); -ChromeUtils.import("resource://gre/modules/Services.jsm"); ChromeUtils.defineModuleGetter(this, "TestUtils", "resource://testing-common/TestUtils.jsm"); ChromeUtils.defineModuleGetter(this, "PrivateBrowsingUtils", diff --git a/test/browser/browser_enabled_newtabpage.js b/test/browser/browser_enabled_newtabpage.js index 2394597cd..d4823058f 100644 --- a/test/browser/browser_enabled_newtabpage.js +++ b/test/browser/browser_enabled_newtabpage.js @@ -1,5 +1,3 @@ -ChromeUtils.import("resource://gre/modules/NetUtil.jsm"); - function checkSpec(uri, check, message) { const {spec} = NetUtil.newChannel({ loadUsingSystemPrincipal: true, diff --git a/test/browser/browser_getScreenshots.js b/test/browser/browser_getScreenshots.js index e373cc397..6b43a5c97 100644 --- a/test/browser/browser_getScreenshots.js +++ b/test/browser/browser_getScreenshots.js @@ -3,8 +3,6 @@ * file, You can obtain one at http://mozilla.org/MPL/2.0/. */ "use strict"; -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); - // a blue page const TEST_URL = "https://example.com/browser/browser/components/newtab/test/browser/blue_page.html"; const XHTMLNS = "http://www.w3.org/1999/xhtml"; diff --git a/test/browser/browser_newtab_overrides.js b/test/browser/browser_newtab_overrides.js index cc016ee0b..c0ae9c363 100644 --- a/test/browser/browser_newtab_overrides.js +++ b/test/browser/browser_newtab_overrides.js @@ -1,8 +1,5 @@ "use strict"; -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -ChromeUtils.import("resource://gre/modules/Services.jsm"); - XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService", "@mozilla.org/browser/aboutnewtab-service;1", "nsIAboutNewTabService"); diff --git a/test/browser/browser_packaged_as_locales.js b/test/browser/browser_packaged_as_locales.js index a8ace4368..0c76ac965 100644 --- a/test/browser/browser_packaged_as_locales.js +++ b/test/browser/browser_packaged_as_locales.js @@ -1,4 +1,3 @@ -ChromeUtils.import("resource://gre/modules/Services.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService", "@mozilla.org/browser/aboutnewtab-service;1", "nsIAboutNewTabService"); diff --git a/test/unit/unit-entry.js b/test/unit/unit-entry.js index d2f08c47c..5acc92faa 100644 --- a/test/unit/unit-entry.js +++ b/test/unit/unit-entry.js @@ -37,12 +37,7 @@ const TEST_GLOBAL = { ChromeUtils: { defineModuleGetter() {}, generateQI() { return {}; }, - import(str) { - if (str === "resource://services-settings/remote-settings.js") { - return {RemoteSettings: TEST_GLOBAL.RemoteSettings}; - } - return {}; - }, + import() { return global; }, }, Components: {isSuccessCode: () => true}, // eslint-disable-next-line object-shorthand diff --git a/test/xpcshell/test_ASRouterTargeting_attribution.js b/test/xpcshell/test_ASRouterTargeting_attribution.js index 13c40b6aa..36ba673f5 100644 --- a/test/xpcshell/test_ASRouterTargeting_attribution.js +++ b/test/xpcshell/test_ASRouterTargeting_attribution.js @@ -4,9 +4,9 @@ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource:///modules/AttributionCode.jsm"); -ChromeUtils.import("resource://activity-stream/lib/ASRouterTargeting.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {AttributionCode} = ChromeUtils.import("resource:///modules/AttributionCode.jsm"); +const {ASRouterTargeting} = ChromeUtils.import("resource://activity-stream/lib/ASRouterTargeting.jsm"); add_task(async function check_attribution_data() { // Some setup to fake the correct attribution data diff --git a/test/xpcshell/test_AboutNewTabService.js b/test/xpcshell/test_AboutNewTabService.js index 1d577217c..9ab0baa60 100644 --- a/test/xpcshell/test_AboutNewTabService.js +++ b/test/xpcshell/test_AboutNewTabService.js @@ -4,10 +4,9 @@ "use strict"; -ChromeUtils.import("resource://gre/modules/Services.jsm"); -ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); -ChromeUtils.import("resource://gre/modules/Preferences.jsm"); -ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); +const {Services} = ChromeUtils.import("resource://gre/modules/Services.jsm"); +const {XPCOMUtils} = ChromeUtils.import("resource://gre/modules/XPCOMUtils.jsm"); +const {AppConstants} = ChromeUtils.import("resource://gre/modules/AppConstants.jsm"); XPCOMUtils.defineLazyServiceGetter(this, "aboutNewTabService", "@mozilla.org/browser/aboutnewtab-service;1", "nsIAboutNewTabService"); diff --git a/webpack.system-addon.config.js b/webpack.system-addon.config.js index 7df399c93..8aca65ef6 100644 --- a/webpack.system-addon.config.js +++ b/webpack.system-addon.config.js @@ -34,7 +34,7 @@ module.exports = { exclude: /node_modules/, loader: "babel-loader", // Converts .jsm files into common-js modules - options: {plugins: [["jsm-to-esmodules", {basePath: resourcePathRegEx, replace: true}], ["transform-object-rest-spread", {"useBuiltIns": true}]]}, + options: {plugins: [["jsm-to-esmodules", {basePath: resourcePathRegEx, removeOtherImports: true, replace: true}], ["transform-object-rest-spread", {"useBuiltIns": true}]]}, }, ], },