alert() used in the PAC
low
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.
Examples
Bad
function FindProxyForURL(url, host) {
alert("debug " + host);
return "DIRECT";
}
Open bad example in checkerEngine behaviour
| Engine | Behaviour | Source |
|---|---|---|
| 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. | code, verified 2026-10-04 · ref |
| firefox | Message is written to the browser console; no dialog. | 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). | lab, verified 2026-10-04 |
| winhttp | alert exists and returns false, with or without arguments; the script continues. | lab, verified 2026-10-11 |
The PAC functions this rule is about
alert(): Debug output from a PAC. Where it goes depends on the engine; remove it from production files.
Related rules
- Browser or Node.js objects used in the PAC PAC-E018
- console used in the PAC PAC-K022
- Call to a function that is not defined PAC-E005