# alert() used in the PAC

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

Rule PAC-K002 (`alert-in-pac`), severity low, category: Compatibility across engines.

alert() is the PAC specification's debugging hook. Chromium records it internally, Firefox writes to its console and Windows accepts it without visible output, but engines without alert, such as older pactester builds, throw and abort the evaluation. It has no place in a deployed file.

## Why it matters

`alert()` was defined by the original Netscape PAC environment as a debugging function. It
never shows a dialog in any current browser. Chromium binds it and forwards the message to
its network log (not visible to users; code, 2026-10-04); Firefox logs to the browser
console. Windows (WinHTTP) defines `alert()`; in the lab on Windows 11 (2026-10-11) the call
returned false and did not stop the script. Engines without the function, such as pacparser
1.5.0 and older, throw a `ReferenceError`, and the request is treated as a script failure. A
deployed PAC with `alert()` therefore does nothing useful anywhere and may break routing on an
engine that lacks it. Lab verification of the Firefox behaviour is pending.


## How to fix

Remove alert() calls; test PACs with an external evaluator instead.

## Bad

```js
function FindProxyForURL(url, host) {
  alert("debug " + host);
  return "DIRECT";
}
```

## Good

```js
function FindProxyForURL(url, host) {
  return "DIRECT";
}
```

## Engine behaviour

- chromium: alert is bound (AlertCallback) and the message is forwarded to the resolver bindings, which record it in the network log; no dialog, no exception. (source: code, verified 2026-10-04)
- firefox: Message is written to the browser console; no dialog. (source: expert, unverified)
- pacparser: Depends on the version. Since 1.5.1, alert writes the message to standard error and the script continues; in 1.4.x alert is not defined, so the call throws an error (lab, 1.5.3 and 1.4.6). (source: lab, verified 2026-10-04)
- winhttp: alert exists and returns false, with or without arguments; the script continues. (source: lab, verified 2026-10-11)
