[Content Filtering] REGRESSION (r182356): Provisional URL is incorrect in didReceiveS...
authoraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Aug 2015 06:48:28 +0000 (06:48 +0000)
committeraestes@apple.com <aestes@apple.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Mon, 24 Aug 2015 06:48:28 +0000 (06:48 +0000)
https://bugs.webkit.org/show_bug.cgi?id=147872
rdar://problem/22044000

Reviewed by Dan Bernstein.
Source/WebCore:

Passed the ResourceLoader request URL to dispatchDidReceiveServerRedirectForProvisionalLoad().

New API test: ContentFiltering.ServerRedirect

* WebCore.xcodeproj/project.pbxproj:
* loader/EmptyClients.h:
* loader/FrameLoaderClient.h: Added a URL argument to dispatchDidReceiveServerRedirectForProvisionalLoad().
* loader/ResourceLoader.cpp:
(WebCore::ResourceLoader::willSendRequestInternal): Passed the request URL to dispatchDidReceiveServerRedirectForProvisionalLoad().
* testing/Internals.cpp:
(WebCore::Internals::Internals): Stopped calling MockContentFilter::ensureInstalled().
* testing/MockContentFilterSettings.cpp:
(WebCore::MockContentFilterSettings::setEnabled): Called MockContentFilter::ensureInstalled() to ensure the
mock is installed whenever the filter is enabled.
* testing/MockContentFilterSettings.h: Exported member functions used by TestWebKitAPI.

Source/WebKit/mac:

* WebCoreSupport/WebFrameLoaderClient.h:
* WebCoreSupport/WebFrameLoaderClient.mm:
(WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad): Set provisionalURL using the URL argument.

Source/WebKit/win:

* WebCoreSupport/WebFrameLoaderClient.cpp:
(WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad): Added the URL argument.
* WebCoreSupport/WebFrameLoaderClient.h:

Source/WebKit2:

The provisional DocumentLoader request URL does not reflect redirects when content filtering is enabled, but
the URL argument passed to dispatchDidReceiveServerRedirectForProvisionalLoad() does, so use it intead.

* WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
(WebKit::WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad):
Sent DidReceiveServerRedirectForProvisionalLoadForFrame using the URL argument.
* WebProcess/WebCoreSupport/WebFrameLoaderClient.h:

Tools:

Added an API test.

* TestWebKitAPI/Configurations/WebProcessPlugIn.xcconfig: Linked libWebCoreTestSupport in order to use MockContentFilter.
* TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
* TestWebKitAPI/Tests/WebKit2Cocoa/ContentFiltering.mm: Added.
(-[ServerRedirectNavigationDelegate webView:didStartProvisionalNavigation:]): Expect the initial request URL.
(-[ServerRedirectNavigationDelegate webView:didReceiveServerRedirectForProvisionalNavigation:]): Expect the redirect URL.
(-[ServerRedirectNavigationDelegate webView:didCommitNavigation:]):
(TEST): Tested that -[WKWebView URL] is updated after a redirect when content filtering is enabled.
* TestWebKitAPI/Tests/WebKit2Cocoa/ContentFilteringPlugIn.mm: Added.
(+[ServerRedirectPlugIn initialize]): Enable MockContentFilter.
* TestWebKitAPI/cocoa/TestProtocol.h: Renamed from Tools/TestWebKitAPI/mac/TestProtocol.h.
* TestWebKitAPI/cocoa/TestProtocol.mm: Renamed from Tools/TestWebKitAPI/mac/TestProtocol.mm.

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

24 files changed:
Source/WebCore/ChangeLog
Source/WebCore/WebCore.xcodeproj/project.pbxproj
Source/WebCore/loader/EmptyClients.h
Source/WebCore/loader/FrameLoaderClient.h
Source/WebCore/loader/ResourceLoader.cpp
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/MockContentFilterSettings.cpp
Source/WebCore/testing/MockContentFilterSettings.h
Source/WebKit/mac/ChangeLog
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit/mac/WebCoreSupport/WebFrameLoaderClient.mm
Source/WebKit/win/ChangeLog
Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit/win/WebCoreSupport/WebFrameLoaderClient.h
Source/WebKit2/ChangeLog
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp
Source/WebKit2/WebProcess/WebCoreSupport/WebFrameLoaderClient.h
Tools/ChangeLog
Tools/TestWebKitAPI/Configurations/WebProcessPlugIn.xcconfig
Tools/TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ContentFiltering.mm [new file with mode: 0644]
Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ContentFilteringPlugIn.mm [new file with mode: 0644]
Tools/TestWebKitAPI/cocoa/TestProtocol.h [moved from Tools/TestWebKitAPI/mac/TestProtocol.h with 100% similarity]
Tools/TestWebKitAPI/cocoa/TestProtocol.mm [moved from Tools/TestWebKitAPI/mac/TestProtocol.mm with 100% similarity]

