Bug 1098074 - Part 1: Use AutoJSAPI to report JS errors in nsFrameMessageManager; r=bholley
authorTerrence Cole <terrence@mozilla.com>
Wed, 12 Nov 2014 16:48:51 -0800
changeset 216287 977889c9dbb7685bba598057c73f9020f2ff8a7d
parent 216286 dff90d1d4b3c435b559cc6a6320690d16a44fe5a
child 216288 a2b9f43e63758d54cf58ce73370a24d7ec88bb2f
push id51998
push usertcole@mozilla.com
push dateTue, 18 Nov 2014 20:16:37 +0000
treeherdermozilla-inbound@659549fa7af0 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbholley
bugs1098074
milestone36.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1098074 - Part 1: Use AutoJSAPI to report JS errors in nsFrameMessageManager; r=bholley
dom/base/nsFrameMessageManager.cpp
--- a/dom/base/nsFrameMessageManager.cpp
+++ b/dom/base/nsFrameMessageManager.cpp
@@ -971,16 +971,17 @@ nsFrameMessageManager::ReceiveMessage(ns
       // AutoEntryScript aes;
       // if (!aes.Init(wrappedJS->GetJSObject())) {
       //   continue;
       // }
       // JSContext* cx = aes.cx();
       nsIGlobalObject* nativeGlobal =
         xpc::NativeGlobal(js::GetGlobalForObjectCrossCompartment(wrappedJS->GetJSObject()));
       AutoEntryScript aes(nativeGlobal);
+      aes.TakeOwnershipOfErrorReporting();
       JSContext* cx = aes.cx();
       JS::Rooted<JSObject*> object(cx, wrappedJS->GetJSObject());
 
       // The parameter for the listener function.
       JS::Rooted<JSObject*> param(cx,
         JS_NewObject(cx, nullptr, JS::NullPtr(), JS::NullPtr()));
       NS_ENSURE_TRUE(param, NS_ERROR_OUT_OF_MEMORY);
 
@@ -1071,25 +1072,24 @@ nsFrameMessageManager::ReceiveMessage(ns
       {
         JS::Rooted<JSObject*> thisObject(cx, thisValue.toObjectOrNull());
 
         JSAutoCompartment tac(cx, thisObject);
         if (!JS_WrapValue(cx, &argv)) {
           return NS_ERROR_UNEXPECTED;
         }
 
-        if (!JS_CallFunctionValue(cx, thisObject, funval, JS::HandleValueArray(argv), &rval)) {
-          nsJSUtils::ReportPendingException(cx);
+        if (!JS_CallFunctionValue(cx, thisObject, funval,
+                                  JS::HandleValueArray(argv), &rval)) {
           continue;
         }
         if (aJSONRetVal) {
           nsString json;
           if (!JS_Stringify(cx, &rval, JS::NullPtr(), JS::NullHandleValue,
                            JSONCreator, &json)) {
-            nsJSUtils::ReportPendingException(cx);
             continue;
           }
           aJSONRetVal->AppendElement(json);
         }
       }
     }
   }
   nsRefPtr<nsFrameMessageManager> kungfuDeathGrip = mParentManager;