bug 791527 check compiler return on pac thread r=biesi
authorPatrick McManus <mcmanus@ducksong.com>
Thu, 27 Sep 2012 13:29:34 -0400
changeset 108324 ac9b018f79a8ca80817a6192a48544199ae9ddda
parent 108323 345ebb6f3f3e30e965c608e1e504317c929a1ca8
child 108325 0129800fa8a193b335ea708c08f0d3f110c98456
push id23552
push userryanvm@gmail.com
push dateFri, 28 Sep 2012 03:05:08 +0000
treeherdermozilla-central@2d96ee8d9dd4 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbiesi
bugs791527
milestone18.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
bug 791527 check compiler return on pac thread r=biesi
netwerk/base/src/ProxyAutoConfig.cpp
netwerk/test/unit/test_protocolproxyservice.js
--- a/netwerk/base/src/ProxyAutoConfig.cpp
+++ b/netwerk/base/src/ProxyAutoConfig.cpp
@@ -582,17 +582,18 @@ ProxyAutoConfig::SetupJS()
     return NS_ERROR_FAILURE;
 
   JSAutoRequest ar(mJSRuntime->Context());
 
   JSScript *script = JS_CompileScript(mJSRuntime->Context(),
                                       mJSRuntime->Global(),
                                       mPACScript.get(), mPACScript.Length(),
                                       mPACURI.get(), 1);
-  if (!JS_ExecuteScript(mJSRuntime->Context(), mJSRuntime->Global(), script, nullptr)) {
+  if (!script ||
+      !JS_ExecuteScript(mJSRuntime->Context(), mJSRuntime->Global(), script, nullptr)) {
     nsString alertMessage(NS_LITERAL_STRING("PAC file failed to install from "));
     alertMessage += NS_ConvertUTF8toUTF16(mPACURI);
     PACLogToConsole(alertMessage);
     return NS_ERROR_FAILURE;
   }
 
   mJSRuntime->SetOK();
   nsString alertMessage(NS_LITERAL_STRING("PAC file installed from "));
--- a/netwerk/test/unit/test_protocolproxyservice.js
+++ b/netwerk/test/unit/test_protocolproxyservice.js
@@ -10,16 +10,17 @@
 // run_filter_test();
 // run_filter_test2()
 // run_filter_test3()
 // run_pref_test();
 // run_pac_test();
 // run_pac_cancel_test();
 // run_proxy_host_filters_test();
 // run_myipaddress_test();
+// run_failed_script_test();
 
 var ios = Components.classes["@mozilla.org/network/io-service;1"]
                     .getService(Components.interfaces.nsIIOService);
 var pps = Components.classes["@mozilla.org/network/protocol-proxy-service;1"]
                     .getService();
 var prefs = Components.classes["@mozilla.org/preferences-service;1"]
                      .getService(Components.interfaces.nsIPrefBranch);
 
@@ -591,16 +592,40 @@ function myipaddress_callback(pi)
   do_check_eq(pi.type, "http");
   do_check_eq(pi.port, 1234);
 
   // make sure we didn't return localhost
   do_check_neq(pi.host, null);
   do_check_neq(pi.host, "127.0.0.1");
   do_check_neq(pi.host, "::1");
 
+  run_failed_script_test();
+}
+
+function run_failed_script_test()
+{
+  // test to make sure we go direct with invalid PAC
+  var pac = 'data:text/plain,' +
+            '\nfor(;\n';
+
+  var uri = ios.newURI("http://www.mozilla.org/", null, null);
+
+  prefs.setIntPref("network.proxy.type", 2);
+  prefs.setCharPref("network.proxy.autoconfig_url", pac);
+
+  var cb = new resolveCallback();
+  cb.nextFunction = failed_script_callback;
+  var req = pps.asyncResolve(uri, 0, cb);
+}
+
+function failed_script_callback(pi)
+{
+  // we should go direct
+  do_check_eq(pi, null);
+
   prefs.setIntPref("network.proxy.type", 0);
   do_test_finished();
 }
 
 function run_deprecated_sync_test()
 {
   var uri = ios.newURI("http://www.mozilla.org/", null, null);