Bug 1195242 - force malware and phishing block warnings to break out of frames at the docshell level, r?bz draft
authorGijs Kruitbosch <gijskruitbosch@gmail.com>
Wed, 20 Jan 2016 11:10:54 +0000
changeset 323476 c915616a89604b982d642afddb2dda5ff6133ba2
parent 323475 c2139fedfe55c5e36d173268eea3aba55467b12f
child 513220 b490fde04f7191cf0d0e0a04e72da3d3daeec845
push id9727
push usergijskruitbosch@gmail.com
push dateWed, 20 Jan 2016 11:11:12 +0000
reviewersbz
bugs1195242
milestone46.0a1
Bug 1195242 - force malware and phishing block warnings to break out of frames at the docshell level, r?bz
docshell/base/nsDocShell.cpp
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -4947,16 +4947,27 @@ nsDocShell::DisplayLoadError(nsresult aE
       } else {
         error.AssignLiteral("nssFailure2");
       }
     }
   } else if (NS_ERROR_PHISHING_URI == aError ||
              NS_ERROR_MALWARE_URI == aError ||
              NS_ERROR_UNWANTED_URI == aError ||
              NS_ERROR_FORBIDDEN_URI == aError) {
+    // This ensures we never display the error page in a frame:
+    nsCOMPtr<nsIDocShellTreeItem> parent;
+    GetSameTypeParent(getter_AddRefs(parent));
+    if (parent) {
+      nsCOMPtr<nsIDocShellTreeItem> sameTypeRoot;
+      parent->GetSameTypeRootTreeItem(getter_AddRefs(sameTypeRoot));
+      nsCOMPtr<nsIDocShell> rootShell = do_QueryInterface(sameTypeRoot);
+      return rootShell->DisplayLoadError(aError, aURI, aURL, aFailedChannel,
+          aDisplayedErrorPage);
+    }
+
     nsAutoCString host;
     aURI->GetHost(host);
     CopyUTF8toUTF16(host, formatStrs[0]);
     formatStrCount = 1;
 
     // Malware and phishing detectors may want to use an alternate error
     // page, but if the pref's not set, we'll fall back on the standard page
     nsAdoptingCString alternateErrorPage =