Title: [215212] trunk
Revision
215212
Author
commit-qu...@webkit.org
Date
2017-04-10 17:40:00 -0700 (Mon, 10 Apr 2017)

Log Message

REGRESSION(r195479) First main resource load in new WebProcess bypasses content extensions
https://bugs.webkit.org/show_bug.cgi?id=170707
<rdar://problem/27788755>

Patch by Alex Christensen <achristen...@webkit.org> on 2017-04-10
Reviewed by Tim Horton.

Source/WebKit2:

We fix this by sending the UserContentController with the WebPageCreationParameters
instead of in a IPC message immediately following creation.  By the time the WebPage
receives its second message, it has already started loading the first main resource.

I also changed all instances of calling ChildProcessProxy::connection() to send a message
in favor of calling ChildProcessProxy::send, which does the same thing except if a child
process has not started, it will put the message in a queue and send it when the process
is finished launching.  This was necessary because the UserContentController is now connected
to the process sooner, so there were some API tests that would try to send messages between
initiating a process launch and finishing a process launch, and this change preserves the
existing behavior in those cases.

* Shared/WebPageCreationParameters.cpp:
(WebKit::WebPageCreationParameters::encode):
(WebKit::WebPageCreationParameters::decode):
* Shared/WebPageCreationParameters.h:
* UIProcess/Databases/DatabaseProcessProxy.cpp:
(WebKit::DatabaseProcessProxy::getDatabaseProcessConnection):
(WebKit::DatabaseProcessProxy::didFinishLaunching):
* UIProcess/Downloads/DownloadProxy.cpp:
(WebKit::DownloadProxy::cancel):
(WebKit::DownloadProxy::canAuthenticateAgainstProtectionSpace):
(WebKit::DownloadProxy::willSendRequest):
(WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
* UIProcess/UserContent/WebUserContentControllerProxy.cpp:
(WebKit::WebUserContentControllerProxy::addProcess):
(WebKit::WebUserContentControllerProxy::addUserContentWorldUse):
(WebKit::WebUserContentControllerProxy::removeUserContentWorldUses):
(WebKit::WebUserContentControllerProxy::addUserScript):
(WebKit::WebUserContentControllerProxy::removeUserScript):
(WebKit::WebUserContentControllerProxy::removeAllUserScripts):
(WebKit::WebUserContentControllerProxy::addUserStyleSheet):
(WebKit::WebUserContentControllerProxy::removeUserStyleSheet):
(WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets):
(WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler):
(WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName):
(WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers):
(WebKit::WebUserContentControllerProxy::addContentExtension):
(WebKit::WebUserContentControllerProxy::removeContentExtension):
(WebKit::WebUserContentControllerProxy::removeAllContentExtensions):
* UIProcess/UserContent/WebUserContentControllerProxy.h:
* UIProcess/VisitedLinkStore.cpp:
(WebKit::VisitedLinkStore::removeAll):
(WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired):
(WebKit::VisitedLinkStore::sendTable):
* UIProcess/WebPageProxy.cpp:
(WebKit::WebPageProxy::finishInitializingWebPageAfterProcessLaunch):
(WebKit::WebPageProxy::creationParameters):
* UIProcess/WebProcessProxy.cpp:
(WebKit::WebProcessProxy::addWebUserContentControllerProxy):
* UIProcess/WebProcessProxy.h:
* WebProcess/UserContent/WebUserContentController.h:
* WebProcess/WebPage/WebPage.cpp:
(WebKit::m_backgroundCPULimit):

Tools:

* TestWebKitAPI/Tests/WebKit2Cocoa/WKUserContentExtensionStore.mm:
(-[ContentExtensionDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(TEST_F):
* TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
(-[ContentBlockingWebsitePoliciesDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
(-[ContentBlockingWebsitePoliciesDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]):
(TEST):

Modified Paths

Diff

Modified: trunk/Source/WebKit2/ChangeLog (215211 => 215212)


--- trunk/Source/WebKit2/ChangeLog	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/ChangeLog	2017-04-11 00:40:00 UTC (rev 215212)
@@ -1,5 +1,68 @@
 2017-04-10  Alex Christensen  <achristen...@webkit.org>
 
+        REGRESSION(r195479) First main resource load in new WebProcess bypasses content extensions
+        https://bugs.webkit.org/show_bug.cgi?id=170707
+        <rdar://problem/27788755>
+
+        Reviewed by Tim Horton.
+
+        We fix this by sending the UserContentController with the WebPageCreationParameters
+        instead of in a IPC message immediately following creation.  By the time the WebPage
+        receives its second message, it has already started loading the first main resource.
+        
+        I also changed all instances of calling ChildProcessProxy::connection() to send a message
+        in favor of calling ChildProcessProxy::send, which does the same thing except if a child
+        process has not started, it will put the message in a queue and send it when the process
+        is finished launching.  This was necessary because the UserContentController is now connected
+        to the process sooner, so there were some API tests that would try to send messages between
+        initiating a process launch and finishing a process launch, and this change preserves the
+        existing behavior in those cases.
+
+        * Shared/WebPageCreationParameters.cpp:
+        (WebKit::WebPageCreationParameters::encode):
+        (WebKit::WebPageCreationParameters::decode):
+        * Shared/WebPageCreationParameters.h:
+        * UIProcess/Databases/DatabaseProcessProxy.cpp:
+        (WebKit::DatabaseProcessProxy::getDatabaseProcessConnection):
+        (WebKit::DatabaseProcessProxy::didFinishLaunching):
+        * UIProcess/Downloads/DownloadProxy.cpp:
+        (WebKit::DownloadProxy::cancel):
+        (WebKit::DownloadProxy::canAuthenticateAgainstProtectionSpace):
+        (WebKit::DownloadProxy::willSendRequest):
+        (WebKit::DownloadProxy::decideDestinationWithSuggestedFilenameAsync):
+        * UIProcess/UserContent/WebUserContentControllerProxy.cpp:
+        (WebKit::WebUserContentControllerProxy::addProcess):
+        (WebKit::WebUserContentControllerProxy::addUserContentWorldUse):
+        (WebKit::WebUserContentControllerProxy::removeUserContentWorldUses):
+        (WebKit::WebUserContentControllerProxy::addUserScript):
+        (WebKit::WebUserContentControllerProxy::removeUserScript):
+        (WebKit::WebUserContentControllerProxy::removeAllUserScripts):
+        (WebKit::WebUserContentControllerProxy::addUserStyleSheet):
+        (WebKit::WebUserContentControllerProxy::removeUserStyleSheet):
+        (WebKit::WebUserContentControllerProxy::removeAllUserStyleSheets):
+        (WebKit::WebUserContentControllerProxy::addUserScriptMessageHandler):
+        (WebKit::WebUserContentControllerProxy::removeUserMessageHandlerForName):
+        (WebKit::WebUserContentControllerProxy::removeAllUserMessageHandlers):
+        (WebKit::WebUserContentControllerProxy::addContentExtension):
+        (WebKit::WebUserContentControllerProxy::removeContentExtension):
+        (WebKit::WebUserContentControllerProxy::removeAllContentExtensions):
+        * UIProcess/UserContent/WebUserContentControllerProxy.h:
+        * UIProcess/VisitedLinkStore.cpp:
+        (WebKit::VisitedLinkStore::removeAll):
+        (WebKit::VisitedLinkStore::pendingVisitedLinksTimerFired):
+        (WebKit::VisitedLinkStore::sendTable):
+        * UIProcess/WebPageProxy.cpp:
+        (WebKit::WebPageProxy::finishInitializingWebPageAfterProcessLaunch):
+        (WebKit::WebPageProxy::creationParameters):
+        * UIProcess/WebProcessProxy.cpp:
+        (WebKit::WebProcessProxy::addWebUserContentControllerProxy):
+        * UIProcess/WebProcessProxy.h:
+        * WebProcess/UserContent/WebUserContentController.h:
+        * WebProcess/WebPage/WebPage.cpp:
+        (WebKit::m_backgroundCPULimit):
+
+2017-04-10  Alex Christensen  <achristen...@webkit.org>
+
         Add API to get available content extension identifiers in a WKContentExtensionStore
         https://bugs.webkit.org/show_bug.cgi?id=170093
 

Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp (215211 => 215212)


--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.cpp	2017-04-11 00:40:00 UTC (rev 215212)
@@ -101,6 +101,13 @@
     encoder << enumeratingAllNetworkInterfacesEnabled;
 #endif
 #endif
+    encoder << userContentWorlds;
+    encoder << userScripts;
+    encoder << userStyleSheets;
+    encoder << messageHandlers;
+#if ENABLE(CONTENT_EXTENSIONS)
+    encoder << contentExtensions;
+#endif
 }
 
 bool WebPageCreationParameters::decode(IPC::Decoder& decoder, WebPageCreationParameters& parameters)
@@ -237,6 +244,18 @@
         return false;
 #endif
 #endif
+    if (!decoder.decode(parameters.userContentWorlds))
+        return false;
+    if (!decoder.decode(parameters.userScripts))
+        return false;
+    if (!decoder.decode(parameters.userStyleSheets))
+        return false;
+    if (!decoder.decode(parameters.messageHandlers))
+        return false;
+#if ENABLE(CONTENT_EXTENSIONS)
+    if (!decoder.decode(parameters.contentExtensions))
+        return false;
+#endif
     return true;
 }
 

Modified: trunk/Source/WebKit2/Shared/WebPageCreationParameters.h (215211 => 215212)


--- trunk/Source/WebKit2/Shared/WebPageCreationParameters.h	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/Shared/WebPageCreationParameters.h	2017-04-11 00:40:00 UTC (rev 215212)
@@ -23,15 +23,16 @@
  * THE POSSIBILITY OF SUCH DAMAGE.
  */
 
-#ifndef WebPageCreationParameters_h
-#define WebPageCreationParameters_h
+#pragma once
 
 #include "DrawingAreaInfo.h"
 #include "LayerTreeContext.h"
 #include "SessionState.h"
+#include "WebCompiledContentExtensionData.h"
 #include "WebCoreArgumentCoders.h"
 #include "WebPageGroupData.h"
 #include "WebPreferencesStore.h"
+#include "WebUserContentControllerDataTypes.h"
 #include <WebCore/ActivityState.h>
 #include <WebCore/Color.h>
 #include <WebCore/FloatSize.h>
@@ -156,8 +157,15 @@
     bool enumeratingAllNetworkInterfacesEnabled { false };
 #endif
 #endif
+
+    // UserContentController members
+    Vector<std::pair<uint64_t, String>> userContentWorlds;
+    Vector<WebUserScriptData> userScripts;
+    Vector<WebUserStyleSheetData> userStyleSheets;
+    Vector<WebScriptMessageHandlerData> messageHandlers;
+#if ENABLE(CONTENT_EXTENSIONS)
+    Vector<std::pair<String, WebCompiledContentExtensionData>> contentExtensions;
+#endif
 };
 
 } // namespace WebKit
-
-#endif // WebPageCreationParameters_h

Modified: trunk/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp (215211 => 215212)


--- trunk/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/UIProcess/Databases/DatabaseProcessProxy.cpp	2017-04-11 00:40:00 UTC (rev 215212)
@@ -122,7 +122,7 @@
         return;
     }
 
