Bug 167475 - Telemetry to count how often iframes load no-data URLs, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Fri, 23 Nov 2018 08:11:31 +0100
changeset 507006 8810195a2a42d9622f020cf704b8025396d0f139
parent 507005 f9d8c60591142bd751ff149f34b287d456df606c
child 507007 5f77d9f3460c8ab31c35326e9ef079aee758ef35
push id1905
push userffxbld-merge
push dateMon, 21 Jan 2019 12:33:13 +0000
treeherdermozilla-release@c2fca1944d8c [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs167475
milestone65.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 167475 - Telemetry to count how often iframes load no-data URLs, r=smaug
docshell/base/nsDocShell.cpp
dom/base/UseCounters.conf
--- a/docshell/base/nsDocShell.cpp
+++ b/docshell/base/nsDocShell.cpp
@@ -10264,16 +10264,33 @@ nsDocShell::DoURILoad(nsIURI* aURI,
 
   nsresult rv;
   nsCOMPtr<nsIURILoader> uriLoader = do_GetService(NS_URI_LOADER_CONTRACTID, &rv);
   if (NS_FAILED(rv)) {
     return rv;
   }
 
   if (IsFrame()) {
+    bool doesNotReturnData = false;
+    NS_URIChainHasFlags(aURI, nsIProtocolHandler::URI_DOES_NOT_RETURN_DATA,
+                        &doesNotReturnData);
+
+    if (doesNotReturnData) {
+      // If this is an iframe, it must have a parent. Let's count the
+      // no-data-URL telemetry on the parent document, because probably this one
+      // is an about page.
+      nsCOMPtr<nsIDocShellTreeItem> parent;
+      GetSameTypeParent(getter_AddRefs(parent));
+      MOZ_ASSERT(parent);
+
+      nsIDocument* parentDocument = parent->GetDocument();
+      if (parentDocument) {
+        parentDocument->SetDocumentAndPageUseCounter(eUseCounter_custom_no_data_URL);
+      }
+    }
 
     MOZ_ASSERT(aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_IFRAME ||
                aContentPolicyType == nsIContentPolicy::TYPE_INTERNAL_FRAME,
                "DoURILoad thinks this is a frame and InternalLoad does not");
 
     // Only allow view-source scheme in top-level docshells. view-source is
     // the only scheme to which this applies at the moment due to potential
     // timing attacks to read data from cross-origin iframes. If this widens
--- a/dom/base/UseCounters.conf
+++ b/dom/base/UseCounters.conf
@@ -55,16 +55,19 @@ method PushManager.subscribe
 method PushSubscription.unsubscribe
 
 // window.sidebar
 attribute Window.sidebar
 
 // External interface
 method External.AddSearchProvider
 
+// no-data URLs for iframes
+custom no_data_URL used in iframes
+
 // AppCache API
 method OfflineResourceList.swapCache
 method OfflineResourceList.update
 attribute OfflineResourceList.status
 attribute OfflineResourceList.onchecking
 attribute OfflineResourceList.onerror
 attribute OfflineResourceList.onnoupdate
 attribute OfflineResourceList.ondownloading