Bug 960246 - Handle failures when executing frame scripts (r=smaug,bholley)
authorBill McCloskey <wmccloskey@mozilla.com>
Thu, 16 Jan 2014 11:43:01 -0800
changeset 163874 d020e9d743a61d9c338814360810e015bdccdccf
parent 163660 33f70f00af82bcef4fcc663b8032accdf11ee32e
child 163875 3dcedecd2bbf2559e823de41b96cbaecc7417811
push idunknown
push userunknown
push dateunknown
reviewerssmaug, bholley
bugs960246
milestone29.0a1
Bug 960246 - Handle failures when executing frame scripts (r=smaug,bholley)
content/base/src/nsFrameMessageManager.cpp
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -1405,27 +1405,32 @@ nsFrameScriptExecutor::LoadFrameScriptIn
     bool shouldCache = !holder;
     TryCacheLoadAndCompileScript(aURL, aRunInGlobalScope,
                                  shouldCache, &script, &funobj);
   }
 
   JS::Rooted<JSObject*> global(cx, mGlobal->GetJSObject());
   if (global) {
     JSAutoCompartment ac(cx, global);
+    bool ok = true;
     if (funobj) {
       JS::Rooted<JSObject*> method(cx, JS_CloneFunctionObject(cx, funobj, global));
       if (!method) {
         return;
       }
       JS::Rooted<JS::Value> rval(cx);
       JS::Rooted<JS::Value> methodVal(cx, JS::ObjectValue(*method));
-      (void) JS_CallFunctionValue(cx, global, methodVal,
-                                  0, nullptr, rval.address());
+      ok = JS_CallFunctionValue(cx, global, methodVal,
+                                0, nullptr, rval.address());
     } else if (script) {
-      (void) JS_ExecuteScript(cx, global, script, nullptr);
+      ok = JS_ExecuteScript(cx, global, script, nullptr);
+    }
+
+    if (!ok) {
+      nsJSUtils::ReportPendingException(cx);
     }
   }
 }
 
 void
 nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
                                                     bool aRunInGlobalScope,
                                                     bool aShouldCache,