-    connection()->send(Messages::DatabaseProcess::CreateDatabaseToWebProcessConnection(), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
+    send(Messages::DatabaseProcess::CreateDatabaseToWebProcessConnection(), 0, IPC::SendOption::DispatchMessageEvenWhenWaitingForSyncReply);
 }
 
 void DatabaseProcessProxy::didClose(IPC::Connection&)
@@ -217,7 +217,7 @@
     }
 
     for (unsigned i = 0; i < m_numPendingConnectionRequests; ++i)
-        connection()->send(Messages::DatabaseProcess::CreateDatabaseToWebProcessConnection(), 0);
+        send(Messages::DatabaseProcess::CreateDatabaseToWebProcessConnection(), 0);
     
     m_numPendingConnectionRequests = 0;
 }

Modified: trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp (215211 => 215212)


--- trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/UIProcess/Downloads/DownloadProxy.cpp	2017-04-11 00:40:00 UTC (rev 215212)
@@ -75,7 +75,7 @@
         return;
 
     if (NetworkProcessProxy* networkProcess = m_processPool->networkProcess())
-        networkProcess->connection()->send(Messages::NetworkProcess::CancelDownload(m_downloadID), 0);
+        networkProcess->send(Messages::NetworkProcess::CancelDownload(m_downloadID), 0);
 }
 
 void DownloadProxy::invalidate()
