Diff
Modified: trunk/Source/WebKit/ChangeLog (226324 => 226325)
--- trunk/Source/WebKit/ChangeLog 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Source/WebKit/ChangeLog 2018-01-02 17:21:37 UTC (rev 226325)
@@ -1,5 +1,32 @@
2018-01-02 Alex Christensen <achristen...@webkit.org>
+ Use new WebsiteDataStore passed in through decidePolicyForNavigation SPI
+ https://bugs.webkit.org/show_bug.cgi?id=180897
+ <rdar://problem/35535328>
+
+ Reviewed by Brent Fulgham.
+
+ * Shared/WebsitePoliciesData.cpp:
+ (WebKit::WebsitePoliciesData::applyToDocumentLoader):
+ * UIProcess/Cocoa/NavigationState.mm:
+ (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
+ * UIProcess/WebPageProxy.cpp:
+ (WebKit::WebPageProxy::changeWebsiteDataStore):
+ * UIProcess/WebPageProxy.h:
+ * UIProcess/WebProcessPool.cpp:
+ (WebKit::WebProcessPool::pageBeginUsingWebsiteDataStore):
+ (WebKit::WebProcessPool::pageEndUsingWebsiteDataStore):
+ (WebKit::WebProcessPool::pageAddedToProcess): Deleted.
+ (WebKit::WebProcessPool::pageRemovedFromProcess): Deleted.
+ * UIProcess/WebProcessPool.h:
+ * UIProcess/WebProcessProxy.cpp:
+ (WebKit::WebProcessProxy::addExistingWebPage):
+ (WebKit::WebProcessProxy::removeWebPage):
+ * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm:
+ (WebKit::WebFrameNetworkingContext::ensureWebsiteDataStoreSession):
+
+2018-01-02 Alex Christensen <achristen...@webkit.org>
+
Only use CookieStorageShim when we aren't using NetworkSession
https://bugs.webkit.org/show_bug.cgi?id=180766
Modified: trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp (226324 => 226325)
--- trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp 2018-01-02 17:21:37 UTC (rev 226325)
@@ -27,7 +27,10 @@
#include "WebsitePoliciesData.h"
#include "ArgumentCoders.h"
+#include "WebProcess.h"
#include <WebCore/DocumentLoader.h>
+#include <WebCore/Frame.h>
+#include <WebCore/Page.h>
namespace WebKit {
@@ -112,6 +115,16 @@
documentLoader.setAutoplayPolicy(WebCore::AutoplayPolicy::Deny);
break;
}
+
+ if (websitePolicies.websiteDataStoreParameters) {
+ if (auto* frame = documentLoader.frame()) {
+ if (auto* page = frame->page()) {
+ auto sessionID = websitePolicies.websiteDataStoreParameters->networkSessionParameters.sessionID;
+ WebProcess::singleton().addWebsiteDataStore(WTFMove(*websitePolicies.websiteDataStoreParameters));
+ page->setSessionID(sessionID);
+ }
+ }
+ }
}
}
Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (226324 => 226325)
--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm 2018-01-02 17:21:37 UTC (rev 226325)
@@ -33,6 +33,7 @@
#import "APINavigationResponse.h"
#import "APIString.h"
#import "APIURL.h"
+#import "APIWebsiteDataStore.h"
#import "AuthenticationDecisionListener.h"
#import "CompletionHandlerCallChecker.h"
#import "Logging.h"
@@ -460,7 +461,7 @@
auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), delegateHasWebsitePolicies ? @selector(_webView:decidePolicyForNavigationAction:decisionHandler:) : @selector(webView:decidePolicyForNavigationAction:decisionHandler:));
- auto decisionHandlerWithPolicies = [localListener = WTFMove(listener), navigationAction = navigationAction.copyRef(), checker = WTFMove(checker), mainFrameURLString](WKNavigationActionPolicy actionPolicy, _WKWebsitePolicies *websitePolicies) mutable {
+ auto decisionHandlerWithPolicies = [localListener = WTFMove(listener), navigationAction = navigationAction.copyRef(), checker = WTFMove(checker), mainFrameURLString, webPageProxy = makeRef(webPageProxy)](WKNavigationActionPolicy actionPolicy, _WKWebsitePolicies *websitePolicies) mutable {
if (checker->completionHandlerHasBeenCalled())
return;
checker->didCallCompletionHandler();
@@ -472,6 +473,7 @@
auto& sessionID = data->websiteDataStoreParameters->networkSessionParameters.sessionID;
if (!sessionID.isEphemeral() && sessionID != PAL::SessionID::defaultSessionID())
[NSException raise:NSInvalidArgumentException format:@"_WKWebsitePolicies.websiteDataStore must be nil, default, or non-persistent."];
+ webPageProxy->changeWebsiteDataStore(websitePolicies->_websitePolicies->websiteDataStore()->websiteDataStore());
}
}
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.cpp (226324 => 226325)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.cpp 2018-01-02 17:21:37 UTC (rev 226325)
@@ -444,6 +444,13 @@
return m_websiteDataStore->sessionID();
}
+void WebPageProxy::changeWebsiteDataStore(WebsiteDataStore& websiteDataStore)
+{
+ m_process->processPool().pageEndUsingWebsiteDataStore(*this);
+ m_websiteDataStore = websiteDataStore;
+ m_process->processPool().pageBeginUsingWebsiteDataStore(*this);
+}
+
const API::PageConfiguration& WebPageProxy::configuration() const
{
return m_configuration.get();
Modified: trunk/Source/WebKit/UIProcess/WebPageProxy.h (226324 => 226325)
--- trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Source/WebKit/UIProcess/WebPageProxy.h 2018-01-02 17:21:37 UTC (rev 226325)
@@ -324,6 +324,7 @@
WebNavigationState& navigationState() { return *m_navigationState.get(); }
WebsiteDataStore& websiteDataStore() { return m_websiteDataStore; }
+ void changeWebsiteDataStore(WebsiteDataStore&);
#if ENABLE(DATA_DETECTION)
NSArray *dataDetectionResults() { return m_dataDetectionResults.get(); }
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.cpp (226324 => 226325)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.cpp 2018-01-02 17:21:37 UTC (rev 226325)
@@ -1045,7 +1045,7 @@
}
#endif
-void WebProcessPool::pageAddedToProcess(WebPageProxy& page)
+void WebProcessPool::pageBeginUsingWebsiteDataStore(WebPageProxy& page)
{
auto result = m_sessionToPagesMap.add(page.sessionID(), HashSet<WebPageProxy*>()).iterator->value.add(&page);
ASSERT_UNUSED(result, result.isNewEntry);
@@ -1074,7 +1074,7 @@
#endif
}
-void WebProcessPool::pageRemovedFromProcess(WebPageProxy& page)
+void WebProcessPool::pageEndUsingWebsiteDataStore(WebPageProxy& page)
{
auto sessionID = page.sessionID();
auto iterator = m_sessionToPagesMap.find(sessionID);
Modified: trunk/Source/WebKit/UIProcess/WebProcessPool.h (226324 => 226325)
--- trunk/Source/WebKit/UIProcess/WebProcessPool.h 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Source/WebKit/UIProcess/WebProcessPool.h 2018-01-02 17:21:37 UTC (rev 226325)
@@ -176,8 +176,8 @@
Ref<WebPageProxy> createWebPage(PageClient&, Ref<API::PageConfiguration>&&);
- void pageAddedToProcess(WebPageProxy&);
- void pageRemovedFromProcess(WebPageProxy&);
+ void pageBeginUsingWebsiteDataStore(WebPageProxy&);
+ void pageEndUsingWebsiteDataStore(WebPageProxy&);
const String& injectedBundlePath() const { return m_configuration->injectedBundlePath(); }
Modified: trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp (226324 => 226325)
--- trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp 2018-01-02 17:21:37 UTC (rev 226325)
@@ -360,7 +360,7 @@
ASSERT(!m_pageMap.contains(pageID));
ASSERT(!globalPageMap().contains(pageID));
- m_processPool->pageAddedToProcess(webPage);
+ m_processPool->pageBeginUsingWebsiteDataStore(webPage);
m_pageMap.set(pageID, &webPage);
globalPageMap().set(pageID, &webPage);
@@ -375,7 +375,7 @@
removedPage = globalPageMap().take(pageID);
ASSERT_UNUSED(removedPage, removedPage == &webPage);
- m_processPool->pageRemovedFromProcess(webPage);
+ m_processPool->pageEndUsingWebsiteDataStore(webPage);
updateBackgroundResponsivenessTimer();
Modified: trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm (226324 => 226325)
--- trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm 2018-01-02 17:21:37 UTC (rev 226325)
@@ -62,10 +62,8 @@
SandboxExtension::consumePermanently(parameters.cookieStoragePathExtensionHandle);
RetainPtr<CFHTTPCookieStorageRef> uiProcessCookieStorage;
- if (!sessionID.isEphemeral())
+ if (!sessionID.isEphemeral() && !parameters.uiProcessCookieStorageIdentifier.isEmpty())
uiProcessCookieStorage = cookieStorageFromIdentifyingData(parameters.uiProcessCookieStorageIdentifier);
- else
- ASSERT(parameters.uiProcessCookieStorageIdentifier.isEmpty());
NetworkStorageSession::ensureSession(sessionID, base + '.' + String::number(sessionID.sessionID()), WTFMove(uiProcessCookieStorage));
Modified: trunk/Tools/ChangeLog (226324 => 226325)
--- trunk/Tools/ChangeLog 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Tools/ChangeLog 2018-01-02 17:21:37 UTC (rev 226325)
@@ -1 +1,18 @@
+2018-01-02 Alex Christensen <achristen...@webkit.org>
+
+ Use new WebsiteDataStore passed in through decidePolicyForNavigation SPI
+ https://bugs.webkit.org/show_bug.cgi?id=180897
+ <rdar://problem/35535328>
+
+ Reviewed by Brent Fulgham.
+
+ Test two forms of storage to be sure we are using a different WebsiteDataStore: cookies and sessionStorage.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
+ (-[WebsitePoliciesWebsiteDataStoreDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]):
+ (-[WebsitePoliciesWebsiteDataStoreDelegate webView:startURLSchemeTask:]):
+ (-[WebsitePoliciesWebsiteDataStoreDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]):
+ (websiteDataStoreTestWebView):
+ (TEST):
+
== Rolled over to ChangeLog-2018-01-01 ==
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (226324 => 226325)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm 2018-01-02 17:18:17 UTC (rev 226324)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm 2018-01-02 17:21:37 UTC (rev 226325)
@@ -789,7 +789,7 @@
static bool done;
-@interface WebsitePoliciesWebsiteDataStoreDelegate : NSObject <WKNavigationDelegatePrivate, WKURLSchemeHandler>
+@interface WebsitePoliciesWebsiteDataStoreDelegate : NSObject <WKNavigationDelegatePrivate, WKURLSchemeHandler, WKUIDelegate>
@end
@implementation WebsitePoliciesWebsiteDataStoreDelegate
@@ -796,7 +796,8 @@
- (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler
{
- if ([navigationAction.request.URL.path isEqualToString:@"/invalid"]) {
+ NSURL *url = ""
+ if ([url.path isEqualToString:@"/invalid"]) {
_WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease];
websitePolicies.websiteDataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:[[[_WKWebsiteDataStoreConfiguration alloc] init] autorelease]] autorelease];
@@ -810,10 +811,22 @@
done = true;
}
+ if ([url.path isEqualToString:@"/checkStorage"] || [url.path isEqualToString:@"/checkCookies"]) {
+ _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease];
+ websitePolicies.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
+ decisionHandler(WKNavigationActionPolicyAllow, websitePolicies);
+ }
}
-- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
+- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)task
{
+ NSURL *url = ""
+ if ([url.path isEqualToString:@"/checkStorage"]) {
+ NSString *html = @"<script>var oldValue = window.sessionStorage['storageKey']; window.sessionStorage['storageKey'] = 'value'; alert('old value: <' + (oldValue ? 'fail' : '') + '>');</script>";
+ [task didReceiveResponse:[[NSURLResponse alloc] initWithURL:url MIMEType:@"text/html" expectedContentLength:html.length textEncodingName:nil]];
+ [task didReceiveData:[html dataUsingEncoding:NSUTF8StringEncoding]];
+ [task didFinish];
+ }
}
- (void)webView:(WKWebView *)webView stopURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask
@@ -820,16 +833,30 @@
{
}
+- (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler
+{
+ EXPECT_STREQ(message.UTF8String, "old value: <>");
+ completionHandler();
+ done = true;
+}
+
@end
-TEST(WebKit, UpdateWebsitePoliciesInvalid)
+RetainPtr<WKWebView> websiteDataStoreTestWebView()
{
auto delegate = adoptNS([[WebsitePoliciesWebsiteDataStoreDelegate alloc] init]);
auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]);
[configuration setURLSchemeHandler:delegate.get() forURLScheme:@"test"];
+ [configuration setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]];
auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]);
[webView setNavigationDelegate:delegate.get()];
+ [webView setUIDelegate:delegate.get()];
+ return webView;
+}
+TEST(WebKit, UpdateWebsitePoliciesInvalid)
+{
+ auto webView = websiteDataStoreTestWebView();
auto policies = adoptNS([[_WKWebsitePolicies alloc] init]);
[policies setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]];
bool sawException = false;
@@ -844,6 +871,15 @@
TestWebKitAPI::Util::run(&done);
}
-// FIXME: Use _WKWebsitePolicies.websiteDataStore and test that it is used.
+TEST(WebKit, WebsitePoliciesDataStore)
+{
+ auto cookieWebView = websiteDataStoreTestWebView();
+ NSString *alertOldCookie = @"<script>var oldCookie = document.cookie; document.cookie = 'key=value'; alert('old value: <' + oldCookie + '>');</script>";
+ [cookieWebView loadHTMLString:alertOldCookie baseURL:[NSURL URLWithString:@"http://example.com/checkCookies"]];
+ TestWebKitAPI::Util::run(&done);
+ done = false;
+ [cookieWebView loadHTMLString:alertOldCookie baseURL:[NSURL URLWithString:@"http://example.com/checkCookies"]];
+ TestWebKitAPI::Util::run(&done);
+}
#endif // WK_API_ENABLED