Web Inspector: provide a way for inspector to turn on/off ITP debug mode and AdClickA...
authordrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 May 2020 19:51:18 +0000 (19:51 +0000)
committerdrousso@apple.com <drousso@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 4 May 2020 19:51:18 +0000 (19:51 +0000)
https://bugs.webkit.org/show_bug.cgi?id=209763

Reviewed by Brian Burg.

Source/JavaScriptCore:

* inspector/protocol/Page.json:
Add new enum values to `Page.Setting`:
 - `AdClickAttributionDebugModeEnabled`
 - `ITPDebugModeEnabled`

Source/WebCore:

Tests: inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled.html
       inspector/page/overrideSetting-ITPDebugModeEnabled.html

* inspector/agents/InspectorPageAgent.cpp:
(WebCore::InspectorPageAgent::disable):
(WebCore::InspectorPageAgent::overrideSetting):

* inspector/InspectorClient.h:
(WebCore::InspectorClient::setDeveloperPreferenceOverride): Added.
(WebCore::InspectorClient::setMockCaptureDevicesEnabledOverride): Deleted.

Source/WebInspectorUI:

* UserInterface/Base/Main.js:
(WI._handleDeviceSettingsTabBarButtonClicked):
Add a new section to the device settings popover:

    Enable: [ ] ITP Debug Mode
            [ ] Ad Click Attribution Debug Mode

* Localizations/en.lproj/localizedStrings.js:

Source/WebKit:

Generalize the `setMockCaptureDevicesEnabledOverride` to be `setDeveloperPreferenceOverride`
that uses an enum `WebCore::InspectorClient::DeveloperPreference` to know what to do.

Communicate with the NetworkProcess (from the WebProcess via the UIProcess) in the case of:
 - `AdClickAttributionDebugModeEnabled`
 - `ITPDebugModeEnabled`

* WebProcess/Inspector/WebInspectorClient.h:
* WebProcess/Inspector/WebInspectorClient.cpp:
(WebKit::WebInspectorClient::setDeveloperPreferenceOverride): Added.
(WebKit::WebInspectorClient::setMockCaptureDevicesEnabledOverride): Deleted.
* WebProcess/Inspector/WebInspector.h:
* WebProcess/Inspector/WebInspector.cpp:
(WebKit::WebInspector::setDeveloperPreferenceOverride): Added.
(WebKit::WebInspector::setMockCaptureDevicesEnabledOverride): Deleted.

* UIProcess/Inspector/WebInspectorProxy.messages.in:
* UIProcess/Inspector/WebInspectorProxy.h:
* UIProcess/Inspector/WebInspectorProxy.cpp:
(WebKit::WebInspectorProxy::setDeveloperPreferenceOverride): Added.
(WebKit::WebInspectorProxy::setMockCaptureDevicesEnabledOverride): Deleted.
* UIProcess/WebsiteData/WebsiteDataStore.h:
* UIProcess/WebsiteData/WebsiteDataStore.cpp:
(WebKit::WebsiteDataStore::setAdClickAttributionDebugMode): Added.
* UIProcess/Network/NetworkProcessProxy.h:
* UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::setAdClickAttributionDebugMode): Added.

* NetworkProcess/NetworkProcess.messages.in:
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::initializeNetworkProcess):
(WebKit::NetworkProcess::setAdClickAttributionDebugMode): Added.
* NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
(WebKit::ResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode):

LayoutTests:

* inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled.html: Added.
* inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled-expected.txt: Added.
* inspector/page/overrideSetting-ITPDebugModeEnabled.html: Added.
* inspector/page/overrideSetting-ITPDebugModeEnabled-expected.txt: Added.

* TestExpectations:
* platform/wk2/TestExpectations:

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

31 files changed:
LayoutTests/ChangeLog
LayoutTests/TestExpectations
LayoutTests/inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled-expected.txt [new file with mode: 0644]
LayoutTests/inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled.html [new file with mode: 0644]
LayoutTests/inspector/page/overrideSetting-ITPDebugModeEnabled-expected.txt [new file with mode: 0644]
LayoutTests/inspector/page/overrideSetting-ITPDebugModeEnabled.html [new file with mode: 0644]
LayoutTests/platform/wk2/TestExpectations
Source/JavaScriptCore/ChangeLog
Source/JavaScriptCore/inspector/protocol/Page.json
Source/WebCore/ChangeLog
Source/WebCore/inspector/InspectorClient.h
Source/WebCore/inspector/agents/InspectorPageAgent.cpp
Source/WebInspectorUI/ChangeLog
Source/WebInspectorUI/Localizations/en.lproj/localizedStrings.js
Source/WebInspectorUI/UserInterface/Base/Main.js
Source/WebKit/ChangeLog
Source/WebKit/NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp
Source/WebKit/NetworkProcess/NetworkProcess.cpp
Source/WebKit/NetworkProcess/NetworkProcess.h
Source/WebKit/NetworkProcess/NetworkProcess.messages.in
Source/WebKit/UIProcess/Inspector/WebInspectorProxy.cpp
Source/WebKit/UIProcess/Inspector/WebInspectorProxy.h
Source/WebKit/UIProcess/Inspector/WebInspectorProxy.messages.in
Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
Source/WebKit/UIProcess/Network/NetworkProcessProxy.h
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.cpp
Source/WebKit/UIProcess/WebsiteData/WebsiteDataStore.h
Source/WebKit/WebProcess/Inspector/WebInspector.cpp
Source/WebKit/WebProcess/Inspector/WebInspector.h
Source/WebKit/WebProcess/Inspector/WebInspectorClient.cpp
Source/WebKit/WebProcess/Inspector/WebInspectorClient.h

