Bug 1070842 - Switch to new-style exception reporting in LoadFrameScriptInternal. r=bz
authorBobby Holley <bobbyholley@gmail.com>
Mon, 29 Sep 2014 15:34:21 +0200
changeset 207703 b3c7b542dbc25c56c9843a8a090f06b59b00391d
parent 207702 ed7e4dde009b2e29ed05b05f32592edba5016b19
child 207704 8b19763dd5f1681073257fe504637b1d8a7c74e0
push id27564
push userryanvm@gmail.com
push dateMon, 29 Sep 2014 18:57:04 +0000
treeherdermozilla-central@ce9a0b34225e [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1070842
milestone35.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 1070842 - Switch to new-style exception reporting in LoadFrameScriptInternal. r=bz
content/base/src/nsFrameMessageManager.cpp
--- a/content/base/src/nsFrameMessageManager.cpp
+++ b/content/base/src/nsFrameMessageManager.cpp
@@ -24,16 +24,17 @@
 #include "nsIConsoleService.h"
 #include "nsIMemoryReporter.h"
 #include "nsIProtocolHandler.h"
 #include "nsIScriptSecurityManager.h"
 #include "nsIJSRuntimeService.h"
 #include "nsIDOMClassInfo.h"
 #include "nsIDOMFile.h"
 #include "xpcpublic.h"
+#include "mozilla/CycleCollectedJSRuntime.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/dom/nsIContentParent.h"
 #include "mozilla/dom/PermissionMessageUtils.h"
 #include "mozilla/dom/ScriptSettings.h"
 #include "mozilla/dom/StructuredCloneUtils.h"
 #include "mozilla/dom/ipc/BlobChild.h"
 #include "mozilla/dom/ipc/BlobParent.h"
 #include "JavaScriptChild.h"
@@ -1427,50 +1428,47 @@ nsFrameScriptExecutor::Shutdown()
 void
 nsFrameScriptExecutor::LoadFrameScriptInternal(const nsAString& aURL,
                                                bool aRunInGlobalScope)
 {
   if (!mGlobal || !sCachedScripts) {
     return;
   }
 
-  AutoSafeJSContext cx;
-  JS::Rooted<JSScript*> script(cx);
+  JSRuntime* rt = CycleCollectedJSRuntime::Get()->Runtime();
+  JS::Rooted<JSScript*> script(rt);
 
   nsFrameScriptObjectExecutorHolder* holder = sCachedScripts->Get(aURL);
   if (holder && holder->WillRunInGlobalScope() == aRunInGlobalScope) {
     script = holder->mScript;
   } else {
     // Don't put anything in the cache if we already have an entry
     // with a different WillRunInGlobalScope() value.
     bool shouldCache = !holder;
     TryCacheLoadAndCompileScript(aURL, aRunInGlobalScope,
                                  shouldCache, &script);
   }
 
-  JS::Rooted<JSObject*> global(cx, mGlobal->GetJSObject());
+  JS::Rooted<JSObject*> global(rt, mGlobal->GetJSObject());
   if (global) {
-    JSAutoCompartment ac(cx, global);
-    bool ok = true;
+    AutoEntryScript aes(xpc::NativeGlobal(global));
+    aes.TakeOwnershipOfErrorReporting();
+    JSContext* cx = aes.cx();
     if (script) {
       if (aRunInGlobalScope) {
-        ok = JS::CloneAndExecuteScript(cx, global, script);
+        JS::CloneAndExecuteScript(cx, global, script);
       } else {
         JS::Rooted<JSObject*> scope(cx);
-        ok = js::ExecuteInGlobalAndReturnScope(cx, global, script, &scope);
-        if (ok){
+        bool ok = js::ExecuteInGlobalAndReturnScope(cx, global, script, &scope);
+        if (ok) {
           // Force the scope to stay alive.
           mAnonymousGlobalScopes.AppendElement(scope);
         }
       }
     }
-
-    if (!ok) {
-      nsJSUtils::ReportPendingException(cx);
-    }
   }
 }
 
 void
 nsFrameScriptExecutor::TryCacheLoadAndCompileScript(const nsAString& aURL,
                                                     bool aRunInGlobalScope,
                                                     bool aShouldCache,
                                                     JS::MutableHandle<JSScript*> aScriptp)