Search code examples
firefoxproxyhttp-proxyfirefox-addon-webextensionspac

Registering PAC Proxy file from Firefox WebExtension - Functions not defined


When I try to register a .pac file from a webextension background script in Firefox using browser.proxy.register("proxy.pac"), all the PAC functions expected to be available are not.

Using isNetName(), dnsResolve(), shExpMatch(), etc. all throw an "is not defined" error.

Here is my background script:

browser.proxy.register("proxy.pac")
browser.proxy.onProxyError.addListener(error => {
    console.error(`Proxy error: ${error.message}`);
});

Solution

  • The Browser Extension PAC script environment is limited and doesn't support all the functions provided to normal PAC scripts.

    Some of those function however can be copied from the Firefox source code.