Bug 1529248 - Clear-Site-Data header should consider executioncontexts flag only for 2xx response status, r=farre a=lizzard
authorAndrea Marchesini <amarchesini@mozilla.com>
Thu, 21 Feb 2019 08:28:38 +0000
changeset 516190 e3d40984bde070c97bc3c3190cad373be57b78a9
parent 516189 17fb0284bb5d0ecc4e0f8e87d5738e19fcc6090d
child 516191 cdfa53fd8d9c1555c4775e435350d0fa32f2040b
push id1953
push userffxbld-merge
push dateMon, 11 Mar 2019 12:10:20 +0000
treeherdermozilla-release@9c35dcbaa899 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersfarre, lizzard
bugs1529248
milestone66.0
Bug 1529248 - Clear-Site-Data header should consider executioncontexts flag only for 2xx response status, r=farre a=lizzard Differential Revision: https://phabricator.services.mozilla.com/D20502
toolkit/components/clearsitedata/ClearSiteData.cpp
--- a/toolkit/components/clearsitedata/ClearSiteData.cpp
+++ b/toolkit/components/clearsitedata/ClearSiteData.cpp
@@ -174,27 +174,16 @@ ClearSiteData::Observe(nsISupports* aSub
 }
 
 void ClearSiteData::ClearDataFromChannel(nsIHttpChannel* aChannel) {
   MOZ_ASSERT(aChannel);
 
   nsresult rv;
   nsCOMPtr<nsIURI> uri;
 
-  uint32_t status;
-  rv = aChannel->GetResponseStatus(&status);
-  if (NS_WARN_IF(NS_FAILED(rv))) {
-    return;
-  }
-
-  // We just care about 2xx response status.
-  if (status < 200 || status >= 300) {
-    return;
-  }
-
   nsIScriptSecurityManager* ssm = nsContentUtils::GetSecurityManager();
   if (NS_WARN_IF(!ssm)) {
     return;
   }
 
   nsCOMPtr<nsIPrincipal> principal;
   rv = ssm->GetChannelResultPrincipal(aChannel, getter_AddRefs(principal));
   if (NS_WARN_IF(NS_FAILED(rv))) {
@@ -253,19 +242,28 @@ void ClearSiteData::ClearDataFromChannel
 
     rv = csd->DeleteDataFromPrincipal(principal, false /* user request */,
                                       cleanFlags, holder);
     if (NS_WARN_IF(NS_FAILED(rv))) {
       return;
     }
   }
 
+  // We consider eExecutionContexts only for 2xx response status.
   if (flags & eExecutionContexts) {
-    LogOpToConsole(aChannel, uri, eExecutionContexts);
-    BrowsingContextsReload(holder, principal);
+    uint32_t status;
+    rv = aChannel->GetResponseStatus(&status);
+    if (NS_WARN_IF(NS_FAILED(rv))) {
+      return;
+    }
+
+    if (status >= 200 && status < 300) {
+      LogOpToConsole(aChannel, uri, eExecutionContexts);
+      BrowsingContextsReload(holder, principal);
+    }
   }
 }
 
 uint32_t ClearSiteData::ParseHeader(nsIHttpChannel* aChannel,
                                     nsIURI* aURI) const {
   MOZ_ASSERT(aChannel);
 
   nsAutoCString headerValue;