# console used in the PAC

Source: https://findproxyforurl.net/rules/console-in-pac/ · last updated 2026-10-12

Rule PAC-K022 (`console-in-pac`), severity medium, category: Compatibility across engines.

console.log works in Chrome and in current pactester builds, but Firefox, Windows (WinHTTP) and older pactester builds do not define console. There the call throws an error and the request is handled as a script failure.

## Why it matters

`console.log(host)` is often left over from testing a PAC file in a browser's developer
console. Whether it works depends on the engine that runs the file:
- Chrome (and other browsers built on Chromium) defines a `console` object in the PAC context;
  the call does not fail (lab, Chrome 145).
- pactester (pacparser) 1.5.3 defines `console`; pactester 1.4.6 does not (lab).
- Windows (WinHTTP, Windows 11) does not define `console` (lab). The call throws a ReferenceError,
  which has the same effect as any other exception (PAC-E006): the request is handled as a script
  failure.
- Firefox does not define `console` either (lab, Firefox 157). There, too, the call throws and
  the request is handled as a script failure.

The output is never shown to the user anyway, so the call does nothing useful in a deployed
file. The only debugging function the PAC format itself defines is `alert()`, which has its own
differences (PAC-K002).


## How to fix

Remove console.log and other console calls before you deploy the file; test the file with a separate test tool.

## Bad

```js
function FindProxyForURL(url, host) {
  console.log("PAC called for " + host);
  return "PROXY proxy.corp.example:8080";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  return "PROXY proxy.corp.example:8080";
}
```

## Engine behaviour

- chromium: console is defined (an object); calls do not throw. (source: lab, verified 2026-10-04)
- firefox: console is undefined; a call throws and the request is handled as a script failure. (source: lab, verified 2026-10-12)
- pacparser: console is defined in 1.5.3 and undefined in 1.4.6, where a call throws. (source: lab, verified 2026-10-04)
- winhttp: console is undefined; a call throws and the request is handled as a script failure. (source: lab, verified 2026-10-11)