@@ -126,7 +126,7 @@
 
     bool result = m_processPool->downloadClient().canAuthenticateAgainstProtectionSpace(getPtr(WebProtectionSpace::create(protectionSpace)));
     
-    networkProcessProxy->connection()->send(Messages::NetworkProcess::ContinueCanAuthenticateAgainstProtectionSpaceDownload(m_downloadID, result), 0);
+    networkProcessProxy->send(Messages::NetworkProcess::ContinueCanAuthenticateAgainstProtectionSpaceDownload(m_downloadID, result), 0);
 }
 #endif
 
@@ -144,7 +144,7 @@
         if (!networkProcessProxy)
             return;
         
-        networkProcessProxy->connection()->send(Messages::NetworkProcess::ContinueWillSendRequest(protectedThis->m_downloadID, newRequest), 0);
+        networkProcessProxy->send(Messages::NetworkProcess::ContinueWillSendRequest(protectedThis->m_downloadID, newRequest), 0);
     });
 }
 #endif
@@ -189,7 +189,7 @@
         SandboxExtension::createHandle(destination, SandboxExtension::ReadWrite, sandboxExtensionHandle);
 
     if (NetworkProcessProxy* networkProcess = m_processPool->networkProcess())
-        networkProcess->connection()->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite), 0);
+        networkProcess->send(Messages::NetworkProcess::ContinueDecidePendingDownloadDestination(downloadID, destination, sandboxExtensionHandle, allowOverwrite), 0);
 }
 
 #if !USE(NETWORK_SESSION)

Modified: trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp (215211 => 215212)


--- trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.cpp	2017-04-11 00:40:00 UTC (rev 215212)
@@ -67,40 +67,33 @@
     }
 }
 
-void WebUserContentControllerProxy::addProcess(WebProcessProxy& webProcessProxy)
+void WebUserContentControllerProxy::addProcess(WebProcessProxy& webProcessProxy, WebPageCreationParameters& parameters)
 {
-    ASSERT(webProcessProxy.state() == WebProcessProxy::State::Running);
-
     if (!m_processes.add(&webProcessProxy).isNewEntry)
         return;
 
     webProcessProxy.addMessageReceiver(Messages::WebUserContentControllerProxy::messageReceiverName(), m_identifier, *this);
 
-    Vector<std::pair<uint64_t, String>> userContentWorlds;
+    ASSERT(parameters.userContentWorlds.isEmpty());
     for (const auto& world : m_userContentWorlds)
-        userContentWorlds.append(std::make_pair(world.key->identifier(), world.key->name()));
-    webProcessProxy.connection()->send(Messages::WebUserContentController::AddUserContentWorlds(userContentWorlds), m_identifier);
+        parameters.userContentWorlds.append(std::make_pair(world.key->identifier(), world.key->name()));
 
-    Vector<WebUserScriptData> userScripts;
+    ASSERT(parameters.userScripts.isEmpty());
     for (const auto& userScript : m_userScripts->elementsOfType<API::UserScript>())
-        userScripts.append({ userScript->identifier(), userScript->userContentWorld().identifier(), userScript->userScript() });
-    webProcessProxy.connection()->send(Messages::WebUserContentController::AddUserScripts(userScripts), m_identifier);
+        parameters.userScripts.append({ userScript->identifier(), userScript->userContentWorld().identifier(), userScript->userScript() });
 
-    Vector<WebUserStyleSheetData> userStyleSheets;
+    ASSERT(parameters.userStyleSheets.isEmpty());
     for (const auto& userStyleSheet : m_userStyleSheets->elementsOfType<API::UserStyleSheet>())
-        userStyleSheets.append({ userStyleSheet->identifier(), userStyleSheet->userContentWorld().identifier(), userStyleSheet->userStyleSheet() });
-    webProcessProxy.connection()->send(Messages::WebUserContentController::AddUserStyleSheets(userStyleSheets), m_identifier);
+        parameters.userStyleSheets.append({ userStyleSheet->identifier(), userStyleSheet->userContentWorld().identifier(), userStyleSheet->userStyleSheet() });
 
-    Vector<WebScriptMessageHandlerData> messageHandlers;
+    ASSERT(parameters.messageHandlers.isEmpty());
     for (auto& handler : m_scriptMessageHandlers.values())
-        messageHandlers.append({ handler->identifier(), handler->userContentWorld().identifier(), handler->name() });
-    webProcessProxy.connection()->send(Messages::WebUserContentController::AddUserScriptMessageHandlers(messageHandlers), m_identifier);
+        parameters.messageHandlers.append({ handler->identifier(), handler->userContentWorld().identifier(), handler->name() });
 
 #if ENABLE(CONTENT_EXTENSIONS)
-    Vector<std::pair<String, WebCompiledContentExtensionData>> contentExtensions;
+    ASSERT(parameters.contentExtensions.isEmpty());
     for (const auto& contentExtension : m_contentExtensions.values())
-        contentExtensions.append(std::make_pair(contentExtension->name(), contentExtension->compiledExtension().data()));
-    webProcessProxy.connection()->send(Messages::WebUserContentController::AddContentExtensions(contentExtensions), m_identifier);
+        parameters.contentExtensions.append(std::make_pair(contentExtension->name(), contentExtension->compiledExtension().data()));
 #endif
 }
 
@@ -120,7 +113,7 @@
     auto addResult = m_userContentWorlds.add(&world);
     if (addResult.isNewEntry) {
         for (WebProcessProxy* process : m_processes)
-            process->connection()->send(Messages::WebUserContentController::AddUserContentWorlds({ std::make_pair(world.identifier(), world.name()) }), m_identifier);
+            process->send(Messages::WebUserContentController::AddUserContentWorlds({ std::make_pair(world.identifier(), world.name()) }), m_identifier);
     }
 }
 
@@ -144,7 +137,7 @@
 {
     if (shouldSendRemoveUserContentWorldsMessage(world, numberOfUsesToRemove)) {
         for (WebProcessProxy* process : m_processes)
-            process->connection()->send(Messages::WebUserContentController::RemoveUserContentWorlds({ world.identifier() }), m_identifier);
+            process->send(Messages::WebUserContentController::RemoveUserContentWorlds({ world.identifier() }), m_identifier);
     }
 }
 
@@ -157,7 +150,7 @@
     }
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::RemoveUserContentWorlds(worldsToRemove), m_identifier);
+        process->send(Messages::WebUserContentController::RemoveUserContentWorlds(worldsToRemove), m_identifier);
 }
 
 void WebUserContentControllerProxy::addUserScript(API::UserScript& userScript)
@@ -169,7 +162,7 @@
     m_userScripts->elements().append(&userScript);
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::AddUserScripts({ { userScript.identifier(), world->identifier(), userScript.userScript() } }), m_identifier);
+        process->send(Messages::WebUserContentController::AddUserScripts({ { userScript.identifier(), world->identifier(), userScript.userScript() } }), m_identifier);
 }
 
 void WebUserContentControllerProxy::removeUserScript(API::UserScript& userScript)
@@ -177,7 +170,7 @@
     Ref<API::UserContentWorld> world = userScript.userContentWorld();
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::RemoveUserScript(world->identifier(), userScript.identifier()), m_identifier);
+        process->send(Messages::WebUserContentController::RemoveUserScript(world->identifier(), userScript.identifier()), m_identifier);
 
     m_userScripts->elements().removeAll(&userScript);
 
@@ -187,7 +180,7 @@
 void WebUserContentControllerProxy::removeAllUserScripts(API::UserContentWorld& world)
 {
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::RemoveAllUserScripts({ world.identifier() }), m_identifier);
+        process->send(Messages::WebUserContentController::RemoveAllUserScripts({ world.identifier() }), m_identifier);
 
     unsigned userScriptsRemoved = m_userScripts->removeAllOfTypeMatching<API::UserScript>([&](const auto& userScript) {
         return &userScript->userContentWorld() == &world;
@@ -208,7 +201,7 @@
         worldIdentifiers.uncheckedAppend(worldCountPair.key->identifier());
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::RemoveAllUserScripts(worldIdentifiers), m_identifier);
+        process->send(Messages::WebUserContentController::RemoveAllUserScripts(worldIdentifiers), m_identifier);
 
     m_userScripts->elements().clear();
 
@@ -224,7 +217,7 @@
     m_userStyleSheets->elements().append(&userStyleSheet);
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::AddUserStyleSheets({ { userStyleSheet.identifier(), world->identifier(), userStyleSheet.userStyleSheet() } }), m_identifier);
+        process->send(Messages::WebUserContentController::AddUserStyleSheets({ { userStyleSheet.identifier(), world->identifier(), userStyleSheet.userStyleSheet() } }), m_identifier);
 }
 
 void WebUserContentControllerProxy::removeUserStyleSheet(API::UserStyleSheet& userStyleSheet)
@@ -232,7 +225,7 @@
     Ref<API::UserContentWorld> world = userStyleSheet.userContentWorld();
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::RemoveUserStyleSheet(world->identifier(), userStyleSheet.identifier()), m_identifier);
+        process->send(Messages::WebUserContentController::RemoveUserStyleSheet(world->identifier(), userStyleSheet.identifier()), m_identifier);
 
     m_userStyleSheets->elements().removeAll(&userStyleSheet);
 
@@ -242,7 +235,7 @@
 void WebUserContentControllerProxy::removeAllUserStyleSheets(API::UserContentWorld& world)
 {
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::RemoveAllUserStyleSheets({ world.identifier() }), m_identifier);
+        process->send(Messages::WebUserContentController::RemoveAllUserStyleSheets({ world.identifier() }), m_identifier);
 
     unsigned userStyleSheetsRemoved = m_userStyleSheets->removeAllOfTypeMatching<API::UserStyleSheet>([&](const auto& userStyleSheet) {
         return &userStyleSheet->userContentWorld() == &world;
@@ -263,7 +256,7 @@
         worldIdentifiers.uncheckedAppend(worldCountPair.key->identifier());
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::RemoveAllUserStyleSheets(worldIdentifiers), m_identifier);
+        process->send(Messages::WebUserContentController::RemoveAllUserStyleSheets(worldIdentifiers), m_identifier);
 
     m_userStyleSheets->elements().clear();
 
@@ -284,7 +277,7 @@
     m_scriptMessageHandlers.add(handler.identifier(), &handler);
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::AddUserScriptMessageHandlers({ { handler.identifier(), world->identifier(), handler.name() } }), m_identifier);
+        process->send(Messages::WebUserContentController::AddUserScriptMessageHandlers({ { handler.identifier(), world->identifier(), handler.name() } }), m_identifier);
     
     return true;
 }
