Title: [229201] trunk/Source/WebKit
Revision
229201
Author
[email protected]
Date
2018-03-03 15:27:18 -0800 (Sat, 03 Mar 2018)

Log Message

Notify the NetworkProcess when a session is servicing an automation client
https://bugs.webkit.org/show_bug.cgi?id=183306
<rdar://problem/37835783>

Reviewed by Brian Burg.

Network loads servicing WebDriver are done through an ephemeral session. While this is great
for protecting a developer's machine from sharing state with test runs, it has the unintended
effect of blocking certain logging operations.

We do not log content in ephemeral sessions to protect user privacy. However, ephemeral sessions
generated by WebDriver should participate in logging so that proper testing (with logging) can
be done.

This patch signals the NetworkProcess when an ephemeral session (created for automation purposes)
is created, so that it can allow logging.

* NetworkProcess/NetworkProcess.cpp:
(WebKit::NetworkProcess::destroySession): Remove controlled-by-automation entry.
(WebKit::NetworkProcess::sessionIsControlledByAutomation const): Added.
(WebKit::NetworkProcess::setSessionIsControlledByAutomation): Added.
* NetworkProcess/NetworkProcess.h:
* NetworkProcess/NetworkProcess.messages.in:
* NetworkProcess/NetworkResourceLoader.cpp:
(WebKit::NetworkResourceLoader::isAlwaysOnLoggingAllowed const): Checks if the relevant session
is servicing an automation client, and returns true if it is.
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::WebPageProxy): Signal the network process if this page is being created
for an automation client.

Modified Paths

Diff

Modified: trunk/Source/WebKit/ChangeLog (229200 => 229201)


--- trunk/Source/WebKit/ChangeLog	2018-03-03 20:13:42 UTC (rev 229200)
+++ trunk/Source/WebKit/ChangeLog	2018-03-03 23:27:18 UTC (rev 229201)
@@ -1,3 +1,35 @@
+2018-03-03  Brent Fulgham  <[email protected]>
+
+        Notify the NetworkProcess when a session is servicing an automation client
+        https://bugs.webkit.org/show_bug.cgi?id=183306
+        <rdar://problem/37835783>
+
+        Reviewed by Brian Burg.
+
+        Network loads servicing WebDriver are done through an ephemeral session. While this is great
+        for protecting a developer's machine from sharing state with test runs, it has the unintended
+        effect of blocking certain logging operations.
+
+        We do not log content in ephemeral sessions to protect user privacy. However, ephemeral sessions
+        generated by WebDriver should participate in logging so that proper testing (with logging) can
+        be done.
+
+        This patch signals the NetworkProcess when an ephemeral session (created for automation purposes)
+        is created, so that it can allow logging.
+
+        * NetworkProcess/NetworkProcess.cpp:
+        (WebKit::NetworkProcess::destroySession): Remove controlled-by-automation entry.
+        (WebKit::NetworkProcess::sessionIsControlledByAutomation const): Added.
+        (WebKit::NetworkProcess::setSessionIsControlledByAutomation): Added.
+        * NetworkProcess/NetworkProcess.h:
+        * NetworkProcess/NetworkProcess.messages.in:
+        * NetworkProcess/NetworkResourceLoader.cpp:
+        (WebKit::NetworkResourceLoader::isAlwaysOnLoggingAllowed const): Checks if the relevant session
+        is servicing an automation client, and returns true if it is.
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::WebPageProxy): Signal the network process if this page is being created
+        for an automation client.
+
 2018-03-02  Yusuke Suzuki  <[email protected]>
 
         [WTF] Remove RunLoop and RunLoop::Timer's interface using double as seconds

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp (229200 => 229201)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2018-03-03 20:13:42 UTC (rev 229200)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.cpp	2018-03-03 23:27:18 UTC (rev 229201)
@@ -325,6 +325,7 @@
 void NetworkProcess::destroySession(PAL::SessionID sessionID)
 {
     SessionTracker::destroySession(sessionID);
+    m_sessionsControlledByAutomation.remove(sessionID);
 }
 
 void NetworkProcess::grantSandboxExtensionsToStorageProcessForBlobs(const Vector<String>& filenames, Function<void ()>&& completionHandler)
