Bug 1268889 - Implement Clear-Site-Data header - part 2 - pref, r=smaug
authorAndrea Marchesini <amarchesini@mozilla.com>
Wed, 20 Jun 2018 11:57:49 -0400
changeset 423162 b2320061fbcb5a844162e50fe22f409ce9a03ff9
parent 423161 dd3b7047ea6f00c7488329b50842623f1bbdd3fb
child 423163 97528847b7b7b47475b5e0a54550194ffa38a7df
push id34164
push usercsabou@mozilla.com
push dateThu, 21 Jun 2018 01:17:13 +0000
treeherdermozilla-central@d231a3231680 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerssmaug
bugs1268889
milestone62.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 1268889 - Implement Clear-Site-Data header - part 2 - pref, r=smaug
modules/libpref/init/StaticPrefList.h
testing/web-platform/meta/clear-site-data/__dir__.ini
toolkit/components/clearsitedata/ClearSiteData.cpp
--- a/modules/libpref/init/StaticPrefList.h
+++ b/modules/libpref/init/StaticPrefList.h
@@ -112,16 +112,32 @@ VARCACHE_PREF(
 )
 
 // If true. then the service worker interception and the ServiceWorkerManager
 // will live in the parent process.  This only takes effect on browser start.
 // Note, this is not currently safe to use for normal browsing yet.
 PREF("dom.serviceWorkers.parent_intercept", bool, false)
 
 //---------------------------------------------------------------------------
+// Clear-Site-Data prefs
+//---------------------------------------------------------------------------
+
+#ifdef NIGHTLY
+# define PREF_VALUE true
+#else
+# define PREF_VALUE false
+#endif
+VARCACHE_PREF(
+  "dom.clearSiteData.enabled",
+   dom_clearSiteData_enabled,
+  bool, PREF_VALUE
+)
+#undef PREF_VALUE
+
+//---------------------------------------------------------------------------
 // Full-screen prefs
 //---------------------------------------------------------------------------
 
 #ifdef RELEASE_OR_BETA
 # define PREF_VALUE false
 #else
 # define PREF_VALUE true
 #endif
new file mode 100644
--- /dev/null
+++ b/testing/web-platform/meta/clear-site-data/__dir__.ini
@@ -0,0 +1,1 @@
+prefs: [dom.clearSiteData.enabled:true]
--- a/toolkit/components/clearsitedata/ClearSiteData.cpp
+++ b/toolkit/components/clearsitedata/ClearSiteData.cpp
@@ -4,16 +4,17 @@
  * License, v. 2.0. If a copy of the MPL was not distributed with this file,
  * You can obtain one at http://mozilla.org/MPL/2.0/. */
 
 #include "ClearSiteData.h"
 
 #include "mozilla/OriginAttributes.h"
 #include "mozilla/Preferences.h"
 #include "mozilla/Services.h"
+#include "mozilla/StaticPrefs.h"
 #include "mozilla/Unused.h"
 #include "nsASCIIMask.h"
 #include "nsCharSeparatedTokenizer.h"
 #include "nsContentUtils.h"
 #include "nsIClearDataService.h"
 #include "nsIHttpChannel.h"
 #include "nsIHttpProtocolHandler.h"
 #include "nsIObserverService.h"
@@ -161,16 +162,21 @@ ClearSiteData::ClearSiteData() = default
 ClearSiteData::~ClearSiteData() = default;
 
 NS_IMETHODIMP
 ClearSiteData::Observe(nsISupports* aSubject, const char* aTopic,
                        const char16_t* aData)
 {
   MOZ_ASSERT(!strcmp(aTopic, NS_HTTP_ON_EXAMINE_RESPONSE_TOPIC));
 
+  // Pref disabled.
+  if (!StaticPrefs::dom_clearSiteData_enabled()) {
+    return NS_OK;
+  }
+
   nsCOMPtr<nsIHttpChannel> channel = do_QueryInterface(aSubject);
   if (NS_WARN_IF(!channel)) {
     return NS_OK;
   }
 
   ClearDataFromChannel(channel);
   return NS_OK;
 }