@@ -294,7 +287,7 @@
     for (auto it = m_scriptMessageHandlers.begin(), end = m_scriptMessageHandlers.end(); it != end; ++it) {
         if (it->value->name() == name && &it->value->userContentWorld() == &world) {
             for (WebProcessProxy* process : m_processes)
-                process->connection()->send(Messages::WebUserContentController::RemoveUserScriptMessageHandler(world.identifier(), it->value->identifier()), m_identifier);
+                process->send(Messages::WebUserContentController::RemoveUserScriptMessageHandler(world.identifier(), it->value->identifier()), m_identifier);
 
             m_scriptMessageHandlers.remove(it);
 
@@ -307,7 +300,7 @@
 void WebUserContentControllerProxy::removeAllUserMessageHandlers(API::UserContentWorld& world)
 {
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::RemoveAllUserScriptMessageHandlers({ world.identifier() }), m_identifier);
+        process->send(Messages::WebUserContentController::RemoveAllUserScriptMessageHandlers({ world.identifier() }), m_identifier);
 
     unsigned numberRemoved = 0;
     m_scriptMessageHandlers.removeIf([&](auto& entry) {
@@ -345,7 +338,7 @@
     auto pair = std::make_pair(contentExtension.name(), contentExtension.compiledExtension().data());
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::AddContentExtensions({ pair }), m_identifier);
+        process->send(Messages::WebUserContentController::AddContentExtensions({ pair }), m_identifier);
 }
 
 void WebUserContentControllerProxy::removeContentExtension(const String& name)
@@ -353,7 +346,7 @@
     m_contentExtensions.remove(name);
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::RemoveContentExtension(name), m_identifier);
+        process->send(Messages::WebUserContentController::RemoveContentExtension(name), m_identifier);
 }
 
 void WebUserContentControllerProxy::removeAllContentExtensions()
@@ -361,7 +354,7 @@
     m_contentExtensions.clear();
 
     for (WebProcessProxy* process : m_processes)
-        process->connection()->send(Messages::WebUserContentController::RemoveAllContentExtensions(), m_identifier);
+        process->send(Messages::WebUserContentController::RemoveAllContentExtensions(), m_identifier);
 }
 #endif
 

Modified: trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h (215211 => 215212)


--- trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/UIProcess/UserContent/WebUserContentControllerProxy.h	2017-04-11 00:40:00 UTC (rev 215212)
@@ -56,6 +56,7 @@
 class WebProcessProxy;
 class WebScriptMessageHandler;
 struct FrameInfoData;
+struct WebPageCreationParameters;
 
 class WebUserContentControllerProxy : public API::ObjectImpl<API::Object::Type::UserContentController>, private IPC::MessageReceiver {
 public:
@@ -68,7 +69,7 @@
 
     uint64_t identifier() const { return m_identifier; }
 
-    void addProcess(WebProcessProxy&);
+    void addProcess(WebProcessProxy&, WebPageCreationParameters&);
     void removeProcess(WebProcessProxy&);
 
     API::Array& userScripts() { return m_userScripts.get(); }

Modified: trunk/Source/WebKit2/UIProcess/VisitedLinkStore.cpp (215211 => 215212)


--- trunk/Source/WebKit2/UIProcess/VisitedLinkStore.cpp	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/UIProcess/VisitedLinkStore.cpp	2017-04-11 00:40:00 UTC (rev 215212)
@@ -111,7 +111,7 @@
 
     for (WebProcessProxy* process : m_processes) {
         ASSERT(process->processPool().processes().contains(process));
-        process->connection()->send(Messages::VisitedLinkTableController::RemoveAllVisitedLinks(), m_identifier);
+        process->send(Messages::VisitedLinkTableController::RemoveAllVisitedLinks(), m_identifier);
     }
 }
 
@@ -194,9 +194,9 @@
         ASSERT(process->processPool().processes().contains(process));
 
         if (addedVisitedLinks.size() > 20)
-            process->connection()->send(Messages::VisitedLinkTableController::AllVisitedLinkStateChanged(), m_identifier);
+            process->send(Messages::VisitedLinkTableController::AllVisitedLinkStateChanged(), m_identifier);
         else
-            process->connection()->send(Messages::VisitedLinkTableController::VisitedLinkStateChanged(addedVisitedLinks), m_identifier);
+            process->send(Messages::VisitedLinkTableController::VisitedLinkStateChanged(addedVisitedLinks), m_identifier);
     }
 }
 
@@ -253,7 +253,7 @@
     if (!m_table.sharedMemory()->createHandle(handle, SharedMemory::Protection::ReadOnly))
         return;
 
-    process.connection()->send(Messages::VisitedLinkTableController::SetVisitedLinkTable(handle), m_identifier);
+    process.send(Messages::VisitedLinkTableController::SetVisitedLinkTable(handle), m_identifier);
 }
 
 } // namespace WebKit

Modified: trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp (215211 => 215212)


--- trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/UIProcess/WebPageProxy.cpp	2017-04-11 00:40:00 UTC (rev 215212)
@@ -824,8 +824,6 @@
         return;
 
     m_needsToFinishInitializingWebPageAfterProcessLaunch = false;
