How to test a proxy autoconfiguration file

Due to the existence of [Greal Firewall](, I have a terribly long `proxy.pac` file. Apparently, how to maintain that becomes a problem. Regularly, I use [git]( to keep a “stable” version and make updates on it.

Recently I just found the script stop working for no good reason, because the proxy server I’m using is working, and I tried manually choose a proxy server (by entering its address and port into my browser directly) it also worked, so apparently there is something wrong with the script.

However, it has been a while since I last commit my changes to this script back to git. So there are some changes I wish to keep and I don’t want to do a binary search to find out the problem (Yep, I’m a lazy guy).

A few googling got me a tool called [pactester](, which turned out to be very useful. Basically it’s a Perl wrap of [SpiderMonkey]( JavaScript engine. Since the proxy autoconfiguration script is just a subset of plain JavaScript, it can safely executes that with SpiderMonkey and find out where is the problem.

So I installed it and did one test:

$ pactester -p ~/Documents/Miscs/proxy.pac -u ‘’
Use of uninitialized value in numeric ne (!=) at pactester line 137.
Error: SyntaxError: missing ) after condition at line 98:
if (dnsDomainIs(host, “”) return “SOCKS”;

So that’s the problem. Fixed it, everything is back to normal again!

That’s a small tip on debugging a complex pac script, hope it helps.

Author: Jiang Jiang

A software engineer from China, working on some OS for a fruit company. Interested in typography and science fiction.

2 thoughts on “How to test a proxy autoconfiguration file”

  1. Thanks for this post, I’ve been searching for AGES for something to test my wpad.dat files for things like the silly typo that you mention and this is very helpful, saved me a lot of heartache!

  2. I also want to test my wpad.dat files but i find it hard because i really do not know some technical stuff. I will read this over and over again so that i can do it perfectly. Thanks!

Leave a Reply

Your email address will not be published. Required fields are marked *