Bug 1344527 - Give up in ReadScriptAsync if we can't create a promise. r=bholley
MozReview-Commit-ID: Hq4vJZmfDpc
--- a/js/xpconnect/loader/mozJSSubScriptLoader.cpp
+++ b/js/xpconnect/loader/mozJSSubScriptLoader.cpp
@@ -405,22 +405,22 @@ mozJSSubScriptLoader::ReadScriptAsync(ns
{
RootedObject target_obj(RootingCx(), targetObjArg);
nsCOMPtr<nsIGlobalObject> globalObject = xpc::NativeGlobal(target_obj);
ErrorResult result;
AutoJSAPI jsapi;
if (NS_WARN_IF(!jsapi.Init(globalObject))) {
- return NS_ERROR_UNEXPECTED;
+ return NS_ERROR_UNEXPECTED;
}
RefPtr<Promise> promise = Promise::Create(globalObject, result);
if (result.Failed()) {
- promise = nullptr;
+ return result.StealNSResult();
}
DebugOnly<bool> asJS = ToJSValue(jsapi.cx(), promise, retval);
MOZ_ASSERT(asJS, "Should not fail to convert the promise to a JS value");
// We create a channel and call SetContentType, to avoid expensive MIME type
// lookups (bug 632490).
nsCOMPtr<nsIChannel> channel;