-
-    m_process->addWebUserContentControllerProxy(m_userContentController);
     m_process->addVisitedLinkStore(m_visitedLinkStore);
 }
 
@@ -5595,6 +5593,8 @@
 #endif
 #endif
 
+    m_process->addWebUserContentControllerProxy(m_userContentController, parameters);
+
     return parameters;
 }
 

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp (215211 => 215212)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.cpp	2017-04-11 00:40:00 UTC (rev 215212)
@@ -320,10 +320,10 @@
     store.addProcess(*this);
 }
 
-void WebProcessProxy::addWebUserContentControllerProxy(WebUserContentControllerProxy& proxy)
+void WebProcessProxy::addWebUserContentControllerProxy(WebUserContentControllerProxy& proxy, WebPageCreationParameters& parameters)
 {
     m_webUserContentControllerProxies.add(&proxy);
-    proxy.addProcess(*this);
+    proxy.addProcess(*this, parameters);
 }
 
 void WebProcessProxy::didDestroyVisitedLinkStore(VisitedLinkStore& store)

Modified: trunk/Source/WebKit2/UIProcess/WebProcessProxy.h (215211 => 215212)


--- trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/UIProcess/WebProcessProxy.h	2017-04-11 00:40:00 UTC (rev 215212)
@@ -98,7 +98,7 @@
     unsigned visiblePageCount() const { return m_visiblePageCounter.value(); }
 
     void addVisitedLinkStore(VisitedLinkStore&);
-    void addWebUserContentControllerProxy(WebUserContentControllerProxy&);
+    void addWebUserContentControllerProxy(WebUserContentControllerProxy&, WebPageCreationParameters&);
     void didDestroyVisitedLinkStore(VisitedLinkStore&);
     void didDestroyWebUserContentControllerProxy(WebUserContentControllerProxy&);
 

Modified: trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.h (215211 => 215212)


--- trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.h	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/WebProcess/UserContent/WebUserContentController.h	2017-04-11 00:40:00 UTC (rev 215212)
@@ -62,6 +62,14 @@
     void removeUserStyleSheets(InjectedBundleScriptWorld&);
     void removeAllUserContent();
 
+    void addUserContentWorlds(const Vector<std::pair<uint64_t, String>>&);
+    void addUserScripts(const Vector<WebUserScriptData>&);
+    void addUserStyleSheets(const Vector<WebUserStyleSheetData>&);
+    void addUserScriptMessageHandlers(const Vector<WebScriptMessageHandlerData>&);
+#if ENABLE(CONTENT_EXTENSIONS)
+    void addContentExtensions(const Vector<std::pair<String, WebCompiledContentExtensionData>>&);
+#endif
+
 private:
     explicit WebUserContentController(uint64_t identifier);
 
@@ -78,23 +86,18 @@
     // IPC::MessageReceiver.
     void didReceiveMessage(IPC::Connection&, IPC::Decoder&) override;
 
-    void addUserContentWorlds(const Vector<std::pair<uint64_t, String>>&);
     void removeUserContentWorlds(const Vector<uint64_t>&);
 
-    void addUserScripts(const Vector<WebUserScriptData>&);
     void removeUserScript(uint64_t worldIdentifier, uint64_t userScriptIdentifier);
     void removeAllUserScripts(const Vector<uint64_t>&);
 
-    void addUserStyleSheets(const Vector<WebUserStyleSheetData>&);
     void removeUserStyleSheet(uint64_t worldIdentifier, uint64_t userScriptIdentifier);
     void removeAllUserStyleSheets(const Vector<uint64_t>&);
 
-    void addUserScriptMessageHandlers(const Vector<WebScriptMessageHandlerData>&);
     void removeUserScriptMessageHandler(uint64_t worldIdentifier, uint64_t userScriptIdentifier);
     void removeAllUserScriptMessageHandlers(const Vector<uint64_t>&);
 
 #if ENABLE(CONTENT_EXTENSIONS)
-    void addContentExtensions(const Vector<std::pair<String, WebCompiledContentExtensionData>>&);
     void removeContentExtension(const String& name);
     void removeAllContentExtensions();
 #endif

Modified: trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp (215211 => 215212)


--- trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Source/WebKit2/WebProcess/WebPage/WebPage.cpp	2017-04-11 00:40:00 UTC (rev 215212)
@@ -566,6 +566,14 @@
 
     for (auto iterator : parameters.urlSchemeHandlers)
         registerURLSchemeHandler(iterator.value, iterator.key);
+
+    m_userContentController->addUserContentWorlds(parameters.userContentWorlds);
+    m_userContentController->addUserScripts(parameters.userScripts);
+    m_userContentController->addUserStyleSheets(parameters.userStyleSheets);
+    m_userContentController->addUserScriptMessageHandlers(parameters.messageHandlers);
+#if ENABLE(CONTENT_EXTENSIONS)
+    m_userContentController->addContentExtensions(parameters.contentExtensions);
+#endif
 }
 
 #if ENABLE(WEB_RTC)

