Make XPCSafeJSObjectWrapper usage in PAC actually work correctly for the common case. bug 391515, r=jst sr+a=brendan
git-svn-id: svn://10.0.0.236/trunk@232170 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -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,
|
||||
|
||||
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user