Add alert() and console.log() for PAC script debugging#239
Merged
Conversation
Exposes alert(msg) and console.log(...args) in the JavaScript context so PAC authors can log from inside large PAC files. Output is routed through the existing error printer (stderr by default, overridable via pacparser_set_error_printer), so pactester's stdout proxy result stays clean. Addresses #32. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Match the terse comment style of surrounding helpers (dns_resolve, my_ip). When JS_ToCString fails mid-argument, emit a trailing newline before returning so stderr does not carry a dangling partial line. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Extend runtests.py with a check that alert()/console.log() from a PAC file emit the expected ALERT:/LOG: lines on stderr. Since the _pacparser C extension writes via vfprintf on fd 2, stderr is captured at the file-descriptor level with dup2 rather than by reassigning sys.stderr. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.


Summary
alert(msg)andconsole.log(...args)in the PAC JavaScript context so authors can debug large PAC files.pacparser_set_error_printer), sopactester's stdout proxy result stays unaffected.ALERT:/LOG:.Fixes #32.
Test plan
NO_INTERNET=1 make -C srcpasses (existing testdata + new end-to-end logging test intests/runtests.sh).pactesterthat logs go to stderr and proxy result stays on stdout.tests/logging.pacto confirm the new check fails loudly and exits non-zero.🤖 Generated with Claude Code