Split up message responder
We've recently inherited the
messageResponder.js file from the adblockplusui repository, it contains many of the message listeners used by the extension. Historically, it was effectively one huge message listener, so it made sense that it was in one file. Since we broke apart that huge message listener by using the messaging API (see trac#4783) and we've now moved the file into the adblockpluschrome repository, it would make more sense to split the file up. See also trac#4492.
What to change
- Where possible simply move message handlers into the correct module.
- Where necessary also rename message handlers.
- Where necessary split up monolithic message handlers into smaller parts.
- Take care to forward deprecated messages, so that nothing breaks.
- Take care to document all message handlers using JSDoc strings with the
- While moving/changing any of the inherited code, take care to bring it in line with our code standards where practical.
- All message handlers are now documented using JSDoc strings, but we had to use the
@eventstag for them. See the "Events" section of our API docs: https://adblockplus.org/jsdoc/adblockpluschrome/ . This is now the canonical documentation for the message handlers.
- Some messages were renamed and or tweaked (see linked API docs for more details), please adjust accordingly:
"types.get"message was renamed to
"app.open"message was renamed to
"app.get"message was split up.
"subscriptions.getInitIssues"- renamed but works the same as before
"prefs.getDocLink"- renamed but works the same as before
"subscriptions.getRecommendations"- renamed but works the same as before
what: "features", returns boolean instead of Object.
what: "*"and returns entire
infoObject at once.
- instead of
- The old message names will continue to work for now, but are deprecated and will be removed in the future (along with messageResponder.js itself).
Hints for testers
These changes touch a lot of the message handling logic, so it's important to smoke test the UI to make sure it hasn't broken. Especially on different supported browsers. Functionality to test:
- Subscription links (e.g. the one on testpages.adblockplus.org) still work and open the dialog on the options page correctly.
- Notifications still work, especially that they are still applied to the correct page using URL filtering and that they are showed correctly based on their type (e.g. "info" for popup only, "normal" for desktop notification only and "critical" for both).
- Test that disabling/enabling "useful" notifications still works
- Test that preference changes and documentation links in the options page still work correctly.
- Test the option to enable/disable our developer tools pane is hidden for unsupported browsers (e.g. supported on Chrome but not supported on Firefox versions < 54).
- Test that the recommended subscriptions for a new user still work correctly.
- In our developer tools pane, check the request types still show up in the "items of type" drop-down menu.
- Test that adding and removing subscriptions + custom filters still works correctly.
- If possible, test the "Your data has been corrupted" version of the first run page still shows when it should. (Might require tweaking the code, so might not be practical to test.)