Modified: trunk/Tools/ChangeLog (215211 => 215212)


--- trunk/Tools/ChangeLog	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Tools/ChangeLog	2017-04-11 00:40:00 UTC (rev 215212)
@@ -1,5 +1,21 @@
 2017-04-10  Alex Christensen  <achristen...@webkit.org>
 
+        REGRESSION(r195479) First main resource load in new WebProcess bypasses content extensions
+        https://bugs.webkit.org/show_bug.cgi?id=170707
+        <rdar://problem/27788755>
+
+        Reviewed by Tim Horton.
+
+        * TestWebKitAPI/Tests/WebKit2Cocoa/WKUserContentExtensionStore.mm:
+        (-[ContentExtensionDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+        (TEST_F):
+        * TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm:
+        (-[ContentBlockingWebsitePoliciesDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+        (-[ContentBlockingWebsitePoliciesDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]):
+        (TEST):
+
+2017-04-10  Alex Christensen  <achristen...@webkit.org>
+
         Add API to get available content extension identifiers in a WKContentExtensionStore
         https://bugs.webkit.org/show_bug.cgi?id=170093
 

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKUserContentExtensionStore.mm (215211 => 215212)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKUserContentExtensionStore.mm	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WKUserContentExtensionStore.mm	2017-04-11 00:40:00 UTC (rev 215212)
@@ -307,18 +307,10 @@
 {
     switch (alertCount++) {
     case 0:
-        // FIXME: The first content blocker should be enabled here.
-        // ContentExtensionsBackend::addContentExtension isn't being called in the WebProcess
-        // until after the first main resource starts loading, so we need to send a message to the
-        // WebProcess before loading if we have installed content blockers.
-        // See rdar://problem/27788755
-        EXPECT_STREQ("content blockers disabled", message.UTF8String);
-        break;
-    case 1:
         // Default behavior.
         EXPECT_STREQ("content blockers enabled", message.UTF8String);
         break;
-    case 2:
+    case 1:
         // After having removed the content extension.
         EXPECT_STREQ("content blockers disabled", message.UTF8String);
         break;
@@ -360,10 +352,6 @@
     [webView loadRequest:request];
     TestWebKitAPI::Util::run(&receivedAlert);
 
-    receivedAlert = false;
-    [webView reload];
-    TestWebKitAPI::Util::run(&receivedAlert);
-
     [[configuration userContentController] removeContentExtension:extension.get()];
 
     receivedAlert = false;

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm (215211 => 215212)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm	2017-04-11 00:24:17 UTC (rev 215211)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/WebsitePolicies.mm	2017-04-11 00:40:00 UTC (rev 215212)
@@ -71,22 +71,14 @@
 {
     switch (alertCount++) {
     case 0:
-        // FIXME: The first content blocker should be enabled here.
-        // ContentExtensionsBackend::addContentExtension isn't being called in the WebProcess
-        // until after the first main resource starts loading, so we need to send a message to the
-        // WebProcess before loading if we have installed content blockers.
-        // See rdar://problem/27788755
-        EXPECT_STREQ("content blockers disabled", message.UTF8String);
-        break;
-    case 1:
         // Default behavior.
         EXPECT_STREQ("content blockers enabled", message.UTF8String);
         break;
-    case 2:
+    case 1:
         // After having set websitePolicies.contentBlockersEnabled to false.
         EXPECT_STREQ("content blockers disabled", message.UTF8String);
         break;
-    case 3:
+    case 2:
         // After having reloaded without content blockers.
         EXPECT_STREQ("content blockers disabled", message.UTF8String);
         break;
@@ -102,12 +94,9 @@
     _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease];
     switch (alertCount) {
     case 0:
-        // Verify an existing bug the first time a page is loaded in a new WebProcess.
+        // Verify the content blockers behave correctly with the default behavior.
         break;
     case 1:
-        // Verify the content blockers behave correctly with the default behavior.
-        break;
-    case 2:
         {
             // Verify disabling content blockers works correctly.
             websitePolicies.contentBlockersEnabled = false;
@@ -120,7 +109,7 @@
             });
         }
         return;
-    case 3:
+    case 2:
         // Verify enabling content blockers has no effect when reloading without content blockers.
         websitePolicies.contentBlockersEnabled = true;
         break;
@@ -164,10 +153,6 @@
     TestWebKitAPI::Util::run(&receivedAlert);
 
     receivedAlert = false;
-    [webView reload];
-    TestWebKitAPI::Util::run(&receivedAlert);
-
-    receivedAlert = false;
     [webView _reloadWithoutContentBlockers];
     TestWebKitAPI::Util::run(&receivedAlert);
 
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to