PAC-K002 · alert-in-pac

alert() used in the PAC

low · 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.

Examples

Bad

function FindProxyForURL(url, host) {
  alert("debug " + host);
  return "DIRECT";
}
Open bad example in checker

Good

function FindProxyForURL(url, host) {
  return "DIRECT";
}
Open good example in checker

Engine behaviour

EngineBehaviourSource
chromiumalert 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
firefoxMessage is written to the browser console; no dialog.expert, unverified
pacparserDepends 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
winhttpalert exists and returns false, with or without arguments; the script continues.lab, verified 2026-10-11

Source: code = read in the engine's source, doc = vendor documentation, lab = observed in a lab run, expert = practitioner knowledge, not yet verified.

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

References

Last updated: