调试.pac javascript的4种方法

1. PacTester

下载:Win | Linux | Google Code

Usage:  ./pactester <-p pacfile> <-u url> [-h host] [-c client_ip]
        ./pactester <-p pacfile> <-f urlslist> [-c client_ip]

Options:
  -p pacfile: PAC file to test
  -u url: URL to test
  -h host: Host part of the URL
  -c client_ip: client IP address (defaults to IP address of the machine on which script is running)
  -f urlslist: a file containing list of URLs to be tested.

Example:
  ./pactester -p wpad.dat -u http://www.google.com
  ./pactester -p wpad.dat -u http://www.google.com -c 192.168.1.105
  ./pactester -p wpad.dat -f url_list

有个更加新的 PacParser 项目 http://code.google.com/p/pacparser

2. Internet Explorer (Visual InterDev)

http://support.microsoft.com/kb/274356

打开注册表 HKCU/Software/Microsoft/Windows Script/Settings,新建个JITDebug,类型DWORD,值为1

然后在IE里设置.pac,在.pac文件里alert("Blah");几行,就可以在Visual InterDev里 新建工程,调试 - 进程 选中iexplore.exe,打开任意网站调试。

3. Chrome

启动Chrome用这个命令行: chrome.exe --proxy-pac-url="file://E:/foo/bar.pac"

地址栏打开 chrome://net-internals/#events

如果出错了有一些提示。简单的调试够用了。。。

4. Firefox

在.pac的javascript里直接用 alert() 这个非标准函数即可在Error Console里看到出错。超方便。

参考:1, 2

Comments