index 1b11808..04e4d6a 100644 (file)
@@ -1,3 +1,18 @@
+2020-05-04  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: provide a way for inspector to turn on/off ITP debug mode and AdClickAttribution debug mode
+        https://bugs.webkit.org/show_bug.cgi?id=209763
+
+        Reviewed by Brian Burg.
+
+        * inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled.html: Added.
+        * inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled-expected.txt: Added.
+        * inspector/page/overrideSetting-ITPDebugModeEnabled.html: Added.
+        * inspector/page/overrideSetting-ITPDebugModeEnabled-expected.txt: Added.
+
+        * TestExpectations:
+        * platform/wk2/TestExpectations:
+
 2020-05-04  Guillem Vinals  <gvinals@apple.com>
 
         WebGPU: Textures should be able to have OUTPUT_ATTACHEMENT | SAMPLED usage flags
index 27e2b0a..bae37c4 100644 (file)
@@ -976,6 +976,10 @@ inspector/runtime/callFunctionOn-emulateUserGesture-userIsInteracting.html [ Ski
 # Target domain is only present in WK2.
 http/tests/inspector/target [ Skip ]
 
+# ITP and AdClickAttribution are WK2 only.
+inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled.html [ Skip ]
+inspector/page/overrideSetting-ITPDebugModeEnabled.html [ Skip ]
+
 # These conformance tests are no longer in sync with the latest specification
 # and expect compareDocumentPosition() to return:
 # DOCUMENT_POSITION_IMPLEMENTATION_SPECIFIC | DOCUMENT_POSITION_DISCONNECTED
diff --git a/LayoutTests/inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled-expected.txt b/LayoutTests/inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled-expected.txt
new file mode 100644 (file)
index 0000000..1f15449
--- /dev/null
@@ -0,0 +1,9 @@
+CONSOLE MESSAGE: [Ad Click Attribution] Turned Debug Mode on.
+Tests for the Page.overrideSetting command.
+
+
+== Running test suite: Page.overrideSetting
+-- Running test case: Page.overrideSetting.AdClickAttributionDebugModeEnabled
+Enabling ad click attribution debug mode...
+PASS: Should broadcast at least one console message.
+
diff --git a/LayoutTests/inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled.html b/LayoutTests/inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled.html
new file mode 100644 (file)
index 0000000..fadf11d
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Page.overrideSetting");
+
+    suite.addTestCase({
+        name: "Page.overrideSetting.AdClickAttributionDebugModeEnabled",
+        description: "Test that changing whether ad click attribution debug mode is enabled has an effect.",
+        test(resolve, reject) {
+            let listener = WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, (event) => {
+                let {message} = event.data;
+                if (message.source !== WI.ConsoleMessage.MessageSource.AdClickAttribution)
+                    return;
+
+                InspectorTest.pass("Should broadcast at least one console message.");
+
+                WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.MessageAdded, listener);
+                resolve();
+            });
+
+            InspectorTest.log("Enabling ad click attribution debug mode...");
+            PageAgent.overrideSetting(InspectorBackend.Enum.Page.Setting.AdClickAttributionDebugModeEnabled, true).catch(reject);
+        },
+    });
+
+    suite.runTestCasesAndFinish();
+}
+
+</script>
+</head>
+<body onload="runTest()">
+    <p>Tests for the Page.overrideSetting command.</p>
+</body>
+</html>
diff --git a/LayoutTests/inspector/page/overrideSetting-ITPDebugModeEnabled-expected.txt b/LayoutTests/inspector/page/overrideSetting-ITPDebugModeEnabled-expected.txt
new file mode 100644 (file)
index 0000000..2b6d7ab
--- /dev/null
@@ -0,0 +1,11 @@
+CONSOLE MESSAGE: [ITP] Turned Debug Mode on.
+CONSOLE MESSAGE: [ITP] Applying cross-site tracking restrictions to: [3rdpartytestwebkit.org].
+CONSOLE MESSAGE: [ITP] Done applying cross-site tracking restrictions.
+Tests for the Page.overrideSetting command.
+
+
+== Running test suite: Page.overrideSetting
+-- Running test case: Page.overrideSetting.ITPDebugModeEnabled
+Enabling ITP debug mode...
+PASS: Should broadcast at least one console message.
+
diff --git a/LayoutTests/inspector/page/overrideSetting-ITPDebugModeEnabled.html b/LayoutTests/inspector/page/overrideSetting-ITPDebugModeEnabled.html
new file mode 100644 (file)
index 0000000..5b94346
--- /dev/null
@@ -0,0 +1,38 @@
+<!DOCTYPE html>
+<html>
+<head>
+<script src="../../http/tests/inspector/resources/inspector-test.js"></script>
+<script>
+function test()
+{
+    let suite = InspectorTest.createAsyncSuite("Page.overrideSetting");
+
+    suite.addTestCase({
+        name: "Page.overrideSetting.ITPDebugModeEnabled",
+        description: "Test that changing whether ITP debug mode is enabled has an effect.",
+        test(resolve, reject) {
+            let listener = WI.consoleManager.addEventListener(WI.ConsoleManager.Event.MessageAdded, (event) => {
+                let {message} = event.data;
+                if (message.source !== WI.ConsoleMessage.MessageSource.ITPDebug)
+                    return;
+
+                InspectorTest.pass("Should broadcast at least one console message.");
+
+                WI.consoleManager.removeEventListener(WI.ConsoleManager.Event.MessageAdded, listener);
+                resolve();
+            });
+
+            InspectorTest.log("Enabling ITP debug mode...");
+            PageAgent.overrideSetting(InspectorBackend.Enum.Page.Setting.ITPDebugModeEnabled, true).catch(reject);
+        },
+    });
+
+    suite.runTestCasesAndFinish();
+}
+
+</script>
+</head>
+<body onload="runTest()">
+    <p>Tests for the Page.overrideSetting command.</p>
+</body>
+</html>
index e584f87..7866035 100644 (file)
@@ -770,6 +770,10 @@ inspector/runtime/callFunctionOn-emulateUserGesture-userIsInteracting.html [ Pas
 # Target domain is only present in WebKit2.
 http/tests/inspector/target [ Pass ]
 
+# ITP and AdClickAttribution are WK2 only.
+inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled.html [ Pass ]
+inspector/page/overrideSetting-ITPDebugModeEnabled.html [ Pass ]
+
 # Highlighting marked text ranges from layout tests is only supported in WebKit2.
 editing/input/composition-highlights.html [ Pass ]
 
index f3c32b1..6fbdae7 100644 (file)
@@ -1,3 +1,15 @@
+2020-05-04  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: provide a way for inspector to turn on/off ITP debug mode and AdClickAttribution debug mode
+        https://bugs.webkit.org/show_bug.cgi?id=209763
+
+        Reviewed by Brian Burg.
+
+        * inspector/protocol/Page.json:
+        Add new enum values to `Page.Setting`:
+         - `AdClickAttributionDebugModeEnabled`
+         - `ITPDebugModeEnabled`
+
 2020-05-03  Maciej Stachowiak  <mjs@apple.com>
 
         Remove no longer needed WebKitAdditions include for JavaScriptCorePrefix.h
index 7898081..d27512a 100644 (file)
@@ -7,10 +7,12 @@
         {
             "id": "Setting",
             "type": "string",
-            "description": "List of settings able to be overridden by WebInspector. Keep this in sync with FOR_EACH_INSPECTOR_OVERRIDE_SETTING.",
+            "description": "List of settings able to be overridden by WebInspector.",
             "enum": [
+                "AdClickAttributionDebugModeEnabled",
                 "AuthorAndUserStylesEnabled",
                 "ICECandidateFilteringEnabled",
+                "ITPDebugModeEnabled",
                 "ImagesEnabled",
                 "MediaCaptureRequiresSecureConnection",
                 "MockCaptureDevicesEnabled",
index b052dc2..4060398 100644 (file)
@@ -1,3 +1,21 @@
+2020-05-04  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: provide a way for inspector to turn on/off ITP debug mode and AdClickAttribution debug mode
+        https://bugs.webkit.org/show_bug.cgi?id=209763
+
+        Reviewed by Brian Burg.
+
+        Tests: inspector/page/overrideSetting-AdClickAttributionDebugModeEnabled.html
+               inspector/page/overrideSetting-ITPDebugModeEnabled.html
+
+        * inspector/agents/InspectorPageAgent.cpp:
+        (WebCore::InspectorPageAgent::disable):
+        (WebCore::InspectorPageAgent::overrideSetting):
+
+        * inspector/InspectorClient.h:
+        (WebCore::InspectorClient::setDeveloperPreferenceOverride): Added.
+        (WebCore::InspectorClient::setMockCaptureDevicesEnabledOverride): Deleted.
+
 2020-05-04  Simon Fraser  <simon.fraser@apple.com>
 
         REGRESSION: [ Mac WK1 ] inspector/console/console-api.html is flaky crashing
index 0a537a5..97a47d8 100644 (file)
@@ -64,7 +64,12 @@ public:
     virtual void elementSelectionChanged(bool) { }
     virtual void timelineRecordingChanged(bool) { }
 
-    virtual void setMockCaptureDevicesEnabledOverride(Optional<bool>) { }
+    enum class DeveloperPreference {
+        AdClickAttributionDebugModeEnabled,
+        ITPDebugModeEnabled,
+        MockCaptureDevicesEnabled,
+    };
+    virtual void setDeveloperPreferenceOverride(DeveloperPreference, Optional<bool>) { }
 
 #if ENABLE(REMOTE_INSPECTOR)
     virtual bool allowRemoteInspectionToPageDirectly() const { return false; }
@@ -72,3 +77,16 @@ public:
 };
 
 } // namespace WebCore
+
+namespace WTF {
+
+template<> struct EnumTraits<WebCore::InspectorClient::DeveloperPreference> {
+    using values = EnumValues<
+        WebCore::InspectorClient::DeveloperPreference,
+        WebCore::InspectorClient::DeveloperPreference::AdClickAttributionDebugModeEnabled,
+        WebCore::InspectorClient::DeveloperPreference::ITPDebugModeEnabled,
+        WebCore::InspectorClient::DeveloperPreference::MockCaptureDevicesEnabled
+    >;
+};
+
+} // namespace WTF
index 30ebdd3..a193159 100644 (file)
@@ -86,20 +86,6 @@ namespace WebCore {
 
 using namespace Inspector;
 
-// Keep this in sync with Page.Setting
-#define FOR_EACH_INSPECTOR_OVERRIDE_SETTING(macro) \
-    macro(AuthorAndUserStylesEnabled) \
-    macro(ICECandidateFilteringEnabled) \
-    macro(ImagesEnabled) \
-    macro(MediaCaptureRequiresSecureConnection) \
-    macro(MockCaptureDevicesEnabled) \
-    macro(NeedsSiteSpecificQuirks) \
-    macro(ScriptEnabled) \
-    macro(ShowDebugBorders) \
-    macro(ShowRepaintCounter) \
-    macro(WebRTCEncryptionEnabled) \
-    macro(WebSecurityEnabled)
-
 static bool decodeBuffer(const char* buffer, unsigned size, const String& textEncodingName, String* result)
 {
     if (buffer) {
@@ -386,14 +372,22 @@ void InspectorPageAgent::disable(ErrorString&)
     setEmulatedMedia(unused, emptyString());
     setForcedAppearance(unused, emptyString());
 
-#define DISABLE_INSPECTOR_OVERRIDE_SETTING(name) \
-    m_inspectedPage.settings().set##name##InspectorOverride(WTF::nullopt);
-
-    FOR_EACH_INSPECTOR_OVERRIDE_SETTING(DISABLE_INSPECTOR_OVERRIDE_SETTING)
+    auto& inspectedPageSettings = m_inspectedPage.settings();
+    inspectedPageSettings.setAuthorAndUserStylesEnabledInspectorOverride(WTF::nullopt);
+    inspectedPageSettings.setICECandidateFilteringEnabledInspectorOverride(WTF::nullopt);
+    inspectedPageSettings.setImagesEnabledInspectorOverride(WTF::nullopt);
+    inspectedPageSettings.setMediaCaptureRequiresSecureConnectionInspectorOverride(WTF::nullopt);
+    inspectedPageSettings.setMockCaptureDevicesEnabledInspectorOverride(WTF::nullopt);
+    inspectedPageSettings.setNeedsSiteSpecificQuirksInspectorOverride(WTF::nullopt);
+    inspectedPageSettings.setScriptEnabledInspectorOverride(WTF::nullopt);
+    inspectedPageSettings.setShowDebugBordersInspectorOverride(WTF::nullopt);
+    inspectedPageSettings.setShowRepaintCounterInspectorOverride(WTF::nullopt);
+    inspectedPageSettings.setWebRTCEncryptionEnabledInspectorOverride(WTF::nullopt);
+    inspectedPageSettings.setWebSecurityEnabledInspectorOverride(WTF::nullopt);
 
-#undef DISABLE_INSPECTOR_OVERRIDE_SETTING
-
-    m_client->setMockCaptureDevicesEnabledOverride(WTF::nullopt);
+    m_client->setDeveloperPreferenceOverride(InspectorClient::DeveloperPreference::AdClickAttributionDebugModeEnabled, WTF::nullopt);
+    m_client->setDeveloperPreferenceOverride(InspectorClient::DeveloperPreference::ITPDebugModeEnabled, WTF::nullopt);
+    m_client->setDeveloperPreferenceOverride(InspectorClient::DeveloperPreference::MockCaptureDevicesEnabled, WTF::nullopt);
 }
 
 double InspectorPageAgent::timestamp()
@@ -451,21 +445,65 @@ void InspectorPageAgent::overrideSetting(ErrorString& errorString, const String&
         return;
     }
 
+    auto& inspectedPageSettings = m_inspectedPage.settings();
+
     auto overrideValue = asOptionalBool(value);
     switch (setting.value()) {
-#define CASE_INSPECTOR_OVERRIDE_SETTING(name) \
-    case Inspector::Protocol::Page::Setting::name:                              \
-        m_inspectedPage.settings().set##name##InspectorOverride(overrideValue); \
-        break;                                                                  \
+    case Inspector::Protocol::Page::Setting::AdClickAttributionDebugModeEnabled:
+        m_client->setDeveloperPreferenceOverride(InspectorClient::DeveloperPreference::AdClickAttributionDebugModeEnabled, overrideValue);
+        return;
+
+    case Inspector::Protocol::Page::Setting::AuthorAndUserStylesEnabled:
+        inspectedPageSettings.setAuthorAndUserStylesEnabledInspectorOverride(overrideValue);
+        return;
+
+    case Inspector::Protocol::Page::Setting::ICECandidateFilteringEnabled:
+        inspectedPageSettings.setICECandidateFilteringEnabledInspectorOverride(overrideValue);
+        return;
+
+    case Inspector::Protocol::Page::Setting::ITPDebugModeEnabled:
+        m_client->setDeveloperPreferenceOverride(InspectorClient::DeveloperPreference::ITPDebugModeEnabled, overrideValue);
+        return;
+
+    case Inspector::Protocol::Page::Setting::ImagesEnabled:
+        inspectedPageSettings.setImagesEnabledInspectorOverride(overrideValue);
+        return;
+
+    case Inspector::Protocol::Page::Setting::MediaCaptureRequiresSecureConnection:
+        inspectedPageSettings.setMediaCaptureRequiresSecureConnectionInspectorOverride(overrideValue);
+        return;
+
+    case Inspector::Protocol::Page::Setting::MockCaptureDevicesEnabled:
+        inspectedPageSettings.setMockCaptureDevicesEnabledInspectorOverride(overrideValue);
+        m_client->setDeveloperPreferenceOverride(InspectorClient::DeveloperPreference::MockCaptureDevicesEnabled, overrideValue);
+        return;
+
+    case Inspector::Protocol::Page::Setting::NeedsSiteSpecificQuirks:
+        inspectedPageSettings.setNeedsSiteSpecificQuirksInspectorOverride(overrideValue);
+        return;
+
+    case Inspector::Protocol::Page::Setting::ScriptEnabled:
+        inspectedPageSettings.setScriptEnabledInspectorOverride(overrideValue);
+        return;
 
-    FOR_EACH_INSPECTOR_OVERRIDE_SETTING(CASE_INSPECTOR_OVERRIDE_SETTING)
+    case Inspector::Protocol::Page::Setting::ShowDebugBorders:
+        inspectedPageSettings.setShowDebugBordersInspectorOverride(overrideValue);
+        return;
+
+    case Inspector::Protocol::Page::Setting::ShowRepaintCounter:
+        inspectedPageSettings.setShowRepaintCounterInspectorOverride(overrideValue);
+        return;
 
-#undef CASE_INSPECTOR_OVERRIDE_SETTING
+    case Inspector::Protocol::Page::Setting::WebRTCEncryptionEnabled:
+        inspectedPageSettings.setWebRTCEncryptionEnabledInspectorOverride(overrideValue);
+        return;
+
+    case Inspector::Protocol::Page::Setting::WebSecurityEnabled:
+        inspectedPageSettings.setWebSecurityEnabledInspectorOverride(overrideValue);
+        return;
     }
 
-    // Update the UIProcess / client for particular overrides.
-    if (setting.value() == Inspector::Protocol::Page::Setting::MockCaptureDevicesEnabled)
-        m_client->setMockCaptureDevicesEnabledOverride(overrideValue);
+    ASSERT_NOT_REACHED();
 }
 
 static Inspector::Protocol::Page::CookieSameSitePolicy cookieSameSitePolicyJSON(Cookie::SameSitePolicy policy)
index 5d503d1..ad689d6 100644 (file)
@@ -1,3 +1,19 @@
+2020-05-04  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: provide a way for inspector to turn on/off ITP debug mode and AdClickAttribution debug mode
+        https://bugs.webkit.org/show_bug.cgi?id=209763
+
+        Reviewed by Brian Burg.
+
+        * UserInterface/Base/Main.js:
+        (WI._handleDeviceSettingsTabBarButtonClicked):
+        Add a new section to the device settings popover:
+
+            Enable: [ ] ITP Debug Mode
+                    [ ] Ad Click Attribution Debug Mode
+
+        * Localizations/en.lproj/localizedStrings.js:
+
 2020-05-02  Devin Rousso  <drousso@apple.com>
 
         [CSS Easing 1] implement `jump-*` step positions
index 6c89f83..e6d66b3 100644 (file)
@@ -94,6 +94,7 @@ localizedStrings["Accessibility"] = "Accessibility";
 localizedStrings["Action"] = "Action";
 /* Tooltip for a time range bar that represents when a CSS animation/transition is running */
 localizedStrings["Active"] = "Active";
+localizedStrings["Ad Click Attribution Debug Mode"] = "Ad Click Attribution Debug Mode";
 localizedStrings["Add"] = "Add";
 localizedStrings["Add %s Rule"] = "Add %s Rule";
 localizedStrings["Add Action"] = "Add Action";
@@ -506,6 +507,7 @@ localizedStrings["Enable Rule"] = "Enable Rule";
 localizedStrings["Enable all breakpoints (%s)"] = "Enable all breakpoints (%s)";
 localizedStrings["Enable paint flashing"] = "Enable paint flashing";
 localizedStrings["Enable source maps"] = "Enable source maps";
+localizedStrings["Enable:"] = "Enable:";
 localizedStrings["Enabled"] = "Enabled";
 localizedStrings["Encoded"] = "Encoded";
 localizedStrings["Encoding"] = "Encoding";
@@ -658,6 +660,7 @@ localizedStrings["Host"] = "Host";
 localizedStrings["ICO"] = "ICO";
 localizedStrings["IP"] = "IP";
 localizedStrings["IP Address"] = "IP Address";
+localizedStrings["ITP Debug Mode"] = "ITP Debug Mode";
 localizedStrings["Identity"] = "Identity";
 localizedStrings["Idle"] = "Idle";
 localizedStrings["If the URL of any script matches one of the regular expression patterns below, any pauses that would have happened in that script will be deferred until execution has continued to outside of that script."] = "If the URL of any script matches one of the regular expression patterns below, any pauses that would have happened in that script will be deferred until execution has continued to outside of that script.";
index 4bc62b3..434baee 100644 (file)
@@ -2275,6 +2275,15 @@ WI._handleDeviceSettingsTabBarButtonClicked = function(event)
             ],
         },
         {
+            name: WI.UIString("Enable:"),
+            columns: [
+                [
+                    {name: WI.UIString("ITP Debug Mode"), setting: InspectorBackend.Enum.Page.Setting.ITPDebugModeEnabled, value: true},
+                    {name: WI.UIString("Ad Click Attribution Debug Mode"), setting: InspectorBackend.Enum.Page.Setting.AdClickAttributionDebugModeEnabled, value: true},
+                ],
+            ],
+        },
+        {
             name: WI.UIString("%s:").format(WI.unlocalizedString("WebRTC")),
             columns: [
                 [
index 6db7740..4f7329f 100644 (file)
@@ -1,3 +1,46 @@
+2020-05-04  Devin Rousso  <drousso@apple.com>
+
+        Web Inspector: provide a way for inspector to turn on/off ITP debug mode and AdClickAttribution debug mode
+        https://bugs.webkit.org/show_bug.cgi?id=209763
+
+        Reviewed by Brian Burg.
+
+        Generalize the `setMockCaptureDevicesEnabledOverride` to be `setDeveloperPreferenceOverride`
+        that uses an enum `WebCore::InspectorClient::DeveloperPreference` to know what to do.
+
+        Communicate with the NetworkProcess (from the WebProcess via the UIProcess) in the case of:
+         - `AdClickAttributionDebugModeEnabled`
+         - `ITPDebugModeEnabled`
+
+        * WebProcess/Inspector/WebInspectorClient.h:
+        * WebProcess/Inspector/WebInspectorClient.cpp:
+        (WebKit::WebInspectorClient::setDeveloperPreferenceOverride): Added.
+        (WebKit::WebInspectorClient::setMockCaptureDevicesEnabledOverride): Deleted.
+        * WebProcess/Inspector/WebInspector.h:
+        * WebProcess/Inspector/WebInspector.cpp:
+        (WebKit::WebInspector::setDeveloperPreferenceOverride): Added.
+        (WebKit::WebInspector::setMockCaptureDevicesEnabledOverride): Deleted.
+
+        * UIProcess/Inspector/WebInspectorProxy.messages.in:
+        * UIProcess/Inspector/WebInspectorProxy.h:
+        * UIProcess/Inspector/WebInspectorProxy.cpp:
+        (WebKit::WebInspectorProxy::setDeveloperPreferenceOverride): Added.
+        (WebKit::WebInspectorProxy::setMockCaptureDevicesEnabledOverride): Deleted.
+        * UIProcess/WebsiteData/WebsiteDataStore.h:
+        * UIProcess/WebsiteData/WebsiteDataStore.cpp:
+        (WebKit::WebsiteDataStore::setAdClickAttributionDebugMode): Added.
+        * UIProcess/Network/NetworkProcessProxy.h:
+        * UIProcess/Network/NetworkProcessProxy.cpp:
+        (WebKit::NetworkProcessProxy::setAdClickAttributionDebugMode): Added.
+
+        * NetworkProcess/NetworkProcess.messages.in:
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::initializeNetworkProcess):
+        (WebKit::NetworkProcess::setAdClickAttributionDebugMode): Added.
+        * NetworkProcess/Classifier/ResourceLoadStatisticsStore.cpp:
+        (WebKit::ResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode):
+
 2020-05-04  Chris Dumez  <cdumez@apple.com>
 
         [iOS] Unable to take RunningBoard process assertions in the iOS Simulator
index ab56a80..3c86a34 100644 (file)
@@ -292,6 +292,9 @@ void ResourceLoadStatisticsStore::setResourceLoadStatisticsDebugMode(bool enable
 {
     ASSERT(!RunLoop::isMain());
 
+    if (m_debugModeEnabled == enable)
+        return;
+
     m_debugModeEnabled = enable;
     m_debugLoggingEnabled = enable;
 
index d6bba35..92e9fde 100644 (file)
@@ -335,7 +335,7 @@ void NetworkProcess::initializeNetworkProcess(NetworkProcessCreationParameters&&
     m_isITPDatabaseEnabled = parameters.shouldEnableITPDatabase;
 #endif
 
-    WebCore::RuntimeEnabledFeatures::sharedFeatures().setAdClickAttributionDebugModeEnabled(parameters.enableAdClickAttributionDebugMode);
+    setAdClickAttributionDebugMode(parameters.enableAdClickAttributionDebugMode);
 
     SandboxExtension::consumePermanently(parameters.defaultDataStoreParameters.networkSessionParameters.resourceLoadStatisticsParameters.directoryExtensionHandle);
 
@@ -1357,6 +1357,21 @@ void NetworkProcess::setToSameSiteStrictCookiesForTesting(PAL::SessionID session
 }
 #endif // ENABLE(RESOURCE_LOAD_STATISTICS)
 
+void NetworkProcess::setAdClickAttributionDebugMode(bool debugMode)
+{
+    if (RuntimeEnabledFeatures::sharedFeatures().adClickAttributionDebugModeEnabled() == debugMode)
+        return;
+
+    RuntimeEnabledFeatures::sharedFeatures().setAdClickAttributionDebugModeEnabled(debugMode);
+
+    String message = debugMode ? "[Ad Click Attribution] Turned Debug Mode on."_s : "[Ad Click Attribution] Turned Debug Mode off."_s;
+    for (auto& networkConnectionToWebProcess : m_webProcessConnections.values()) {
+        if (networkConnectionToWebProcess->sessionID().isEphemeral())
+            continue;
+        networkConnectionToWebProcess->broadcastConsoleMessage(MessageSource::AdClickAttribution, MessageLevel::Info, message);
+    }
+}
+
 void NetworkProcess::preconnectTo(PAL::SessionID sessionID, const URL& url, const String& userAgent, WebCore::StoredCredentialsPolicy storedCredentialsPolicy, Optional<NavigatingToAppBoundDomain> isNavigatingToAppBoundDomain)
 {
 #if ENABLE(SERVER_PRECONNECT)
index addafb6..87ee467 100644 (file)
@@ -269,6 +269,8 @@ public:
     void setToSameSiteStrictCookiesForTesting(PAL::SessionID, const WebCore::RegistrableDomain&, CompletionHandler<void()>&&);
 #endif
 
+    void setAdClickAttributionDebugMode(bool);
+
     using CacheStorageRootPathCallback = CompletionHandler<void(String&&)>;
     void cacheStorageRootPath(PAL::SessionID, CacheStorageRootPathCallback&&);
 
index 4b93a7d..15e1764 100644 (file)
@@ -148,6 +148,8 @@ messages -> NetworkProcess LegacyReceiver {
     SetToSameSiteStrictCookiesForTesting(PAL::SessionID sessionID, WebCore::RegistrableDomain domain) -> () Async
 #endif
 
+    SetAdClickAttributionDebugMode(bool debugMode)
+
     SetSessionIsControlledByAutomation(PAL::SessionID sessionID, bool controlled);
 
     RegisterURLSchemeAsSecure(String scheme)
index b943488..b7eae1e 100644 (file)
@@ -620,16 +620,28 @@ void WebInspectorProxy::timelineRecordingChanged(bool active)
     m_isProfilingPage = active;
 }
 
-void WebInspectorProxy::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
+void WebInspectorProxy::setDeveloperPreferenceOverride(WebCore::InspectorClient::DeveloperPreference developerPreference, Optional<bool> overrideValue)
 {
+    switch (developerPreference) {
+    case InspectorClient::DeveloperPreference::AdClickAttributionDebugModeEnabled:
+        if (m_inspectedPage)
+            m_inspectedPage->websiteDataStore().setAdClickAttributionDebugMode(overrideValue && overrideValue.value());
+        return;
+
+    case InspectorClient::DeveloperPreference::ITPDebugModeEnabled:
+        if (m_inspectedPage)
+            m_inspectedPage->websiteDataStore().setResourceLoadStatisticsDebugMode(overrideValue && overrideValue.value());
+        return;
+
+    case InspectorClient::DeveloperPreference::MockCaptureDevicesEnabled:
 #if ENABLE(MEDIA_STREAM)
-    if (!m_inspectedPage)
+        if (m_inspectedPage)
+            m_inspectedPage->setMockCaptureDevicesEnabledOverride(overrideValue);
+#endif // ENABLE(MEDIA_STREAM)
         return;
+    }
 
-    m_inspectedPage->setMockCaptureDevicesEnabledOverride(enabled);
-#else
-    UNUSED_PARAM(enabled);
-#endif
+    ASSERT_NOT_REACHED();
 }
 
 void WebInspectorProxy::setDiagnosticLoggingAvailable(bool available)
index eb0b81e..8a697d6 100644 (file)
@@ -33,6 +33,7 @@
 #include "WebInspectorUtilities.h"
 #include <JavaScriptCore/InspectorFrontendChannel.h>
 #include <WebCore/FloatRect.h>
+#include <WebCore/InspectorClient.h>
 #include <WebCore/InspectorFrontendClient.h>
 #include <wtf/Forward.h>
 #include <wtf/RefPtr.h>
@@ -242,7 +243,7 @@ private:
     void showCertificate(const WebCore::CertificateInfo&);
     void elementSelectionChanged(bool);
     void timelineRecordingChanged(bool);
-    void setMockCaptureDevicesEnabledOverride(Optional<bool>);
+    void setDeveloperPreferenceOverride(WebCore::InspectorClient::DeveloperPreference, Optional<bool>);
 
     void save(const String& filename, const String& content, bool base64Encoded, bool forceSaveAs);
     void append(const String& filename, const String& content);
index 84a630a..bb31dac 100644 (file)
@@ -39,7 +39,7 @@ messages -> WebInspectorProxy {
     ShowCertificate(WebCore::CertificateInfo certificateInfo)
     ElementSelectionChanged(bool active)
     TimelineRecordingChanged(bool active)
-    SetMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
+    SetDeveloperPreferenceOverride(WebCore::InspectorClient::DeveloperPreference developerPreference, Optional<bool> overrideValue)
 
     Save(String filename, String content, bool base64Encoded, bool forceSaveAs)
     Append(String filename, String content)
index 7b2ff8b..4fca208 100644 (file)
@@ -1167,6 +1167,14 @@ void NetworkProcessProxy::setToSameSiteStrictCookiesForTesting(PAL::SessionID se
 }
 #endif // ENABLE(RESOURCE_LOAD_STATISTICS)
 
+void NetworkProcessProxy::setAdClickAttributionDebugMode(bool debugMode)
+{
+    if (!canSendMessage())
+        return;
+
+    send(Messages::NetworkProcess::SetAdClickAttributionDebugMode(debugMode), 0);
+}
+
 void NetworkProcessProxy::sendProcessWillSuspendImminentlyForTesting()
 {
     if (canSendMessage())
index 37c7564..e07cf99 100644 (file)
@@ -181,6 +181,8 @@ public:
     void setFirstPartyWebsiteDataRemovalModeForTesting(PAL::SessionID, WebCore::FirstPartyWebsiteDataRemovalMode, CompletionHandler<void()>&&);
     void setToSameSiteStrictCookiesForTesting(PAL::SessionID, const RegistrableDomain&, CompletionHandler<void()>&&);
 #endif
+
+    void setAdClickAttributionDebugMode(bool);
     
     void synthesizeAppIsBackground(bool background);
 
index 693d9b1..e36376c 100644 (file)
@@ -2144,6 +2144,12 @@ void WebsiteDataStore::isResourceLoadStatisticsEphemeral(CompletionHandler<void(
     completionHandler(false);
 }
 
+void WebsiteDataStore::setAdClickAttributionDebugMode(bool enabled)
+{
+    for (auto& processPool : processPools())
+        processPool->ensureNetworkProcess().setAdClickAttributionDebugMode(enabled);
+}
+
 #if ENABLE(RESOURCE_LOAD_STATISTICS)
 void WebsiteDataStore::logTestingEvent(const String& event)
 {
index 202576c..cd67eb5 100644 (file)
@@ -125,6 +125,8 @@ public:
     void setResourceLoadStatisticsDebugMode(bool, CompletionHandler<void()>&&);
     void isResourceLoadStatisticsEphemeral(CompletionHandler<void(bool)>&&) const;
 
+    void setAdClickAttributionDebugMode(bool);
+
     uint64_t perOriginStorageQuota() const { return m_resolvedConfiguration->perOriginStorageQuota(); }
     uint64_t perThirdPartyOriginStorageQuota() const;
     const String& cacheStorageDirectory() const { return m_resolvedConfiguration->cacheStorageDirectory(); }
index 4858182..9a30629 100644 (file)
@@ -281,9 +281,9 @@ void WebInspector::timelineRecordingChanged(bool active)
     WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::TimelineRecordingChanged(active), m_page->identifier());
 }
 
-void WebInspector::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
+void WebInspector::setDeveloperPreferenceOverride(InspectorClient::DeveloperPreference developerPreference, Optional<bool> overrideValue)
 {
-    WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SetMockCaptureDevicesEnabledOverride(enabled), m_page->identifier());
+    WebProcess::singleton().parentProcessConnection()->send(Messages::WebInspectorProxy::SetDeveloperPreferenceOverride(developerPreference, overrideValue), m_page->identifier());
 }
 
 bool WebInspector::canAttachWindow()
index 26b89e5..55cc3fa 100644 (file)
@@ -29,6 +29,7 @@
 #include "Connection.h"
 #include "MessageReceiver.h"
 #include <WebCore/FrameIdentifier.h>
+#include <WebCore/InspectorClient.h>
 #include <wtf/Noncopyable.h>
 #include <wtf/text/WTFString.h>
 
@@ -74,7 +75,7 @@ public:
     void stopElementSelection();
     void elementSelectionChanged(bool);
     void timelineRecordingChanged(bool);
-    void setMockCaptureDevicesEnabledOverride(Optional<bool>);
+    void setDeveloperPreferenceOverride(WebCore::InspectorClient::DeveloperPreference, Optional<bool>);
 
     void setFrontendConnection(IPC::Attachment);
 
index 0b06801..eb37263 100644 (file)
@@ -218,10 +218,10 @@ void WebInspectorClient::timelineRecordingChanged(bool active)
         m_page->inspector()->timelineRecordingChanged(active);
 }
 
-void WebInspectorClient::setMockCaptureDevicesEnabledOverride(Optional<bool> enabled)
+void WebInspectorClient::setDeveloperPreferenceOverride(WebCore::InspectorClient::DeveloperPreference developerPreference, Optional<bool> overrideValue)
 {
     if (m_page->inspector())
-        m_page->inspector()->setMockCaptureDevicesEnabledOverride(enabled);
+        m_page->inspector()->setDeveloperPreferenceOverride(developerPreference, overrideValue);
 }
 
 void WebInspectorClient::willMoveToPage(PageOverlay&, Page* page)
index 27c3ee1..19af062 100644 (file)
@@ -73,7 +73,7 @@ private:
     bool overridesShowPaintRects() const override { return true; }
     void showPaintRect(const WebCore::FloatRect&) override;
 
-    void setMockCaptureDevicesEnabledOverride(Optional<bool>) final;
+    void setDeveloperPreferenceOverride(WebCore::InspectorClient::DeveloperPreference, Optional<bool>) final;
 
     // PageOverlay::Client
     void willMoveToPage(WebCore::PageOverlay&, WebCore::Page*) override;