Rewrite XPCOMUtils.defineLazyModuleGetter consumers with alias
Categories
(Core :: XPConnect, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox103 | --- | fixed |
People
(Reporter: arai, Assigned: arai)
References
Details
Attachments
(4 files)
XPCOMUtils.defineLazyModuleGetter
supports 4th parameter, to import symbol with different name.
https://searchfox.org/mozilla-central/rev/426022c17bb140b7e2017c127c2fe2a47481dd18/js/xpconnect/loader/XPCOMUtils.jsm#203-209
* @param aName
* The name of the getter to define on aObject for the module.
* @param aResource
* The URL used to obtain the module.
* @param aSymbol
* The name of the symbol exported by the module.
* This parameter is optional and defaults to aName.
example usage:
https://searchfox.org/mozilla-central/rev/426022c17bb140b7e2017c127c2fe2a47481dd18/remote/shared/messagehandler/ModuleCache.jsm#25-30
XPCOMUtils.defineLazyModuleGetter(
this,
"getTestModuleClass",
"chrome://mochitests/content/browser/remote/shared/messagehandler/test/browser/resources/modules/ModuleRegistry.jsm",
"getModuleClass"
);
This is not supported by defineESMGetters
API
Assignee | ||
Comment 1•3 years ago
|
||
the number of the occurrence is very low, so, not high priority
ModuleCache.jsm
extension-storage.js
ExtensionStorageSync.jsm
TaskScheduler.jsm
TaskScheduler.jsm
DownloadIntegration.jsm
Assignee | ||
Updated•3 years ago
|
Assignee | ||
Comment 2•3 years ago
|
||
Possible options are:
- Fix module that exports the symbol
- Export with different name from the module
- Export with alias from the module
- Fix module that imports the symbol
- Just import without alias
- Support alias in the lazy getter API
Assignee | ||
Comment 3•3 years ago
|
||
XPCOMUtils.defineLazyModuleGetters(lazy, {
...
getModuleClass:
"chrome://remote/content/webdriver-bidi/modules/ModuleRegistry.jsm",
...
});
XPCOMUtils.defineLazyModuleGetter(
lazy,
"getTestModuleClass",
"chrome://mochitests/content/browser/remote/shared/messagehandler/test/browser/resources/modules/ModuleRegistry.jsm",
"getModuleClass"
);
In this case, the testing module can export with getTestModuleClass
alias.
XPCOMUtils.defineLazyModuleGetter(
lazy,
"extensionStorageSyncKinto",
"resource://gre/modules/ExtensionStorageSyncKinto.jsm",
"extensionStorageSync"
);
// We might end up falling back to kinto...
XPCOMUtils.defineLazyModuleGetter(
lazy,
"extensionStorageSyncKinto",
"resource://gre/modules/ExtensionStorageSyncKinto.jsm",
"extensionStorageSync"
);
In those 2 cases, the kinto module can export with extensionStorageSyncKinto
alias.
XPCOMUtils.defineLazyModuleGetter(
lazy,
"WinImpl",
"resource://gre/modules/TaskSchedulerWinImpl.jsm",
"_TaskSchedulerWinImpl"
);
XPCOMUtils.defineLazyModuleGetter(
lazy,
"MacOSImpl",
"resource://gre/modules/TaskSchedulerMacOSImpl.jsm",
"_TaskSchedulerMacOSImpl"
);
In those 2 cases, I don't think those modules need to export with _TaskScheduler
prefix.
Just renaming the symbols should solve.
// We have to use the gCombinedDownloadIntegration identifier because, in this
// module only, the DownloadIntegration identifier refers to the base version.
Integration.downloads.defineModuleGetter(
lazy,
"gCombinedDownloadIntegration",
"resource://gre/modules/DownloadIntegration.jsm",
"DownloadIntegration"
);
...
var DownloadIntegration = {
This case doesn't need alias, because lazy getter on lazy
object doesn't conflict with global variable.
Assignee | ||
Comment 4•3 years ago
|
||
Updated•3 years ago
|
Assignee | ||
Comment 5•3 years ago
|
||
Depends on D149707
Assignee | ||
Comment 6•3 years ago
|
||
Depends on D149708
Assignee | ||
Comment 7•3 years ago
|
||
Depends on D149709
Assignee | ||
Updated•3 years ago
|
Updated•3 years ago
|
Updated•3 years ago
|
Comment 9•3 years ago
|
||
bugherder |
https://hg.mozilla.org/mozilla-central/rev/95c504ebc0ac
https://hg.mozilla.org/mozilla-central/rev/f59ba82197c4
https://hg.mozilla.org/mozilla-central/rev/e649299772e3
https://hg.mozilla.org/mozilla-central/rev/9b8ccbaf78b7
Description
•