Bug 1153145 - Ensure trused focus events from web content focus plugins. r=smaug, a=lizzard
authorSteven Michaud <smichaud@pobox.com>
Tue, 16 Jun 2015 12:00:25 -0500
changeset 267739 9ca933b3b236e9010a25ce7196837d6a2549cb4a
parent 267738 c62540b3f0e5c1b2787349998f7031c5b34449e8
child 267740 b493f95649f4dcc96656ceafa72a638fcb7cc153
push id830
push userraliiev@mozilla.com
push dateFri, 19 Jun 2015 19:24:37 +0000
treeherdermozilla-release@932614382a68 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug, lizzard
bugs1153145
milestone39.0
Bug 1153145 - Ensure trused focus events from web content focus plugins. r=smaug, a=lizzard
dom/html/HTMLObjectElement.cpp
--- a/dom/html/HTMLObjectElement.cpp
+++ b/dom/html/HTMLObjectElement.cpp
@@ -156,17 +156,22 @@ HTMLObjectElement::OnFocusBlurPlugin(Ele
   // Element that doesn't have a plugin running.  But if SetPluginFocused(true)
   // was just called for aElement while it had a plugin running, we want to
   // make sure nsIWidget::SetPluginFocused(false) gets called for it now, even
   // if aFocus is true.
   if (aFocus) {
     nsCOMPtr<nsIObjectLoadingContent> olc = do_QueryInterface(aElement);
     bool hasRunningPlugin = false;
     if (olc) {
-      olc->GetHasRunningPlugin(&hasRunningPlugin);
+      // nsIObjectLoadingContent::GetHasRunningPlugin() fails when
+      // nsContentUtils::IsCallerChrome() returns false (which it can do even
+      // when we're processing a trusted focus event).  We work around this by
+      // calling nsObjectLoadingContent::HasRunningPlugin() directly.
+      hasRunningPlugin =
+        static_cast<nsObjectLoadingContent*>(olc.get())->HasRunningPlugin();
     }
     if (!hasRunningPlugin) {
       aFocus = false;
     }
   }
 
   if (aFocus || aElement == sLastFocused) {
     if (!aFocus) {