index 73e52883b5ef8f28630e364473ebb582d3b42cf9..d3f4d822b5cefe59c21a740a6291979297625762 100644 (file)
@@ -1,3 +1,27 @@
+2015-08-23  Andy Estes  <aestes@apple.com>
+
+        [Content Filtering] REGRESSION (r182356): Provisional URL is incorrect in didReceiveServerRedirectForProvisionalLoadForFrame when Content Filtering is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=147872
+        rdar://problem/22044000
+
+        Reviewed by Dan Bernstein.
+
+        Passed the ResourceLoader request URL to dispatchDidReceiveServerRedirectForProvisionalLoad().
+
+        New API test: ContentFiltering.ServerRedirect
+
+        * WebCore.xcodeproj/project.pbxproj:
+        * loader/EmptyClients.h:
+        * loader/FrameLoaderClient.h: Added a URL argument to dispatchDidReceiveServerRedirectForProvisionalLoad().
+        * loader/ResourceLoader.cpp:
+        (WebCore::ResourceLoader::willSendRequestInternal): Passed the request URL to dispatchDidReceiveServerRedirectForProvisionalLoad().
+        * testing/Internals.cpp:
+        (WebCore::Internals::Internals): Stopped calling MockContentFilter::ensureInstalled().
+        * testing/MockContentFilterSettings.cpp:
+        (WebCore::MockContentFilterSettings::setEnabled): Called MockContentFilter::ensureInstalled() to ensure the
+        mock is installed whenever the filter is enabled.
+        * testing/MockContentFilterSettings.h: Exported member functions used by TestWebKitAPI.
+
 2015-08-23  Geoffrey Garen  <ggaren@apple.com>
 
         Unreviewed, rolling back in r188803.
index 6ebd7192ac4d8d1c342f2d47e83df7692ce46f90..1807e4c920332f5ebca448c07920d50c362c8299 100644 (file)
                A19D934A1AA11B1E00B46C24 /* NetworkExtensionContentFilter.mm in Sources */ = {isa = PBXBuildFile; fileRef = A19D93481AA11B1E00B46C24 /* NetworkExtensionContentFilter.mm */; };
                A19D934B1AA11B1E00B46C24 /* NetworkExtensionContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A19D93491AA11B1E00B46C24 /* NetworkExtensionContentFilter.h */; };
                A1B5B29E1AAA846E008B6042 /* MockContentFilterSettings.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1B5B29C1AAA846E008B6042 /* MockContentFilterSettings.cpp */; };
-               A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */; };
+               A1B5B29F1AAA846F008B6042 /* MockContentFilterSettings.h in Headers */ = {isa = PBXBuildFile; fileRef = A1B5B29D1AAA846E008B6042 /* MockContentFilterSettings.h */; settings = {ATTRIBUTES = (Private, ); }; };
                A1BF6B821AA96C7D00AF4A8A /* MockContentFilter.cpp in Sources */ = {isa = PBXBuildFile; fileRef = A1BF6B801AA96C7D00AF4A8A /* MockContentFilter.cpp */; };
                A1BF6B831AA96C7D00AF4A8A /* MockContentFilter.h in Headers */ = {isa = PBXBuildFile; fileRef = A1BF6B811AA96C7D00AF4A8A /* MockContentFilter.h */; };
                A1C797181883DD82000F5E1F /* DOMGestureEvent.h in Copy Generated Headers */ = {isa = PBXBuildFile; fileRef = 0F54DCDD1880F901003EEDBB /* DOMGestureEvent.h */; };
index 8c57d6e4dae6be6406179faeaf424fc15db845ed..6e5ee74bd0a82a8dab1acdf38546ce3e0526d048 100644 (file)
@@ -272,7 +272,7 @@ public:
     virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int) override { return false; }
 
     virtual void dispatchDidHandleOnloadEvents() override { }
-    virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() override { }
+    virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(const URL&) override { }
     virtual void dispatchDidCancelClientRedirect() override { }
     virtual void dispatchWillPerformClientRedirect(const URL&, double, double) override { }
     virtual void dispatchDidChangeLocationWithinPage() override { }
index e04bbf5b08e194f64a45356e7256fab5ab8c6ae9..afd1b10213da516f3496cc2b41f6b233718707bf 100644 (file)
@@ -154,7 +154,7 @@ namespace WebCore {
         virtual bool dispatchDidLoadResourceFromMemoryCache(DocumentLoader*, const ResourceRequest&, const ResourceResponse&, int length) = 0;
 
         virtual void dispatchDidHandleOnloadEvents() = 0;
-        virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() = 0;
+        virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(const URL&) = 0;
         virtual void dispatchDidChangeProvisionalURL() { }
         virtual void dispatchDidCancelClientRedirect() = 0;
         virtual void dispatchWillPerformClientRedirect(const URL&, double interval, double fireDate) = 0;
index 2633f4e0c455994bed2bb3fdf2eaff4a62531289..581988ef96780d089105580ff40f6bc821695a41 100644 (file)
@@ -365,7 +365,7 @@ void ResourceLoader::willSendRequestInternal(ResourceRequest& request, const Res
     m_request = request;
 
     if (!redirectResponse.isNull() && !m_documentLoader->isCommitted())
-        frameLoader()->client().dispatchDidReceiveServerRedirectForProvisionalLoad();
+        frameLoader()->client().dispatchDidReceiveServerRedirectForProvisionalLoad(m_request.url());
 }
 
 void ResourceLoader::willSendRequest(ResourceRequest&& request, const ResourceResponse& redirectResponse, std::function<void(ResourceRequest&&)>&& callback)
index a14ab8f9b1f15417f8f5d0e9d64ada131bd5696d..4bacd55fee3be195fa3074f4b370342e17b4cf99 100644 (file)
 #endif
 
 #if ENABLE(CONTENT_FILTERING)
-#include "MockContentFilter.h"
+#include "MockContentFilterSettings.h"
 #endif
 
 #if ENABLE(WEB_AUDIO)
@@ -358,10 +358,6 @@ Internals::Internals(Document* document)
     enableMockRTCPeerConnectionHandler();
     WebCore::provideUserMediaTo(document->page(), new UserMediaClientMock());
 #endif
-
-#if ENABLE(CONTENT_FILTERING)
-    MockContentFilter::ensureInstalled();
-#endif
 }
 
 Document* Internals::contextDocument() const
index 5e0a0b92fad057236d771366c962728f7df2d139..a6d8f6dbbf2062c1f9165b8c4a15a9e88d665437 100644 (file)
@@ -30,6 +30,7 @@
 
 #include "ContentFilter.h"
 #include "ContentFilterUnblockHandler.h"
+#include "MockContentFilter.h"
 #include <wtf/NeverDestroyed.h>
 
 namespace WebCore {
@@ -45,6 +46,12 @@ void MockContentFilterSettings::reset()
     singleton() = MockContentFilterSettings();
 }
 
+void MockContentFilterSettings::setEnabled(bool enabled)
+{
+    MockContentFilter::ensureInstalled();
+    m_enabled = enabled;
+}
+
 const String& MockContentFilterSettings::unblockRequestURL() const
 {
     static NeverDestroyed<String> unblockRequestURL = makeString(ContentFilter::urlScheme(), "://", unblockURLHost());
index e7ea5b8ec97700fa80b26d79dd7a4bb8735b84f3..d1626898eb253321177e1a3470e8615202536b86 100644 (file)
@@ -48,7 +48,7 @@ public:
         Block
     };
 
-    static MockContentFilterSettings& singleton();
+    WTF_EXPORT_PRIVATE static MockContentFilterSettings& singleton();
     static void reset();
     static const char* unblockURLHost() { return "mock-unblock"; }
 
@@ -57,7 +57,7 @@ public:
     void deref() { }
 
     bool enabled() const { return m_enabled; }
-    void setEnabled(bool enabled) { m_enabled = enabled; }
+    WTF_EXPORT_PRIVATE void setEnabled(bool);
 
     const String& blockedString() const { return m_blockedString; }
     void setBlockedString(const String& blockedString) { m_blockedString = blockedString; }
index 977bba774173655b66d17c0242468734c03c8ceb..dbe72b63bde02c1b323507fd6f79e3f8db9d060e 100644 (file)
@@ -1,3 +1,15 @@
+2015-08-23  Andy Estes  <aestes@apple.com>
+
+        [Content Filtering] REGRESSION (r182356): Provisional URL is incorrect in didReceiveServerRedirectForProvisionalLoadForFrame when Content Filtering is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=147872
+        rdar://problem/22044000
+
+        Reviewed by Dan Bernstein.
+
+        * WebCoreSupport/WebFrameLoaderClient.h:
+        * WebCoreSupport/WebFrameLoaderClient.mm:
+        (WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad): Set provisionalURL using the URL argument.
+
 2015-08-23  Geoffrey Garen  <ggaren@apple.com>
 
         Unreviewed, rolling back in r188803.
index cd1f24ba9c33aa3db60f0ba1d3565eb7aff45079..4a955cb947e51d45e2d985fd6fa5148a1c5a7d89 100644 (file)
@@ -96,7 +96,7 @@ private:
     virtual NSCachedURLResponse* willCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, NSCachedURLResponse*) const override;
 
     virtual void dispatchDidHandleOnloadEvents() override;
-    virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() override;
+    virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(const WebCore::URL&) override;
     virtual void dispatchDidCancelClientRedirect() override;
     virtual void dispatchWillPerformClientRedirect(const WebCore::URL&, double interval, double fireDate) override;
     virtual void dispatchDidChangeLocationWithinPage() override;
index 01c169e6a86e610a82f4b6a78caa2b41a22688f9..222af167b817670411e8adbfd8c651fbbbc69b15 100644 (file)
@@ -578,9 +578,9 @@ void WebFrameLoaderClient::dispatchDidHandleOnloadEvents()
         CallFrameLoadDelegate(implementations->didHandleOnloadEventsForFrameFunc, webView, @selector(webView:didHandleOnloadEventsForFrame:), m_webFrame.get());
 }
 
-void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
+void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad(const URL& url)
 {
-    m_webFrame->_private->provisionalURL = core(m_webFrame.get())->loader().provisionalDocumentLoader()->url().string();
+    m_webFrame->_private->provisionalURL = url.string();
 
     WebView *webView = getWebView(m_webFrame.get());
     WebFrameLoadDelegateImplementationCache* implementations = WebViewGetFrameLoadDelegateImplementations(webView);
index f8c5e854fea52744a2f35278a71c851220500d53..c3c611ab4efa118e2f4f2017d7d5ae1349f89a36 100644 (file)
@@ -1,3 +1,15 @@
+2015-08-23  Andy Estes  <aestes@apple.com>
+
+        [Content Filtering] REGRESSION (r182356): Provisional URL is incorrect in didReceiveServerRedirectForProvisionalLoadForFrame when Content Filtering is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=147872
+        rdar://problem/22044000
+
+        Reviewed by Dan Bernstein.
+
+        * WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad): Added the URL argument.
+        * WebCoreSupport/WebFrameLoaderClient.h:
+
 2015-08-21  Chris Dumez  <cdumez@apple.com>
 
         document.getElementsByTagName should return an HTMLCollection
index 24ef19cdb77c7c4402887092866410170534a5b1..565b73807712eb67097b1fb590425f070ba47ed2 100644 (file)
@@ -330,7 +330,7 @@ void WebFrameLoaderClient::dispatchDidHandleOnloadEvents()
         frameLoadDelegatePriv->didHandleOnloadEventsForFrame(webView, m_webFrame);
 }
 
-void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
+void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad(const URL&)
 {
     WebView* webView = m_webFrame->webView();
     COMPtr<IWebFrameLoadDelegate> frameLoadDelegate;
index 5262671cdf574c20d3e85ee71123672ae4dd66b5..9af931e8afa4623fc051cc4ea1764589ce0fea7d 100644 (file)
@@ -77,7 +77,7 @@ public:
     virtual bool shouldCacheResponse(WebCore::DocumentLoader*, unsigned long identifier, const WebCore::ResourceResponse&, const unsigned char* data, unsigned long long length);
 
     virtual void dispatchDidHandleOnloadEvents() override;
-    virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() override;
+    virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(const WebCore::URL&) override;
     virtual void dispatchDidCancelClientRedirect() override;
     virtual void dispatchWillPerformClientRedirect(const WebCore::URL&, double interval, double fireDate) override;
     virtual void dispatchDidChangeLocationWithinPage() override;
index 40204d202d4eae0621915eb0f95ca6cf4d82d7c9..1cc386d61a6be4498fac300cf0e8f9fe35dd5281 100644 (file)
@@ -1,3 +1,19 @@
+2015-08-23  Andy Estes  <aestes@apple.com>
+
+        [Content Filtering] REGRESSION (r182356): Provisional URL is incorrect in didReceiveServerRedirectForProvisionalLoadForFrame when Content Filtering is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=147872
+        rdar://problem/22044000
+
+        Reviewed by Dan Bernstein.
+        
+        The provisional DocumentLoader request URL does not reflect redirects when content filtering is enabled, but
+        the URL argument passed to dispatchDidReceiveServerRedirectForProvisionalLoad() does, so use it intead.
+
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.cpp:
+        (WebKit::WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad):
+        Sent DidReceiveServerRedirectForProvisionalLoadForFrame using the URL argument.
+        * WebProcess/WebCoreSupport/WebFrameLoaderClient.h:
+
 2015-08-23  Csaba Osztrogon√°c  <ossy@webkit.org>
 
         Typo fix after r188842.
index f906396d7d1be00a627a2066273e81e5153fde94..08375ba25363de98fadda342deccd19a689d6a63 100644 (file)
@@ -278,21 +278,20 @@ void WebFrameLoaderClient::dispatchDidHandleOnloadEvents()
     webPage->injectedBundleLoaderClient().didHandleOnloadEventsForFrame(webPage, m_frame);
 }
 
-void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad()
+void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad(const URL& url)
 {
     WebPage* webPage = m_frame->page();
     if (!webPage)
         return;
 
     WebDocumentLoader& documentLoader = static_cast<WebDocumentLoader&>(*m_frame->coreFrame()->loader().provisionalDocumentLoader());
-    const String& url = documentLoader.url().string();
     RefPtr<API::Object> userData;
 
     // Notify the bundle client.
     webPage->injectedBundleLoaderClient().didReceiveServerRedirectForProvisionalLoadForFrame(webPage, m_frame, userData);
 
     // Notify the UIProcess.
-    webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), documentLoader.navigationID(), url, UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
+    webPage->send(Messages::WebPageProxy::DidReceiveServerRedirectForProvisionalLoadForFrame(m_frame->frameID(), documentLoader.navigationID(), url.string(), UserData(WebProcess::singleton().transformObjectsToHandles(userData.get()).get())));
 }
 
 void WebFrameLoaderClient::dispatchDidChangeProvisionalURL()
index e8869a95a9e808d48701847c302eca8eac0006b9..d111dfa8e006721b4c9d4665d4c27f0e43718753 100644 (file)
@@ -79,7 +79,7 @@ private:
     virtual bool dispatchDidLoadResourceFromMemoryCache(WebCore::DocumentLoader*, const WebCore::ResourceRequest&, const WebCore::ResourceResponse&, int length) override;
     
     virtual void dispatchDidHandleOnloadEvents() override;
-    virtual void dispatchDidReceiveServerRedirectForProvisionalLoad() override;
+    virtual void dispatchDidReceiveServerRedirectForProvisionalLoad(const WebCore::URL&) override;
     virtual void dispatchDidChangeProvisionalURL() override;
     virtual void dispatchDidCancelClientRedirect() override;
     virtual void dispatchWillPerformClientRedirect(const WebCore::URL&, double interval, double fireDate) override;
index d4fe523e0050a9515c05af353da822ef7432535e..d5020796d771c8171d96b44a5ed52421b36d3548 100644 (file)
@@ -1,3 +1,25 @@
+2015-08-23  Andy Estes  <aestes@apple.com>
+
+        [Content Filtering] REGRESSION (r182356): Provisional URL is incorrect in didReceiveServerRedirectForProvisionalLoadForFrame when Content Filtering is enabled
+        https://bugs.webkit.org/show_bug.cgi?id=147872
+        rdar://problem/22044000
+
+        Reviewed by Dan Bernstein.
+        
+        Added an API test.
+
+        * TestWebKitAPI/Configurations/WebProcessPlugIn.xcconfig: Linked libWebCoreTestSupport in order to use MockContentFilter.
+        * TestWebKitAPI/TestWebKitAPI.xcodeproj/project.pbxproj:
+        * TestWebKitAPI/Tests/WebKit2Cocoa/ContentFiltering.mm: Added.
+        (-[ServerRedirectNavigationDelegate webView:didStartProvisionalNavigation:]): Expect the initial request URL.
+        (-[ServerRedirectNavigationDelegate webView:didReceiveServerRedirectForProvisionalNavigation:]): Expect the redirect URL.
+        (-[ServerRedirectNavigationDelegate webView:didCommitNavigation:]):
+        (TEST): Tested that -[WKWebView URL] is updated after a redirect when content filtering is enabled.
+        * TestWebKitAPI/Tests/WebKit2Cocoa/ContentFilteringPlugIn.mm: Added.
+        (+[ServerRedirectPlugIn initialize]): Enable MockContentFilter.
+        * TestWebKitAPI/cocoa/TestProtocol.h: Renamed from Tools/TestWebKitAPI/mac/TestProtocol.h.
+        * TestWebKitAPI/cocoa/TestProtocol.mm: Renamed from Tools/TestWebKitAPI/mac/TestProtocol.mm.
+
 2015-08-23  Andy Estes  <aestes@apple.com>
 
         Fixed the 32-bit Mac build after r188844.
index 539bd3d8bad387a7dda2b5406f344a10ace1819d..76bb4d2e18c924f093c758d8fd67b44d3d6e46e7 100644 (file)
@@ -27,4 +27,6 @@ INFOPLIST_FILE = cocoa/WebProcessPlugIn/Info.plist;
 PRODUCT_NAME = TestWebKitAPI;
 EXECUTABLE_SUFFIX = .bundle;
 WRAPPER_EXTENSION = wkbundle;
-OTHER_LDFLAGS = $(inherited) -framework JavaScriptCore -framework WebKit;
+HEADER_SEARCH_PATHS = $(inherited) $(BUILT_PRODUCTS_DIR)/WebCoreTestSupport;
+OTHER_LDFLAGS = $(inherited) -framework JavaScriptCore -framework WebKit -lWebCoreTestSupport;
+LD_RUNPATH_SEARCH_PATHS[sdk=macosx*] = "@loader_path/../../..";
index c31004b02f40c0fbf186dca3c2b342b745d270f9..38044508352be0d0e1f8afc81ff0b2482dbcc48a 100644 (file)
@@ -90,7 +90,6 @@
                7CCE7EA71A411A1300447C4C /* PlatformWebViewMac.mm in Sources */ = {isa = PBXBuildFile; fileRef = BC90955C125548AA00083756 /* PlatformWebViewMac.mm */; };
                7CCE7EA81A411A1900447C4C /* SyntheticBackingScaleFactorWindow.m in Sources */ = {isa = PBXBuildFile; fileRef = C081224413FC19EC00DC39AE /* SyntheticBackingScaleFactorWindow.m */; };
                7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29AB8AA2164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.mm */; };
-               7CCE7EAA1A411A2400447C4C /* TestProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = 290F4279172A23A500939FF0 /* TestProtocol.mm */; };
                7CCE7EAB1A411A2400447C4C /* WebKitAgnosticTest.mm in Sources */ = {isa = PBXBuildFile; fileRef = C08587BD13FE956C001EF4E5 /* WebKitAgnosticTest.mm */; };
                7CCE7EAC1A411A3400447C4C /* Counters.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 7C6BBD8B19CEA63000C1F5E0 /* Counters.cpp */; };
                7CCE7EAD1A411A3400447C4C /* JavaScriptTest.cpp in Sources */ = {isa = PBXBuildFile; fileRef = C0ADBE7A12FCA4D000D2C129 /* JavaScriptTest.cpp */; };
                A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */; };
                A13EBBB11B87438000097110 /* BundleParameters.mm in Sources */ = {isa = PBXBuildFile; fileRef = A13EBBAC1B87436F00097110 /* BundleParameters.mm */; };
                A14FC5851B89739100D107EB /* WKWebViewConfigurationExtras.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */; };
+               A14FC5881B8991BF00D107EB /* ContentFiltering.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC5861B8991B600D107EB /* ContentFiltering.mm */; };
+               A14FC58B1B89927100D107EB /* ContentFilteringPlugIn.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC5891B89927100D107EB /* ContentFilteringPlugIn.mm */; };
+               A14FC5901B8AE36F00D107EB /* TestProtocol.mm in Sources */ = {isa = PBXBuildFile; fileRef = A14FC58E1B8AE36500D107EB /* TestProtocol.mm */; };
                A57A34F216AF6B2B00C2501F /* PageVisibilityStateWithWindowChanges.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A57A34F116AF69E200C2501F /* PageVisibilityStateWithWindowChanges.html */; };
                A5E2027515B21F6E00C13E14 /* WindowlessWebViewWithMedia.html in Copy Resources */ = {isa = PBXBuildFile; fileRef = A5E2027015B2180600C13E14 /* WindowlessWebViewWithMedia.html */; };
                B55AD1D5179F3B3000AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp in Sources */ = {isa = PBXBuildFile; fileRef = B55AD1D3179F3ABF00AC1494 /* PreventImageLoadWithAutoResizing_Bundle.cpp */; };
                290A9BB81735F42300D71BBC /* OpenNewWindow.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = OpenNewWindow.html; sourceTree = "<group>"; };
                290F4274172A1FDE00939FF0 /* custom-protocol-sync-xhr.html */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.html; path = "custom-protocol-sync-xhr.html"; sourceTree = "<group>"; };
                290F4276172A232C00939FF0 /* CustomProtocolsSyncXHRTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = CustomProtocolsSyncXHRTest.mm; sourceTree = "<group>"; };
-               290F4279172A23A500939FF0 /* TestProtocol.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = TestProtocol.mm; sourceTree = "<group>"; };
-               290F427A172A23A500939FF0 /* TestProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = TestProtocol.h; sourceTree = "<group>"; };
                291861FD17BD4DC700D4E41E /* StopLoadingFromDidFinishLoading.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = StopLoadingFromDidFinishLoading.mm; sourceTree = "<group>"; };
                2943BE84161DFEB800999E3D /* UserContentTest.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = UserContentTest.mm; path = WebKit2ObjC/UserContentTest.mm; sourceTree = "<group>"; };
                297234B2173AD04800983601 /* CustomProtocolsInvalidScheme.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = CustomProtocolsInvalidScheme.mm; path = WebKit2ObjC/CustomProtocolsInvalidScheme.mm; sourceTree = "<group>"; };
                A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = BundleParametersPlugIn.mm; sourceTree = "<group>"; };
                A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WKWebViewConfigurationExtras.mm; sourceTree = "<group>"; };
                A14FC5841B89739100D107EB /* WKWebViewConfigurationExtras.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = WKWebViewConfigurationExtras.h; sourceTree = "<group>"; };
+               A14FC5861B8991B600D107EB /* ContentFiltering.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentFiltering.mm; sourceTree = "<group>"; };
+               A14FC5891B89927100D107EB /* ContentFilteringPlugIn.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = ContentFilteringPlugIn.mm; sourceTree = "<group>"; };
+               A14FC58D1B8AE36500D107EB /* TestProtocol.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = TestProtocol.h; path = cocoa/TestProtocol.h; sourceTree = "<group>"; };
+               A14FC58E1B8AE36500D107EB /* TestProtocol.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; name = TestProtocol.mm; path = cocoa/TestProtocol.mm; sourceTree = "<group>"; };
                A1A4FE5D18DD3DB700B5EA8A /* Download.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = Download.mm; sourceTree = "<group>"; };
                A1FDFD2E19C288BB005148A4 /* WKImageCreateCGImageCrash.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = WKImageCreateCGImageCrash.cpp; sourceTree = "<group>"; };
                A57A34EF16AF677200C2501F /* PageVisibilityStateWithWindowChanges.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = PageVisibilityStateWithWindowChanges.mm; sourceTree = "<group>"; };
                        children = (
                                A13EBB441B87332B00097110 /* WebProcessPlugIn */,
                                0F139E721A423A2B00F590F5 /* PlatformUtilitiesCocoa.mm */,
