Bug 990090 - Add a version of AutoJSAPIWithErrorsReportedToWindow that takes an nsIGlobalObject. r=bz, a=sledru
authorBobby Holley <bobbyholley@gmail.com>
Thu, 12 Jun 2014 10:02:33 -0700
changeset 206974 f436868418ee20934dba0c19fb3457731d58a938
parent 206973 c28fb44d72a99c7d6d3c9513a9709e6ba22d75e2
child 206975 f1aebc2f1c583b6461d576719a7148c64c4b121d
push id3741
push userasasaki@mozilla.com
push dateMon, 21 Jul 2014 20:25:18 +0000
treeherdermozilla-beta@4d6f46f5af68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sledru
bugs990090
milestone32.0a2
Bug 990090 - Add a version of AutoJSAPIWithErrorsReportedToWindow that takes an nsIGlobalObject. r=bz, a=sledru
dom/base/ScriptSettings.cpp
dom/base/ScriptSettings.h
--- a/dom/base/ScriptSettings.cpp
+++ b/dom/base/ScriptSettings.cpp
@@ -232,16 +232,21 @@ AutoJSAPI::AutoJSAPI(JSContext *aCx, boo
   }
 }
 
 AutoJSAPIWithErrorsReportedToWindow::AutoJSAPIWithErrorsReportedToWindow(nsIScriptContext* aScx)
   : AutoJSAPI(aScx->GetNativeContext(), /* aIsMainThread = */ true)
 {
 }
 
+AutoJSAPIWithErrorsReportedToWindow::AutoJSAPIWithErrorsReportedToWindow(nsIGlobalObject* aGlobalObject)
+  : AutoJSAPI(FindJSContext(aGlobalObject), /* aIsMainThread = */ true)
+{
+}
+
 AutoEntryScript::AutoEntryScript(nsIGlobalObject* aGlobalObject,
                                  bool aIsMainThread,
                                  JSContext* aCx)
   : AutoJSAPI(aCx ? aCx : FindJSContext(aGlobalObject), aIsMainThread, /* aSkipNullAc = */ true)
   , ScriptSettingsStackEntry(aGlobalObject, /* aCandidate = */ true)
   , mAc(cx(), aGlobalObject->GetGlobalJSObject())
   , mStack(ScriptSettingsStack::Ref())
   , mWebIDLCallerPrincipal(nullptr)
--- a/dom/base/ScriptSettings.h
+++ b/dom/base/ScriptSettings.h
@@ -153,16 +153,18 @@ private:
 // implementing it that way would require us to destroy and reconstruct
 // mCxPusher, which is pretty wasteful. So we do this for now, since it should
 // be pretty easy to switch things over later.
 //
 // This should only be used on the main thread.
 class AutoJSAPIWithErrorsReportedToWindow : public AutoJSAPI {
   public:
     AutoJSAPIWithErrorsReportedToWindow(nsIScriptContext* aScx);
+    // Equivalent to AutoJSAPI if aGlobal is not a Window.
+    AutoJSAPIWithErrorsReportedToWindow(nsIGlobalObject* aGlobalObject);
 };
 
 /*
  * A class that represents a new script entry point.
  */
 class AutoEntryScript : public AutoJSAPI,
                         protected ScriptSettingsStackEntry {
 public: