mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-16 23:05:42 +00:00
Bug 765168 - Remove the dependency of XHR::send on a cx parameter. r=smaug
Given the new bindings, I think this is dead code anyway modulo the pref.
This commit is contained in:
parent
53d09f54fe
commit
46527f944d
@ -1572,6 +1572,7 @@ public:
|
||||
nsresult* aRv);
|
||||
|
||||
static JSContext *GetCurrentJSContext();
|
||||
static JSContext *GetSafeJSContext();
|
||||
|
||||
/**
|
||||
* Case insensitive comparison between two strings. However it only ignores
|
||||
|
@ -5454,6 +5454,13 @@ nsContentUtils::GetCurrentJSContext()
|
||||
return cx;
|
||||
}
|
||||
|
||||
/* static */
|
||||
JSContext *
|
||||
nsContentUtils::GetSafeJSContext()
|
||||
{
|
||||
return sThreadJSContextStack->GetSafeJSContext();
|
||||
}
|
||||
|
||||
/* static */
|
||||
nsresult
|
||||
nsContentUtils::ASCIIToLower(nsAString& aStr)
|
||||
|
@ -2680,12 +2680,27 @@ GetRequestBody(nsIVariant* aBody, JSContext *aCx, nsIInputStream** aResult,
|
||||
|
||||
// ArrayBuffer?
|
||||
jsval realVal;
|
||||
nsCxPusher pusher;
|
||||
JSAutoEnterCompartment ac;
|
||||
JSObject* obj;
|
||||
|
||||
// If there's a context on the stack, we can just use it. Otherwise, we need
|
||||
// to use the safe js context (and push it into the stack, so that it's
|
||||
// visible to cx-less functions that we might call here).
|
||||
JSContext* cx = nsContentUtils::GetCurrentJSContext();
|
||||
if (!cx) {
|
||||
cx = nsContentUtils::GetSafeJSContext();
|
||||
if (!pusher.Push(cx)) {
|
||||
return NS_ERROR_FAILURE;
|
||||
}
|
||||
}
|
||||
|
||||
nsresult rv = aBody->GetAsJSVal(&realVal);
|
||||
if (NS_SUCCEEDED(rv) && !JSVAL_IS_PRIMITIVE(realVal) &&
|
||||
(obj = JSVAL_TO_OBJECT(realVal)) &&
|
||||
(JS_IsArrayBufferObject(obj, aCx))) {
|
||||
ArrayBuffer buf(aCx, obj);
|
||||
ac.enter(cx, obj) &&
|
||||
(JS_IsArrayBufferObject(obj, cx))) {
|
||||
ArrayBuffer buf(cx, obj);
|
||||
return GetRequestBody(&buf, aResult, aContentType, aCharset);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user