我正在编写一个用于Firefox的自定义.pac脚本.在我看到的很多例子之后,我插入了alert()来调试它,但没有警报弹出窗口,尽管脚本被清楚地被调用. (我在每次更改为脚本后,在“连接设置”中点击“重新加载”,甚至尝试重新启动Firefox.)
警报是否适用于PAC脚本?也许这是一个仅IE功能?
解决方法
http://mxr.mozilla.org/mozilla-central/source/netwerk/base/src/nsProxyAutoConfig.js
80 // add predefined functions to pac 81 this._sandBox.importFunction(myIpAddress); 82 this._sandBox.importFunction(dnsResolve); 83 this._sandBox.importFunction(proxyAlert,"alert");
108 function proxyAlert(msg) { 109 msg = XPCSafeJSObjectWrapper(msg); 110 try { 111 // It would appear that the console service is threadsafe. 112 var cns = Components.classes["@mozilla.org/consoleservice;1"] 113 .getService(Components.interfaces.nsIConsoleService); 114 cns.logStringMessage("PAC-alert: "+msg); 115 } catch (e) { 116 dump("PAC: proxyAlert ERROR: "+e+"\n"); 117 }