Bug 1234622. Tweak how nsDocumentViewer::FindContainerView finds the parent presshell. r=bz
authorTimothy Nikkel <tnikkel@gmail.com>
Fri, 25 Mar 2016 13:49:29 -0500
changeset 290478 ff20990e88e15a5002d63b2cfd8aa390138c1cb4
parent 290477 745c69669283077563fdf6719882a087e61c342b
child 290479 d210a03627b7b34dac01f4eaaf6e4def2635233c
push id19656
push usergwagner@mozilla.com
push dateMon, 04 Apr 2016 13:43:23 +0000
treeherderb2g-inbound@e99061fde28a [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersbz
bugs1234622
milestone48.0a1
Bug 1234622. Tweak how nsDocumentViewer::FindContainerView finds the parent presshell. r=bz During page transition the presshell we get via the parent docshell is the presshell for the _next_ document. Whereas, the presshell we get via the containing frame element (iframe etc) is the current document. If we use the presshell for the next document to get the primary frame for the containerElement it will return null because it doesn't have the right document.
layout/base/crashtests/1234622-1.html
layout/base/crashtests/crashtests.list
layout/base/nsDocumentViewer.cpp
new file mode 100644
--- /dev/null
+++ b/layout/base/crashtests/1234622-1.html
@@ -0,0 +1,17 @@
+<!DOCTYPE html>
+
+<script>
+
+window.addEventListener("load", function() {
+    setTimeout(function() {
+        window.location = "data:text/html,2";
+    }, 0);
+}, false);
+
+window.addEventListener("pagehide", function() {
+    var x = document.createElement("object");
+    x.setAttribute("data", "data:text/plain,3");
+    document.documentElement.appendChild(x);
+}, false);
+
+</script>
--- a/layout/base/crashtests/crashtests.list
+++ b/layout/base/crashtests/crashtests.list
@@ -463,9 +463,10 @@ load 1043163-1.html
 load 1061028.html
 load 1107508-1.html
 load 1116104.html
 load 1127198-1.html
 load 1140198.html
 pref(layout.css.grid.enabled,true) load 1156588.html
 load 1162813.xul
 load 1163583.html
+load 1234622-1.html
 load 1235467-1.html
--- a/layout/base/nsDocumentViewer.cpp
+++ b/layout/base/nsDocumentViewer.cpp
@@ -2457,27 +2457,29 @@ nsDocumentViewer::FindContainerView()
   if (mContainer) {
     nsCOMPtr<nsIDocShell> docShell(mContainer);
     nsCOMPtr<nsPIDOMWindowOuter> pwin(docShell->GetWindow());
     if (pwin) {
       nsCOMPtr<Element> containerElement = pwin->GetFrameElementInternal();
       if (!containerElement) {
         return nullptr;
       }
+
       nsCOMPtr<nsIPresShell> parentPresShell;
-      nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
-      docShell->GetParent(getter_AddRefs(parentDocShellItem));
-      if (parentDocShellItem) {
-        nsCOMPtr<nsIDocShell> parentDocShell = do_QueryInterface(parentDocShellItem);
-        parentPresShell = parentDocShell->GetPresShell();
+      nsCOMPtr<nsIDocument> parentDoc = containerElement->GetCurrentDoc();
+      if (parentDoc) {
+        parentPresShell = parentDoc->GetShell();
       }
+
       if (!parentPresShell) {
-        nsCOMPtr<nsIDocument> parentDoc = containerElement->GetCurrentDoc();
-        if (parentDoc) {
-          parentPresShell = parentDoc->GetShell();
+        nsCOMPtr<nsIDocShellTreeItem> parentDocShellItem;
+        docShell->GetParent(getter_AddRefs(parentDocShellItem));
+        if (parentDocShellItem) {
+          nsCOMPtr<nsIDocShell> parentDocShell = do_QueryInterface(parentDocShellItem);
+          parentPresShell = parentDocShell->GetPresShell();
         }
       }
       if (!parentPresShell) {
         NS_WARNING("Subdocument container has no presshell");
       } else {
         nsIFrame* subdocFrame = parentPresShell->GetRealPrimaryFrameFor(containerElement);
         if (subdocFrame) {
           // subdocFrame might not be a subdocument frame; the frame