Bug 1562821 - Propagate nsIWebProgress events to the <xul:browser> in responsive design mode r=Ehsan
authorBarret Rennie <barret@brennie.ca>
Tue, 23 Jul 2019 16:43:20 +0000
changeset 484080 ef785c1b1871b33e4743ea2f62f5f47ee4bce565
parent 484079 4f0e19e164f101f5af183785b2dfcfe5efe82fff
child 484081 f55a0b430239f6e38225bf7f486f3391a12b88be
push id90800
push userbrennie@mozilla.com
push dateWed, 24 Jul 2019 17:01:04 +0000
treeherderautoland@ef5b5e589da3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersEhsan
bugs1562821, 1510569
milestone70.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1562821 - Propagate nsIWebProgress events to the <xul:browser> in responsive design mode r=Ehsan The work from bug 1510569 that has ported the majority of the `nsIWebProgress` event handlers from `WebProgressChild`/`RemoteWebProgress` to `BrowserChild`/`BrowserParent` was not properly propogating the events in the responsive design mode case. The `BrowserParent` assumed that its frame element was an `nsIBrowser`, but in RDM it is an `<iframe mozbrowser>` which does not implement `nsIBrowser`. In the RDM case we now walk up the document in the `BrowserParent` tree to find the `<xul:browser>` and call the event handlers on that instead. Differential Revision: https://phabricator.services.mozilla.com/D38916
dom/ipc/BrowserParent.cpp
--- a/dom/ipc/BrowserParent.cpp
+++ b/dom/ipc/BrowserParent.cpp
@@ -2577,18 +2577,33 @@ mozilla::ipc::IPCResult BrowserParent::R
 
 bool BrowserParent::GetWebProgressListener(
     nsIBrowser** aOutBrowser, nsIWebProgress** aOutManager,
     nsIWebProgressListener** aOutListener) {
   MOZ_ASSERT(aOutBrowser);
   MOZ_ASSERT(aOutManager);
   MOZ_ASSERT(aOutListener);
 
-  nsCOMPtr<nsIBrowser> browser =
-      mFrameElement ? mFrameElement->AsBrowser() : nullptr;
+  nsCOMPtr<nsIBrowser> browser;
+  RefPtr<Element> currentElement = mFrameElement;
+
+  // In Responsive Design Mode, mFrameElement will be the <iframe mozbrowser>,
+  // but we want the <xul:browser> that it is embedded in.
+  while (currentElement) {
+    browser = currentElement->AsBrowser();
+    if (browser) {
+      break;
+    }
+
+    BrowsingContext* browsingContext =
+        currentElement->OwnerDoc()->GetBrowsingContext();
+    currentElement =
+        browsingContext ? browsingContext->GetEmbedderElement() : nullptr;
+  }
+
   if (!browser) {
     return false;
   }
 
   nsCOMPtr<nsIWebProgress> manager;
   nsresult rv = browser->GetRemoteWebProgressManager(getter_AddRefs(manager));
   if (NS_FAILED(rv)) {
     return false;