Bug 1318506 - Label PluginInstance IPC messages with plugin's DocGroup (r?jimm) draft
authorBill McCloskey <billm@mozilla.com>
Tue, 15 Nov 2016 15:35:54 -0800
changeset 444815 2e2fb38cf701ebeac354b1038c4ba7e9e20fd14e
parent 444814 ecb6b819362d9d737bef66f6609af81020198980
child 444816 867f1d2e445b4cc2a0154d0be1db02733d16e07d
push id37376
push userbmo:wmccloskey@mozilla.com
push dateMon, 28 Nov 2016 21:43:46 +0000
reviewersjimm
bugs1318506
milestone53.0a1
Bug 1318506 - Label PluginInstance IPC messages with plugin's DocGroup (r?jimm) The goal here is to assign a DocGroup to every runnable. This patch labels all IPC message handlers for PPluginInstance with the DocGroup of the plugin instance's document. MozReview-Commit-ID: 6OIard9n2GB
dom/plugins/ipc/PluginModuleParent.cpp
--- a/dom/plugins/ipc/PluginModuleParent.cpp
+++ b/dom/plugins/ipc/PluginModuleParent.cpp
@@ -2751,16 +2751,29 @@ PluginModuleParent::NPP_NewInternal(NPMI
     }
 
     // Release the surrogate reference that was in pdata
     RefPtr<PluginAsyncSurrogate> surrogate(
         dont_AddRef(PluginAsyncSurrogate::Cast(instance)));
     // Now replace it with the instance
     instance->pdata = static_cast<PluginDataResolver*>(parentInstance);
 
+    // Any IPC messages for the PluginInstance actor should be dispatched to the
+    // DocGroup for the plugin's document.
+    RefPtr<nsPluginInstanceOwner> owner = parentInstance->GetOwner();
+    nsCOMPtr<nsIDOMElement> elt;
+    owner->GetDOMElement(getter_AddRefs(elt));
+    if (nsCOMPtr<nsINode> node = do_QueryInterface(elt)) {
+        nsCOMPtr<nsIDocument> doc = node->OwnerDoc();
+        if (doc) {
+            nsCOMPtr<nsIEventTarget> eventTarget = doc->EventTargetFor(dom::TaskCategory::Other);
+            SetEventTargetForActor(parentInstance, eventTarget);
+        }
+    }
+
     if (!SendPPluginInstanceConstructor(parentInstance,
                                         nsDependentCString(pluginType), mode,
                                         names, values)) {
         // |parentInstance| is automatically deleted.
         instance->pdata = nullptr;
         *error = NPERR_GENERIC_ERROR;
         return NS_ERROR_FAILURE;
     }