Search code examples
google-chrome-extensionchrome-extension-manifest-v3

How to Test Chrome MV3 Extension Using webRequestBlocking API Without Enforcing It via Google Admin Console?


I am developing a Chrome Manifest V3 (MV3) extension that uses the webRequestBlocking API. This API is only available for extensions enforced via the Google Admin Console, as stated in Google's documentation.

In production, the extension will be deployed and enforced via the Admin Console, so it will have access to this API. However, during development, this workflow is impractical because every time I make a change to the code, I need to:

  • Repackage the extension.
  • Publish it to a hosting location.
  • Enforce it through the Admin Console.

This process slows down testing and debugging significantly.

My question is: Is there a way to test an unpacked Chrome MV3 extension that uses the webRequestBlocking API directly on the browser (e.g., in Developer Mode) without enforcing it via the Admin Console?

Key Details:

  • I am working on macOS and ChromeOS (Chromebook).
  • The extension is unpacked during development and loaded via chrome://extensions.
  • When attempting to use webRequestBlocking in Developer Mode, the API is not accessible since it requires enforcement.
  • I am aware of the limitations of MV3 and the reasons for enforcement, but I am looking for a development-specific workaround or best practices.

What I Have Tried:

  1. Loading the unpacked extension directly in Developer Mode: This results in the webRequestBlocking API being inaccessible.
  2. Searching for development flags or configuration options to enable the API for testing: No success so far.
  3. I have also contacted Google Workspace support regarding this issue. After discussing my requirements and development challenges, they suggested I post my question here.

I need a solution to test the webRequestBlocking API in Developer Mode (unpacked extension) without the need for enforcement via the Admin Console. Any official or unofficial development workflows, tools, or flags that can facilitate testing this API during extension development.


Solution

  • Modify your Chrome's shortcut or launcher and add the following to its command line:

    --allowlisted-extension-id=abcdef
    

    Replace abcdef with the id of your extension. Make sure to fully exit all Chrome processes by using the Exit command in the browser menu before running it with the new command line.