Bug 1291437 - Followup: Add some comments explaining why we're initializing the AutoJSAPI in PostMessageEvent::Run the way we do. a=ritu
authorBoris Zbarsky <bzbarsky@mit.edu>
Tue, 02 Aug 2016 13:28:17 -0700
changeset 348115 7f90dcc0445b8c06aa7529bb63dbed5991fc590d
parent 348114 fc1db61e30cdbc18be66eea66948255ec7eb721b
child 348116 404c54eecb4dcd1e9ee465ba054063471e310a5d
push id6389
push userraliiev@mozilla.com
push dateMon, 19 Sep 2016 13:38:22 +0000
treeherdermozilla-beta@01d67bfe6c81 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersritu
bugs1291437
milestone50.0a2
Bug 1291437 - Followup: Add some comments explaining why we're initializing the AutoJSAPI in PostMessageEvent::Run the way we do. a=ritu
dom/base/PostMessageEvent.cpp
--- a/dom/base/PostMessageEvent.cpp
+++ b/dom/base/PostMessageEvent.cpp
@@ -55,16 +55,19 @@ PostMessageEvent::~PostMessageEvent()
 NS_IMETHODIMP
 PostMessageEvent::Run()
 {
   MOZ_ASSERT(mTargetWindow->IsOuterWindow(),
              "should have been passed an outer window!");
   MOZ_ASSERT(!mSource || mSource->IsOuterWindow(),
              "should have been passed an outer window!");
 
+  // Note: We don't init this AutoJSAPI with targetWindow, because we do not
+  // want exceptions during message deserialization to trigger error events on
+  // targetWindow.
   AutoJSAPI jsapi;
   jsapi.Init();
   JSContext* cx = jsapi.cx();
 
   // The document is just used for the principal mismatch error message below.
   // Use a stack variable so mSourceDocument is not held onto after this method
   // finishes, regardless of the method outcome.
   nsCOMPtr<nsIDocument> sourceDocument;