Describe the bug
Navigating to chrome:// or chrome-extension:// or chrome-search:// URLs (e.g. the extensions's own options page!) leads to errors, which are particularly confusing for the developers of the extension who don't understand them
To Reproduce
Steps to reproduce the behavior.
Turn on the extension
Navigate to the options page
Check errors in either the Errors screen (if testing an unreleased dev install) or the Service Worker "Inspect Views"
Expected behavior
We should only load the extension on real web pages (i.e. those starting with http like https:// or http://).
We do have a check for this in one of the two event listeners:
Describe the bug Navigating to
chrome://
orchrome-extension://
orchrome-search://
URLs (e.g. the extensions's own options page!) leads to errors, which are particularly confusing for the developers of the extension who don't understand themTo Reproduce Steps to reproduce the behavior.
Expected behavior
We should only load the extension on real web pages (i.e. those starting with
http
likehttps://
orhttp://
).We do have a check for this in one of the two event listeners:
https://github.com/GoogleChrome/web-vitals-extension/blob/dd624b99fc87e5df649634620dd6f93e53ff9650/service_worker.js#L53-L67
But not in the other:
https://github.com/GoogleChrome/web-vitals-extension/blob/dd624b99fc87e5df649634620dd6f93e53ff9650/service_worker.js#L72-L74
This is because this event doesn't have access to the URL.
This works to catch the error:
But seems a bit brittle depending on the exact wording, not to mention I'd prefer to prevent the code from executing rather than catch the exception.
You also change allow these URLs in the manifest (for pretty good reason to be honest!).
Have asked our resident extensions Dev Rel (Oliver) for advice.
Version: