Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 01329a31ae593125485a4f2bcac7d76981fbcf2f
      
https://github.com/WebKit/WebKit/commit/01329a31ae593125485a4f2bcac7d76981fbcf2f
  Author: Wenson Hsieh <[email protected]>
  Date:   2023-07-10 (Mon, 10 Jul 2023)

  Changed paths:
    M Source/WebKit/NetworkProcess/NetworkProcess.h
    M Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h
    M 
Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.serialization.in
    M Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm
    M Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm
    M Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp
    M Tools/TestWebKitAPI/Tests/WebKit/AdvancedPrivacyProtections.mm
    M Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm
    M Tools/TestWebKitAPI/cocoa/TestWKWebView.h
    M Tools/TestWebKitAPI/cocoa/TestWKWebView.mm

  Log Message:
  -----------
  [macOS] Network connection logs should be silenced in Safari private browsing 
mode
https://bugs.webkit.org/show_bug.cgi?id=259022
rdar://111586011

Reviewed by Youenn Fablet.

In Safari (and other browsers) on iOS, we avoid logging any information about 
network connections —
even with redaction — in private browsing (i.e. when using an ephemeral data 
store). We achieve this
by passing in `nw_context_privacy_level_silent` when configuring 
`NSURLSessionConfiguration` in the
network process.

However, this currently doesn't work on macOS because the logic for determining 
whether or not the
parent of the networking process is a full web browser 
(`isParentProcessAFullWebBrowser()`) only
takes the `com.apple.developer.web-browser` entitlement into account, which is 
iOS-specific.

In contrast, `isFullWebBrowserOrRunningTest()` (also implemented in 
`DefaultWebBrowserChecks.mm`)
uses the above entitlement check on iOS, and checks whether the application can 
open HTTP-family
URLs on macOS. Since this function is intended to be invoked from the 
application process, we add a
flag to `NetworkProcessCreationParameters` to compute and send this over to the 
network process upon
initialization.

Test: WKWebsiteDataStore.DoNotLogNetworkConnectionsInEphemeralSessions

* Source/WebKit/NetworkProcess/NetworkProcess.h:
(WebKit::NetworkProcess::isParentProcessFullWebBrowserOrRunningTest const):
* Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.h:
* 
Source/WebKit/NetworkProcess/NetworkProcessCreationParameters.serialization.in:

See above for more details.

* Source/WebKit/NetworkProcess/cocoa/NetworkProcessCocoa.mm:
(WebKit::NetworkProcess::platformInitializeNetworkProcessCocoa):
* Source/WebKit/NetworkProcess/cocoa/NetworkSessionCocoa.mm:
(WebKit::SessionWrapper::initialize):

Implement the main fix here — replace 
`isParentProcessAFullWebBrowser(networkProcess)` with
`networkProcess.isParentProcessFullWebBrowserOrRunningTest()`.

(WebKit::NetworkSessionCocoa::NetworkSessionCocoa):
(WebKit::NetworkSessionCocoa::sessionWrapperForTask):
(WebKit::NetworkSessionCocoa::removeNetworkWebsiteData):

Add a few FIXMEs referencing the fact that the other existing 
`isParentProcessAFullWebBrowser`
checks in this file don't work on macOS.

* Source/WebKit/UIProcess/Network/NetworkProcessProxy.cpp:
(WebKit::NetworkProcessProxy::sendCreationParametersToNewProcess):
* Tools/TestWebKitAPI/Tests/WebKit/AdvancedPrivacyProtections.mm:
(-[TestWKWebView collectLogsForNewConnections]): Deleted.
* Tools/TestWebKitAPI/Tests/WebKitCocoa/WKWebsiteDatastore.mm:

Add an API test to verify that no network connection logging is saved when 
navigating in an
ephemeral session.

* Tools/TestWebKitAPI/cocoa/TestWKWebView.h:
* Tools/TestWebKitAPI/cocoa/TestWKWebView.mm:
(-[TestWKWebView collectLogsForNewConnections]):

Move this testing helper into `TestWKWebView`, so that we can invoke it from 
API tests across
different files.

Canonical link: https://commits.webkit.org/265904@main


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to