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 200545 4c62cbb21c01027acbc7f8c3e29d3b997ad61bac
parent 200544 400d802dc432c859a75f428594d5e8d6c3bd9554
child 200546 86f90cef7574c81628c8d02dffd51b0f65ae79aa
push id486
push userasasaki@mozilla.com
push dateMon, 14 Jul 2014 18:39:42 +0000
treeherdermozilla-release@d33428174ff1 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz, sledru
bugs990090
milestone31.0
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())
 {
--- 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: