Add infrastructure to enable/disable ITP Debug Mode through Preferences
authorwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2019 21:36:48 +0000 (21:36 +0000)
committerwilander@apple.com <wilander@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 17 Jan 2019 21:36:48 +0000 (21:36 +0000)
https://bugs.webkit.org/show_bug.cgi?id=193510
<rdar://problem/47330969>

Reviewed by Dean Jackson.

Source/WebCore:

No new tests. These changes are purely for settings/preferences.

* page/RuntimeEnabledFeatures.h:
(WebCore::RuntimeEnabledFeatures::setItpDebugModeEnabled):
(WebCore::RuntimeEnabledFeatures::itpDebugModeEnabled const):
(WebCore::RuntimeEnabledFeatures::setResourceLoadStatisticsDebugMode): Deleted.
(WebCore::RuntimeEnabledFeatures::resourceLoadStatisticsDebugMode const): Deleted.
    Renamed.
* page/Settings.yaml:
    Removed since this particular setting should not be persisted for privacy
    reasons.

Source/WebKit:

* NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
(WebKit::ResourceLoadStatisticsMemoryStore::ensurePrevalentResourcesForDebugMode):
(WebKit::ResourceLoadStatisticsMemoryStore::setResourceLoadStatisticsDebugMode):
(WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode):
    These functions are now suited for runtime switching of ITP Debug Mode.
* Shared/WebPreferences.yaml:
    Changed name from ResourceLoadStatisticsDebugMode to ItpDebugModeEnabled.
* UIProcess/API/Cocoa/WKPreferences.mm:
(-[WKPreferences _setItpDebugModeEnabled:]):
(-[WKPreferences _itpDebugModeEnabled]):
    New private preferences functions.
* UIProcess/API/Cocoa/WKPreferencesPrivate.h:
* UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm:
(WebKit::ResourceLoadStatisticsMemoryStore::registerUserDefaultsIfNeeded):
    Removed support for old experimental user default. Added a new one that's
    not connected to any UI, i.e. merely for command line debugging where
    ITP Debug Mode needs to be on all the time.

LayoutTests:

* http/tests/resourceLoadStatistics/set-custom-prevalent-resource-in-debug-mode.html:
    Changed the order of function calls since testRunner.setStatisticsPrevalentResourceForDebugMode()
    now has to be called before testRunner.setStatisticsDebugMode().

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@240129 268f45cc-cd09-0410-ab3c-d52691b4dbfc

LayoutTests/ChangeLog
LayoutTests/http/tests/resourceLoadStatistics/set-custom-prevalent-resource-in-debug-mode.html
Source/WebCore/ChangeLog
Source/WebCore/page/RuntimeEnabledFeatures.h
Source/WebCore/page/Settings.yaml
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp
Source/WebKit/Shared/WebPreferences.yaml
Source/WebKit/UIProcess/API/Cocoa/WKPreferences.mm
Source/WebKit/UIProcess/API/Cocoa/WKPreferencesPrivate.h
Source/WebKit/UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm

index f379523..c8554d9 100644 (file)
@@ -1,3 +1,15 @@
+2019-01-17  John Wilander  <wilander@apple.com>
+
+        Add infrastructure to enable/disable ITP Debug Mode through Preferences
+        https://bugs.webkit.org/show_bug.cgi?id=193510
+        <rdar://problem/47330969>
+
+        Reviewed by Dean Jackson.
+
+        * http/tests/resourceLoadStatistics/set-custom-prevalent-resource-in-debug-mode.html:
+            Changed the order of function calls since testRunner.setStatisticsPrevalentResourceForDebugMode()
+            now has to be called before testRunner.setStatisticsDebugMode().
+
 2019-01-16  Dean Jackson  <dino@apple.com>
 
         (iPad) Link tapping is sluggish on many sites
index 5aa7dd8..8f51151 100644 (file)
@@ -17,8 +17,8 @@
             if (testRunner.isStatisticsPrevalentResource(thirdPartyOrigin))
                 testFailed(thirdPartyOrigin + " already set as prevalent resource.");
 
