Replace calls to GlobalManager.extensionMap.get() with WebExtensionPolicy.getByID()
Categories
(WebExtensions :: General, task, P5)
Tracking
(firefox91 fixed)
| Tracking | Status | |
|---|---|---|
| firefox91 | --- | fixed |
People
(Reporter: standard8, Assigned: jasleenbhambra01, Mentored)
References
Details
(Whiteboard: [lang=js])
Attachments
(1 file)
We want to replace calls to GlobalManager.extensionMap.get() with WebExtensionPolicy.getByID(). This will allow us to remove imports of GlobalManager which is not explicitly exported.
I'm happy to mentor this bug, please note:
- This is slightly larger and more complex than a normal "good first bug".
- This bug will be auto-assigned when the first patch is attached.
Here's what to do:
-
Ensure you have a [working Firefox build](https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html, an artifact build is sufficient thought it doesn't matter if you have a full build.
-
Run
./mach eslint --setupto set up ESLint, then ensure your editor has an integration set-up. It is not essential to do this, but it helps to show if you've made a mistake, or if formatting needs fixing whilst you're still in a particular file. -
Find the cases to replace, this search is a good starting point. Please skip
Extension.jsmandExtensionParent.jsmsince they are acceptable uses ofGlobalManagerat the moment. -
Edit the various pieces of code to replace:
let extension = GlobalManager.extensionMap.get(arg.extensionId);
with
let policy = WebExtensionPolicy.getByID(extension.id);
let extension = policy?.extension;
- In the files you've changed, look for where
GlobalManageris imported, typically this will be viaChromeUtils.importbut it could also beXPCOMUtils.defineLazyGetter. Remove the appropriate code so thatGlobalManageris no longer imported. - From the files where you've removed the imports, see if they can be removed from the top-level .eslintrc.js file. To do this run
./mach eslint path/to/fileand then see if any errors are generated relating toreject-chromeutils-import-params.
- If there are errors and they're not to do with the
GlobalManager, then you can put the line back into the.eslintrc.jsfile. - If there are other errors mentioned, then you may need to fix those as well.
- For the test files you have changed, run the tests to make sure they still pass.
- You can use
./mach mochitest path/to/test - We will do a run on our try servers, and make sure that the rest of the tests have past.
- Commit the changes and submit for review with a message something like
Bug nnnnnnn - Replace calls to GlobalManager.extensionMap.get() with WebExtensionPolicy.getByID(). r?Standard8. - Please be prepared to address comments from review.
Updated•4 years ago
|
Updated•4 years ago
|
| Reporter | ||
Comment 1•4 years ago
|
||
As I mentioned in comment 0, not sure this is a good first bug, as it is slightly larger than what we'd do normally. Probably is a good next bug though.
Comment 2•4 years ago
|
||
The steps needed to resolve this bug are quite straightforward (and spelled out in the first comment). It's not significantly more complex than other good-first-bugs in the extension component. In any case I'll defer to you since you've self-nominated yourself as mentor. Thanks :)
PS. For contributions to extension code, I usually refer new contributors to https://wiki.mozilla.org/WebExtensions/Contribution_Onramp. Part of a new contribution is often writing tests, which is often challenging for beginners, but in this bug it just suffices to run existing tests, which actually makes this easier, hence a good-first-bug in my opinion.
| Assignee | ||
Comment 3•4 years ago
|
||
Updated•4 years ago
|
| Assignee | ||
Comment 4•4 years ago
|
||
(In reply to Mark Banner (:standard8) from comment #0)
We want to replace calls to
GlobalManager.extensionMap.get()withWebExtensionPolicy.getByID(). This will allow us to remove imports ofGlobalManagerwhich is not explicitly exported.I'm happy to mentor this bug, please note:
- This is slightly larger and more complex than a normal "good first bug".
- This bug will be auto-assigned when the first patch is attached.
Here's what to do:
Ensure you have a [working Firefox build](https://firefox-source-docs.mozilla.org/contributing/contribution_quickref.html, an artifact build is sufficient thought it doesn't matter if you have a full build.
Run
./mach eslint --setupto set up ESLint, then ensure your editor has an integration set-up. It is not essential to do this, but it helps to show if you've made a mistake, or if formatting needs fixing whilst you're still in a particular file.Find the cases to replace, this search is a good starting point. Please skip
Extension.jsmandExtensionParent.jsmsince they are acceptable uses ofGlobalManagerat the moment.Edit the various pieces of code to replace:
let extension = GlobalManager.extensionMap.get(arg.extensionId);with
let policy = WebExtensionPolicy.getByID(extension.id); let extension = policy?.extension;
- In the files you've changed, look for where
GlobalManageris imported, typically this will be viaChromeUtils.importbut it could also beXPCOMUtils.defineLazyGetter. Remove the appropriate code so thatGlobalManageris no longer imported.- From the files where you've removed the imports, see if they can be removed from the top-level .eslintrc.js file. To do this run
./mach eslint path/to/fileand then see if any errors are generated relating toreject-chromeutils-import-params.
- If there are errors and they're not to do with the
GlobalManager, then you can put the line back into the.eslintrc.jsfile.- If there are other errors mentioned, then you may need to fix those as well.
- For the test files you have changed, run the tests to make sure they still pass.
- You can use
./mach mochitest path/to/test- We will do a run on our try servers, and make sure that the rest of the tests have past.
- Commit the changes and submit for review with a message something like
Bug nnnnnnn - Replace calls to GlobalManager.extensionMap.get() with WebExtensionPolicy.getByID(). r?Standard8.- Please be prepared to address comments from review.
Hi Sir! I've submitted a patch. Thank You!
Comment 6•4 years ago
|
||
| bugherder | ||
Comment 7•4 years ago
|
||
Hi Jasleen, thank you so much for your patch! 🎉 Your contribution has been added to our recognition wiki at https://wiki.mozilla.org/Add-ons/Contribute/Recognition.
Hope to see you around the project in the future!
| Assignee | ||
Comment 8•4 years ago
|
||
(In reply to Caitlin Neiman [:caitmuenster] from comment #7)
Hi Jasleen, thank you so much for your patch! 🎉 Your contribution has been added to our recognition wiki at https://wiki.mozilla.org/Add-ons/Contribute/Recognition.
Hope to see you around the project in the future!
Thank You Mam! :)
Description
•