From 2e279c21e5de409489bd8be1e5577e603c31d3fb Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Wed, 9 Mar 2016 15:28:54 -0500 Subject: [PATCH] Bug 1254857. Switch the AutoEntryScript in xpc::EvalInSandbox to take ownership of error reporting. r=bholley In practice we always propagate the exception out anyway, so this change is a no-op. --- js/xpconnect/src/Sandbox.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/js/xpconnect/src/Sandbox.cpp b/js/xpconnect/src/Sandbox.cpp index 3c9e39021ea9..ad58a9421c59 100644 --- a/js/xpconnect/src/Sandbox.cpp +++ b/js/xpconnect/src/Sandbox.cpp @@ -1703,6 +1703,7 @@ xpc::EvalInSandbox(JSContext* cx, HandleObject sandboxArg, const nsAString& sour // We're about to evaluate script, so make an AutoEntryScript. // This is clearly Gecko-specific and not in any spec. mozilla::dom::AutoEntryScript aes(priv, "XPConnect sandbox evaluation"); + aes.TakeOwnershipOfErrorReporting(); JSContext* sandcx = aes.cx(); AutoSaveContextOptions savedOptions(sandcx); JS::ContextOptionsRef(sandcx).setDontReportUncaught(true); @@ -1716,9 +1717,8 @@ xpc::EvalInSandbox(JSContext* cx, HandleObject sandboxArg, const nsAString& sour PromiseFlatString(source).get(), source.Length(), &v); // If the sandbox threw an exception, grab it off the context. - if (JS_GetPendingException(sandcx, &exn)) { - MOZ_ASSERT(!ok); - JS_ClearPendingException(sandcx); + if (aes.HasException()) { + aes.StealException(&exn); } }