-            testRunner.setStatisticsDebugMode(true, function() {
-                testRunner.setStatisticsPrevalentResourceForDebugMode(thirdPartyOrigin, function() {
+            testRunner.setStatisticsPrevalentResourceForDebugMode(thirdPartyOrigin, function() {
+                testRunner.setStatisticsDebugMode(true, function() {
                     if (!testRunner.isStatisticsPrevalentResource(thirdPartyOrigin))
                         testFailed(thirdPartyOrigin + " didn't get set as prevalent resource.");
                     else
index e2f8bc5..5267dd9 100644 (file)
@@ -1,3 +1,23 @@
+2019-01-17  John Wilander  <wilander@apple.com>
+
+        Add infrastructure to enable/disable ITP Debug Mode through Preferences
+        https://bugs.webkit.org/show_bug.cgi?id=193510
+        <rdar://problem/47330969>
+
+        Reviewed by Dean Jackson.
+
+        No new tests. These changes are purely for settings/preferences.
+
+        * page/RuntimeEnabledFeatures.h:
+        (WebCore::RuntimeEnabledFeatures::setItpDebugModeEnabled):
+        (WebCore::RuntimeEnabledFeatures::itpDebugModeEnabled const):
+        (WebCore::RuntimeEnabledFeatures::setResourceLoadStatisticsDebugMode): Deleted.
+        (WebCore::RuntimeEnabledFeatures::resourceLoadStatisticsDebugMode const): Deleted.
+            Renamed.
+        * page/Settings.yaml:
+            Removed since this particular setting should not be persisted for privacy
+            reasons.
+
 2019-01-17  Jer Noble  <jer.noble@apple.com>
 
         SDK_VARIANT build destinations should be separate from non-SDK_VARIANT builds
index 02face0..fc47f95 100644 (file)
@@ -145,8 +145,8 @@ public:
     void setAriaReflectionEnabled(bool isEnabled) { m_ariaReflectionEnabled = isEnabled; }
     bool ariaReflectionEnabled() const { return m_ariaReflectionEnabled; }
 
-    void setResourceLoadStatisticsDebugMode(bool isEnabled) { m_resourceLoadStatisticsDebugMode = isEnabled; }
-    bool resourceLoadStatisticsDebugMode() const { return m_resourceLoadStatisticsDebugMode; }
+    void setItpDebugModeEnabled(bool isEnabled) { m_itpDebugMode = isEnabled; }
+    bool itpDebugModeEnabled() const { return m_itpDebugMode; }
 
     void setRestrictedHTTPResponseAccess(bool isEnabled) { m_isRestrictedHTTPResponseAccess = isEnabled; }
     bool restrictedHTTPResponseAccess() const { return m_isRestrictedHTTPResponseAccess; }
@@ -375,7 +375,7 @@ private:
     bool m_webVREnabled { false };
     bool m_accessibilityObjectModelEnabled { false };
     bool m_ariaReflectionEnabled { true };
-    bool m_resourceLoadStatisticsDebugMode { false };
+    bool m_itpDebugMode { false };
     bool m_isRestrictedHTTPResponseAccess { true };
     bool m_crossOriginResourcePolicyEnabled { true };
     bool m_isWebGLCompressedTextureASTCSupportEnabled { false };
index 2b187e1..9b9a6e8 100644 (file)
@@ -765,9 +765,6 @@ shouldEnableTextAutosizingBoost:
 mediaCapabilitiesEnabled:
   initial: false
 
-resourceLoadStatisticsDebugMode:
-  initial: false
-
 clientCoordinatesRelativeToLayoutViewport:
   initial: false
   onChange: setNeedsRecalcStyleInAllFrames
index 98a98f2..6c960a5 100644 (file)
@@ -1,3 +1,29 @@
+2019-01-17  John Wilander  <wilander@apple.com>
+
+        Add infrastructure to enable/disable ITP Debug Mode through Preferences
+        https://bugs.webkit.org/show_bug.cgi?id=193510
+        <rdar://problem/47330969>
+
+        Reviewed by Dean Jackson.
+
+        * NetworkProcess/Classifier/ResourceLoadStatisticsMemoryStore.cpp:
+        (WebKit::ResourceLoadStatisticsMemoryStore::ensurePrevalentResourcesForDebugMode):
+        (WebKit::ResourceLoadStatisticsMemoryStore::setResourceLoadStatisticsDebugMode):
+        (WebKit::ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode):
+            These functions are now suited for runtime switching of ITP Debug Mode.
+        * Shared/WebPreferences.yaml:
+            Changed name from ResourceLoadStatisticsDebugMode to ItpDebugModeEnabled.
+        * UIProcess/API/Cocoa/WKPreferences.mm:
+        (-[WKPreferences _setItpDebugModeEnabled:]):
+        (-[WKPreferences _itpDebugModeEnabled]):
+            New private preferences functions.
+        * UIProcess/API/Cocoa/WKPreferencesPrivate.h:
+        * UIProcess/Cocoa/ResourceLoadStatisticsMemoryStoreCocoa.mm:
+        (WebKit::ResourceLoadStatisticsMemoryStore::registerUserDefaultsIfNeeded):
+            Removed support for old experimental user default. Added a new one that's
+            not connected to any UI, i.e. merely for command line debugging where
+            ITP Debug Mode needs to be on all the time.
+
 2019-01-17  Tim Horton  <timothy_horton@apple.com>
 
         Adopt NSTextCheckingSuppressInitialCapitalizationKey
index 8d62d68..5db4596 100644 (file)
@@ -534,6 +534,9 @@ Vector<String> ResourceLoadStatisticsMemoryStore::ensurePrevalentResourcesForDeb
         auto& manualResourceStatistic = ensureResourceStatisticsForPrimaryDomain(m_debugManualPrevalentResource);
         setPrevalentResource(manualResourceStatistic, ResourceLoadPrevalence::High);
         primaryDomainsToBlock.uncheckedAppend(m_debugManualPrevalentResource);
+#if !RELEASE_LOG_DISABLED
+        RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "Did set %{public}s as prevalent resource for the purposes of ITP Debug Mode.", m_debugManualPrevalentResource.utf8().data());
+#endif
     }
     
     return primaryDomainsToBlock;
@@ -543,24 +546,23 @@ void ResourceLoadStatisticsMemoryStore::setResourceLoadStatisticsDebugMode(bool
 {
     ASSERT(!RunLoop::isMain());
 
+#if !RELEASE_LOG_DISABLED
+    if (enable)
+        RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "Turned ITP Debug Mode on.");
+#endif
+
     m_debugModeEnabled = enable;
     m_debugLoggingEnabled = enable;
 
     ensurePrevalentResourcesForDebugMode();
+    // This will log the current cookie blocking state.
+    if (enable)
+        updateCookieBlocking([]() { });
 }
 
 void ResourceLoadStatisticsMemoryStore::setPrevalentResourceForDebugMode(const String& domain)
 {
-    if (!m_debugModeEnabled)
-        return;
-
     m_debugManualPrevalentResource = domain;
-    auto& resourceStatistic = ensureResourceStatisticsForPrimaryDomain(domain);
-    setPrevalentResource(resourceStatistic, ResourceLoadPrevalence::High);
-
-#if !RELEASE_LOG_DISABLED
-    RELEASE_LOG_INFO(ResourceLoadStatisticsDebug, "Did set %{public}s as prevalent resource for the purposes of ITP Debug Mode.", domain.utf8().data());
-#endif
 }
 
 void ResourceLoadStatisticsMemoryStore::scheduleStatisticsProcessingRequestIfNecessary()
index bbab078..82ddcbc 100644 (file)
@@ -1394,12 +1394,11 @@ ExperimentalPlugInSandboxProfilesEnabled:
   webcoreBinding: RuntimeEnabledFeatures
   webcoreName: experimentalPlugInSandboxProfilesEnabled
 
-ResourceLoadStatisticsDebugMode:
+ItpDebugModeEnabled:
   type: bool
   defaultValue: false
   humanReadableName: "ITP Debug Mode"
   humanReadableDescription: "Intelligent Tracking Prevention Debug Mode"
-  category: internal
   webcoreBinding: RuntimeEnabledFeatures
 
 ServiceWorkersEnabled:
index 3b46ecd..9475df4 100644 (file)
@@ -839,6 +839,16 @@ static WebCore::EditableLinkBehavior toEditableLinkBehavior(_WKEditableLinkBehav
     return _preferences->needsSiteSpecificQuirks();
 }
 
+- (void)_setItpDebugModeEnabled:(BOOL)enabled
+{
+    _preferences->setItpDebugModeEnabled(enabled);
+}
+
+- (BOOL)_itpDebugModeEnabled
+{
+    return _preferences->itpDebugModeEnabled();
+}
+
 #if PLATFORM(MAC)
 - (void)_setJavaEnabledForLocalFiles:(BOOL)enabled
 {
index 63be4d5..d725f32 100644 (file)
@@ -152,6 +152,7 @@ typedef NS_ENUM(NSInteger, _WKEditableLinkBehavior) {
 @property (nonatomic, setter=_setWebAnimationsCSSIntegrationEnabled:) BOOL _webAnimationsCSSIntegrationEnabled WK_API_AVAILABLE(macosx(10.14), ios(WK_IOS_TBA));
 @property (nonatomic, setter=_setDeviceOrientationEventEnabled:) BOOL _deviceOrientationEventEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 @property (nonatomic, setter=_setNeedsSiteSpecificQuirks:) BOOL _needsSiteSpecificQuirks WK_API_AVAILABLE(macosx(10.13.4), ios(WK_IOS_TBA));
+@property (nonatomic, setter=_setItpDebugModeEnabled:) BOOL _itpDebugModeEnabled WK_API_AVAILABLE(macos(WK_MAC_TBA), ios(WK_IOS_TBA));
 
 #if !TARGET_OS_IPHONE
 @property (nonatomic, setter=_setWebGLEnabled:) BOOL _webGLEnabled WK_API_AVAILABLE(macosx(10.13.4));
index 652bc1d..2e868d1 100644 (file)
@@ -46,12 +46,10 @@ void ResourceLoadStatisticsMemoryStore::registerUserDefaultsIfNeeded()
         if (grandfatheringTime > 0_s && grandfatheringTime <= 24_h * 7)
             setGrandfatheringTime(grandfatheringTime);
 
-        setDebugLogggingEnabled([[NSUserDefaults standardUserDefaults] boolForKey:@"ResourceLoadStatisticsDebugLoggingEnabled"]);
-        setResourceLoadStatisticsDebugMode([[NSUserDefaults standardUserDefaults] boolForKey:@"ExperimentalResourceLoadStatisticsDebugMode"]);
+        setResourceLoadStatisticsDebugMode([[NSUserDefaults standardUserDefaults] boolForKey:@"ItpDebugMode"]);
         auto* debugManualPrevalentResource = [[NSUserDefaults standardUserDefaults] stringForKey:@"ResourceLoadStatisticsManualPrevalentResource"];
         if (debugManualPrevalentResource)
             setPrevalentResourceForDebugMode(debugManualPrevalentResource);
-        setStorageAccessPromptsEnabled([[NSUserDefaults standardUserDefaults] boolForKey:@"ExperimentalStorageAccessPromptsEnabled"]);
 
         Seconds cacheMaxAgeCapForPrevalentResources([[NSUserDefaults standardUserDefaults] doubleForKey:@"ResourceLoadStatisticsCacheMaxAgeCap"]);
         if (cacheMaxAgeCapForPrevalentResources > 0_s && cacheMaxAgeCapForPrevalentResources <= 24_h * 365)