+                               A14FC58D1B8AE36500D107EB /* TestProtocol.h */,
+                               A14FC58E1B8AE36500D107EB /* TestProtocol.mm */,
                                A14FC5841B89739100D107EB /* WKWebViewConfigurationExtras.h */,
                                A14FC5831B89739100D107EB /* WKWebViewConfigurationExtras.mm */,
                        );
                                7CEFA9641AC0B9E200B910FD /* _WKUserContentExtensionStore.mm */,
                                A13EBBAC1B87436F00097110 /* BundleParameters.mm */,
                                A13EBBAE1B87436F00097110 /* BundleParametersPlugIn.mm */,
+                               A14FC5861B8991B600D107EB /* ContentFiltering.mm */,
+                               A14FC5891B89927100D107EB /* ContentFilteringPlugIn.mm */,
                                A1A4FE5D18DD3DB700B5EA8A /* Download.mm */,
                                2D1FE0AF1AD465C1006CD9E6 /* FixedLayoutSize.mm */,
                                37D36ED61AF42ECD00BAF5D9 /* LoadAlternateHTMLString.mm */,
                                C081224413FC19EC00DC39AE /* SyntheticBackingScaleFactorWindow.m */,
                                29AB8AA3164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.h */,
                                29AB8AA2164C7A9300D49BEC /* TestBrowsingContextLoadDelegate.mm */,
-                               290F427A172A23A500939FF0 /* TestProtocol.h */,
-                               290F4279172A23A500939FF0 /* TestProtocol.mm */,
                                C08587BE13FE956C001EF4E5 /* WebKitAgnosticTest.h */,
                                C08587BD13FE956C001EF4E5 /* WebKitAgnosticTest.mm */,
                        );
                                7CCE7F3A1A411B8E00447C4C /* MathExtras.cpp in Sources */,
                                7C89D2AC1A69B80D003A5FDE /* WKPageConfiguration.cpp in Sources */,
                                7CCE7F391A411B8E00447C4C /* MD5.cpp in Sources */,
+                               A14FC5901B8AE36F00D107EB /* TestProtocol.mm in Sources */,
                                7CCE7F3B1A411B8E00447C4C /* MediaTime.cpp in Sources */,
                                7CCE7EB21A411A5100447C4C /* MemoryCacheAddImageToCacheIOS.mm in Sources */,
                                7CCE7EC51A411A7E00447C4C /* MemoryCacheDisableWithinResourceLoadDelegate.mm in Sources */,
                                7CCE7F3C1A411B8E00447C4C /* MetaAllocator.cpp in Sources */,
                                7CCE7F011A411AE600447C4C /* MouseMoveAfterCrash.cpp in Sources */,
                                7CCE7F241A411AF600447C4C /* Navigation.mm in Sources */,
+                               A14FC5881B8991BF00D107EB /* ContentFiltering.mm in Sources */,
                                7CCE7F021A411AE600447C4C /* NewFirstVisuallyNonEmptyLayout.cpp in Sources */,
                                7CCE7F031A411AE600447C4C /* NewFirstVisuallyNonEmptyLayoutFails.cpp in Sources */,
                                7CCE7F041A411AE600447C4C /* NewFirstVisuallyNonEmptyLayoutForImages.cpp in Sources */,
                                7CCE7F491A411B8E00447C4C /* TemporaryChange.cpp in Sources */,
                                7CCE7F161A411AE600447C4C /* TerminateTwice.cpp in Sources */,
                                7CCE7EA91A411A1D00447C4C /* TestBrowsingContextLoadDelegate.mm in Sources */,
