Dear Chromium Extension Developers,
We are excited to announce a new feature that will provide you with more flexibility when developing Chromium extensions. Starting with the M136 release (stable release date of April 29th), we will introduce the browser namespace as an optional alternative to the existing chrome namespace for calling Chromium extension APIs. You can try this today using the --enable-features=ExtensionBrowserNamespaceAlternative flag in Chrome Canary. This change will be enabled by default in Chrome Canary the same or next day after this change is submitted (check the commits page to find the exact version).
Here are the key details of this update:
Availability: The browser namespace will be available for all MV3+ extensions wherever extension developers can call Chromium extension APIs, including content scripts, background contexts, and offscreen documents.
Equivalence: The chrome and browser namespaces refer to the exact same extension API objects. For example, chrome.<api> is equivalent to browser.<api> (e.g chrome.<api> === browser.api). They can be used interchangeably.
Object Difference: While the APIs are the same, chrome and browser are different objects. Setting browser.my_custom_var does not automatically set chrome.my_custom_var (and vice versa).
Existing Extensions: We understand that some extensions may be using the non-existence of the browser namespace to detect when they are not running in Chromium. If so, we’d like to know why you are doing this as there may be better options available. In the meantime, a workaround would be to call /Chrom(ium|e)/.test(navigator.userAgent) to detect Chromium or branded Chrome.
Community Feedback: We are aware that this change might affect some existing extensions. We are relying on community reports to determine if this causes significant disruption and we need to make changes to the rollout plan. We hope that the almost 6 week lead time before stable release will provide sufficient time for those extensions to update their behavior.
We hope that this change will make it easier to develop extensions across multiple browsers.
If you have any questions, please feel free to reach out to us.