Bug 1098145 - Fix BrowserElement::Download crash. r=smaug

This commit is contained in:
Kan-Ru Chen (陳侃如) 2014-11-21 18:56:28 +08:00
parent b61618c420
commit 220e6d7376

View File

@ -341,10 +341,13 @@ nsBrowserElement::Download(const nsAString& aUrl,
NS_ENSURE_TRUE(IsNotWidgetOrThrow(aRv), nullptr);
nsCOMPtr<nsIDOMDOMRequest> req;
nsCOMPtr<nsIXPConnectWrappedJS> wrappedObj = do_QueryInterface(mBrowserElementAPI);
MOZ_ASSERT(wrappedObj, "Failed to get wrapped JS from XPCOM component.");
AutoJSAPI jsapi;
jsapi.Init();
JS::Rooted<JS::Value> options(jsapi.cx());
if (!ToJSValue(jsapi.cx(), aOptions, &options)) {
jsapi.Init(wrappedObj->GetJSObject());
JSContext* cx = jsapi.cx();
JS::Rooted<JS::Value> options(cx);
if (!ToJSValue(cx, aOptions, &options)) {
aRv.Throw(NS_ERROR_OUT_OF_MEMORY);
return nullptr;
}