@@ -400,6 +401,19 @@
 }
 #endif
 
+bool NetworkProcess::sessionIsControlledByAutomation(PAL::SessionID sessionID) const
+{
+    return m_sessionsControlledByAutomation.contains(sessionID);
+}
+
+void NetworkProcess::setSessionIsControlledByAutomation(PAL::SessionID sessionID, bool controlled)
+{
+    if (controlled)
+        m_sessionsControlledByAutomation.add(sessionID);
+    else
+        m_sessionsControlledByAutomation.remove(sessionID);
+}
+
 static void fetchDiskCacheEntries(PAL::SessionID sessionID, OptionSet<WebsiteDataFetchOption> fetchOptions, Function<void (Vector<WebsiteData::Entry>)>&& completionHandler)
 {
     if (auto* cache = NetworkProcess::singleton().cache()) {

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.h (229200 => 229201)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2018-03-03 20:13:42 UTC (rev 229200)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.h	2018-03-03 23:27:18 UTC (rev 229201)
@@ -34,6 +34,7 @@
 #include <pal/SessionID.h>
 #include <wtf/Forward.h>
 #include <wtf/Function.h>
+#include <wtf/HashSet.h>
 #include <wtf/MemoryPressureHandler.h>
 #include <wtf/NeverDestroyed.h>
 #include <wtf/RetainPtr.h>
@@ -152,6 +153,9 @@
     bool shouldLogCookieInformation() const { return m_logCookieInformation; }
 #endif
 
+    void setSessionIsControlledByAutomation(PAL::SessionID, bool);
+    bool sessionIsControlledByAutomation(PAL::SessionID) const;
+
 private:
     NetworkProcess();
     ~NetworkProcess();
@@ -258,6 +262,7 @@
 #if ENABLE(SERVER_PRECONNECT)
     HashMap<uint64_t, WeakPtr<PreconnectTask>> m_waitingPreconnectTasks;
 #endif
+    HashSet<PAL::SessionID> m_sessionsControlledByAutomation;
 
 #if PLATFORM(COCOA)
     void platformInitializeNetworkProcessCocoa(const NetworkProcessCreationParameters&);

Modified: trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in (229200 => 229201)


--- trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2018-03-03 20:13:42 UTC (rev 229200)
+++ trunk/Source/WebKit/NetworkProcess/NetworkProcess.messages.in	2018-03-03 23:27:18 UTC (rev 229201)
@@ -88,4 +88,6 @@
     GrantStorageAccessForFrame(PAL::SessionID sessionID, String resourceDomain, String firstPartyDomain, uint64_t frameID, uint64_t pageID, uint64_t contextId)
     RemovePrevalentDomains(PAL::SessionID sessionID, Vector<String> domainsWithInteraction);
 #endif
+
+    SetSessionIsControlledByAutomation(PAL::SessionID sessionID, bool controlled);
 }

Modified: trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp (229200 => 229201)


--- trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2018-03-03 20:13:42 UTC (rev 229200)
+++ trunk/Source/WebKit/NetworkProcess/NetworkResourceLoader.cpp	2018-03-03 23:27:18 UTC (rev 229201)
@@ -706,6 +706,9 @@
 
 bool NetworkResourceLoader::isAlwaysOnLoggingAllowed() const
 {
+    if (NetworkProcess::singleton().sessionIsControlledByAutomation(sessionID()))
+        return true;
+
     return sessionID().isAlwaysOnLoggingAllowed();
 }
 

Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (229200 => 229201)


--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-03-03 20:13:42 UTC (rev 229200)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp	2018-03-03 23:27:18 UTC (rev 229201)
@@ -1281,8 +1281,11 @@
 
     m_controlledByAutomation = controlled;
 
-    if (isValid())
-        m_process->send(Messages::WebPage::SetControlledByAutomation(controlled), m_pageID);
+    if (!isValid())
+        return;
+
+    m_process->send(Messages::WebPage::SetControlledByAutomation(controlled), m_pageID);
+    m_process->processPool().sendToNetworkingProcess(Messages::NetworkProcess::SetSessionIsControlledByAutomation(m_websiteDataStore->sessionID(), m_controlledByAutomation));
 }
 
 #if ENABLE(REMOTE_INSPECTOR)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to