diff --git a/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp b/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp index e5b3ae525846..130d106c8fe5 100644 --- a/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp +++ b/js/src/xpconnect/src/XPCSafeJSObjectWrapper.cpp @@ -867,7 +867,8 @@ XPC_SJOW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv, obj = nsnull; if (JSVAL_IS_PRIMITIVE(argv[0])) { - return ThrowException(NS_ERROR_INVALID_ARG, cx); + *rval = argv[0]; + return JS_TRUE; } JSObject *objToWrap = JSVAL_TO_OBJECT(argv[0]); diff --git a/netwerk/base/src/nsProxyAutoConfig.js b/netwerk/base/src/nsProxyAutoConfig.js index 492c4bd711a3..5e40925c1913 100644 --- a/netwerk/base/src/nsProxyAutoConfig.js +++ b/netwerk/base/src/nsProxyAutoConfig.js @@ -96,16 +96,17 @@ nsProxyAutoConfig.prototype = { return null; // Call the original function - var rval = this._sandBox.FindProxyForURL(testURI, testHost); + try { + var rval = this._sandBox.FindProxyForURL(testURI, testHost); + } catch (e) { + throw new XPCSafeJSObjectWrapper(e); + } return rval; } } function proxyAlert(msg) { - // Ensure that we have a string. - if (typeof msg != "string") - msg = new XPCSafeJSObjectWrapper(msg).toString(); - + msg = new XPCSafeJSObjectWrapper(msg); try { // It would appear that the console service is threadsafe. var cns = Components.classes["@mozilla.org/consoleservice;1"] @@ -127,9 +128,7 @@ function myIpAddress() { // wrapper for resolving hostnames called by PAC file function dnsResolve(host) { - if (typeof host != "string") - host = new XPCSafeJSObjectWrapper(host).toString(); - + host = new XPCSafeJSObjectWrapper(host); try { return dns.resolve(host, 0).getNextAddrAsString(); } catch (e) {