Make XPCSafeJSObjectWrapper usage in PAC actually work correctly for the common case. bug 391515, r=jst sr+a=brendan

This commit is contained in:
mrbkap@gmail.com 2007-08-15 14:16:52 -07:00
parent 76a296aec2
commit 10e61ce970
2 changed files with 10 additions and 10 deletions

View File

@ -646,6 +646,7 @@ XPC_SJOW_NewResolve(JSContext *cx, JSObject *obj, jsval id, uintN flags,
JS_STATIC_DLL_CALLBACK(JSBool)
XPC_SJOW_Convert(JSContext *cx, JSObject *obj, JSType type, jsval *vp)
{
NS_ASSERTION(type != JSTYPE_STRING, "toString failed us");
return JS_TRUE;
}
@ -856,6 +857,11 @@ XPC_SJOW_Construct(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
obj = nsnull;
if (JSVAL_IS_PRIMITIVE(argv[0])) {
JSStackFrame *fp = nsnull;
if (JS_FrameIterator(cx, &fp) && JS_IsConstructorFrame(cx, fp)) {
return ThrowException(NS_ERROR_ILLEGAL_VALUE, cx);
}
*rval = argv[0];
return JS_TRUE;
}
@ -960,13 +966,7 @@ XPC_SJOW_toString(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
}
// Function body for wrapping toString() in a scripted caller.
#ifndef DEBUG
NS_NAMED_LITERAL_CSTRING(funScript,
"return '' + this;");
#else
NS_NAMED_LITERAL_CSTRING(funScript,
"return '[object XPCSafeJSObjectWrapper (' + this + ')]';");
#endif
NS_NAMED_LITERAL_CSTRING(funScript, "return '' + this;");
jsval scriptedFunVal;
if (!GetScriptedFunction(cx, obj, unsafeObj, XPC_SJOW_SLOT_SCRIPTED_TOSTRING,

View File

@ -99,14 +99,14 @@ nsProxyAutoConfig.prototype = {
try {
var rval = this._sandBox.FindProxyForURL(testURI, testHost);
} catch (e) {
throw new XPCSafeJSObjectWrapper(e);
throw XPCSafeJSObjectWrapper(e);
}
return rval;
}
}
function proxyAlert(msg) {
msg = new XPCSafeJSObjectWrapper(msg);
msg = XPCSafeJSObjectWrapper(msg);
try {
// It would appear that the console service is threadsafe.
var cns = Components.classes["@mozilla.org/consoleservice;1"]
@ -128,7 +128,7 @@ function myIpAddress() {
// wrapper for resolving hostnames called by PAC file
function dnsResolve(host) {
host = new XPCSafeJSObjectWrapper(host);
host = XPCSafeJSObjectWrapper(host);
try {
return dns.resolve(host, 0).getNextAddrAsString();
} catch (e) {