-                               7CCE7EAA1A411A2400447C4C /* TestProtocol.mm in Sources */,
                                7CCE7EAE1A411A3400447C4C /* TestsController.cpp in Sources */,
                                CE3524F91B1441C40028A7C5 /* TextFieldDidBeginAndEndEditing.cpp in Sources */,
                                7CCE7EDD1A411A9200447C4C /* TimeRanges.cpp in Sources */,
                                A13EBBAA1B87428D00097110 /* WebProcessPlugIn.mm in Sources */,
                                A13EBBB01B87436F00097110 /* BundleParametersPlugIn.mm in Sources */,
                                A13EBBAB1B87434600097110 /* PlatformUtilitiesCocoa.mm in Sources */,
+                               A14FC58B1B89927100D107EB /* ContentFilteringPlugIn.mm in Sources */,
                        );
                        runOnlyForDeploymentPostprocessing = 0;
                };
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ContentFiltering.mm b/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ContentFiltering.mm
new file mode 100644 (file)
index 0000000..1de3781
--- /dev/null
@@ -0,0 +1,78 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if WK_API_ENABLED
+
+#import "PlatformUtilities.h"
+#import "TestProtocol.h"
+#import "WKWebViewConfigurationExtras.h"
+#import <WebKit/WKBrowsingContextController.h>
+#import <WebKit/WKNavigationDelegate.h>
+#import <WebKit/WKWebView.h>
+#import <wtf/RetainPtr.h>
+
+static bool isDone = false;
+
+@interface ServerRedirectNavigationDelegate : NSObject <WKNavigationDelegate>
+@end
+
+@implementation ServerRedirectNavigationDelegate
+
+- (void)webView:(WKWebView *)webView didStartProvisionalNavigation:(WKNavigation *)navigation
+{
+    EXPECT_WK_STREQ(webView.URL.absoluteString, @"http://redirect/?pass");
+}
+
+- (void)webView:(WKWebView *)webView didReceiveServerRedirectForProvisionalNavigation:(WKNavigation *)navigation
+{
+    EXPECT_WK_STREQ(webView.URL.absoluteString, @"http://pass/");
+}
+
+- (void)webView:(WKWebView *)webView didCommitNavigation:(WKNavigation *)navigation
+{
+    isDone = true;
+}
+
+@end
+
+TEST(ContentFiltering, ServerRedirect)
+{
+    [NSURLProtocol registerClass:[TestProtocol class]];
+    [WKBrowsingContextController registerSchemeForCustomProtocol:[TestProtocol scheme]];
+
+    auto configuration = retainPtr([WKWebViewConfiguration testwebkitapi_configurationWithTestPlugInClassName:@"ServerRedirectPlugIn"]);
+    auto webView = adoptNS([[WKWebView alloc] initWithFrame:CGRectZero configuration:configuration.get()]);
+    auto navigationDelegate = adoptNS([[ServerRedirectNavigationDelegate alloc] init]);
+    [webView setNavigationDelegate:navigationDelegate.get()];
+    [webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"http://redirect?pass"]]];
+    TestWebKitAPI::Util::run(&isDone);
+
+    [WKBrowsingContextController unregisterSchemeForCustomProtocol:[TestProtocol scheme]];
+    [NSURLProtocol unregisterClass:[TestProtocol class]];
+}
+
+#endif // WK_API_ENABLED
diff --git a/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ContentFilteringPlugIn.mm b/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/ContentFilteringPlugIn.mm
new file mode 100644 (file)
index 0000000..43acd52
--- /dev/null
@@ -0,0 +1,51 @@
+/*
+ * Copyright (C) 2015 Apple Inc. All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ *
+ * THIS SOFTWARE IS PROVIDED BY APPLE INC. AND ITS CONTRIBUTORS ``AS IS''
+ * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
+ * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL APPLE INC. OR ITS CONTRIBUTORS
+ * BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
+ * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
+ * SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
+ * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
+ * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
+ * THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#import "config.h"
+
+#if WK_API_ENABLED
+
+#import "MockContentFilterSettings.h"
+#import <WebKit/WKWebProcessPlugIn.h>
+
+@interface ServerRedirectPlugIn : NSObject <WKWebProcessPlugIn>
+@end
+
+@implementation ServerRedirectPlugIn
+
++ (void)initialize
+{
+    using MockContentFilterSettings = WebCore::MockContentFilterSettings;
+    using Decision = MockContentFilterSettings::Decision;
+    using DecisionPoint = MockContentFilterSettings::DecisionPoint;
+    MockContentFilterSettings& settings = MockContentFilterSettings::singleton();
+    settings.setEnabled(true);
+    settings.setDecision(Decision::Allow);
+    settings.setDecisionPoint(DecisionPoint::AfterAddData);
+}
+
+@end
+
+#endif // WK_API_ENABLED