Changeset 226325 in webkit
- Timestamp:
- Jan 2, 2018 9:21:37 AM (6 years ago)
- Location:
- trunk
- Files:
-
- 11 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Source/WebKit/ChangeLog
r226324 r226325 1 2018-01-02 Alex Christensen <achristensen@webkit.org> 2 3 Use new WebsiteDataStore passed in through decidePolicyForNavigation SPI 4 https://bugs.webkit.org/show_bug.cgi?id=180897 5 <rdar://problem/35535328> 6 7 Reviewed by Brent Fulgham. 8 9 * Shared/WebsitePoliciesData.cpp: 10 (WebKit::WebsitePoliciesData::applyToDocumentLoader): 11 * UIProcess/Cocoa/NavigationState.mm: 12 (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction): 13 * UIProcess/WebPageProxy.cpp: 14 (WebKit::WebPageProxy::changeWebsiteDataStore): 15 * UIProcess/WebPageProxy.h: 16 * UIProcess/WebProcessPool.cpp: 17 (WebKit::WebProcessPool::pageBeginUsingWebsiteDataStore): 18 (WebKit::WebProcessPool::pageEndUsingWebsiteDataStore): 19 (WebKit::WebProcessPool::pageAddedToProcess): Deleted. 20 (WebKit::WebProcessPool::pageRemovedFromProcess): Deleted. 21 * UIProcess/WebProcessPool.h: 22 * UIProcess/WebProcessProxy.cpp: 23 (WebKit::WebProcessProxy::addExistingWebPage): 24 (WebKit::WebProcessProxy::removeWebPage): 25 * WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm: 26 (WebKit::WebFrameNetworkingContext::ensureWebsiteDataStoreSession): 27 1 28 2018-01-02 Alex Christensen <achristensen@webkit.org> 2 29 -
trunk/Source/WebKit/Shared/WebsitePoliciesData.cpp
r225989 r226325 28 28 29 29 #include "ArgumentCoders.h" 30 #include "WebProcess.h" 30 31 #include <WebCore/DocumentLoader.h> 32 #include <WebCore/Frame.h> 33 #include <WebCore/Page.h> 31 34 32 35 namespace WebKit { … … 113 116 break; 114 117 } 118 119 if (websitePolicies.websiteDataStoreParameters) { 120 if (auto* frame = documentLoader.frame()) { 121 if (auto* page = frame->page()) { 122 auto sessionID = websitePolicies.websiteDataStoreParameters->networkSessionParameters.sessionID; 123 WebProcess::singleton().addWebsiteDataStore(WTFMove(*websitePolicies.websiteDataStoreParameters)); 124 page->setSessionID(sessionID); 125 } 126 } 127 } 115 128 } 116 129 -
trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm
r225989 r226325 34 34 #import "APIString.h" 35 35 #import "APIURL.h" 36 #import "APIWebsiteDataStore.h" 36 37 #import "AuthenticationDecisionListener.h" 37 38 #import "CompletionHandlerCallChecker.h" … … 461 462 auto checker = CompletionHandlerCallChecker::create(navigationDelegate.get(), delegateHasWebsitePolicies ? @selector(_webView:decidePolicyForNavigationAction:decisionHandler:) : @selector(webView:decidePolicyForNavigationAction:decisionHandler:)); 462 463 463 auto decisionHandlerWithPolicies = [localListener = WTFMove(listener), navigationAction = navigationAction.copyRef(), checker = WTFMove(checker), mainFrameURLString ](WKNavigationActionPolicy actionPolicy, _WKWebsitePolicies *websitePolicies) mutable {464 auto decisionHandlerWithPolicies = [localListener = WTFMove(listener), navigationAction = navigationAction.copyRef(), checker = WTFMove(checker), mainFrameURLString, webPageProxy = makeRef(webPageProxy)](WKNavigationActionPolicy actionPolicy, _WKWebsitePolicies *websitePolicies) mutable { 464 465 if (checker->completionHandlerHasBeenCalled()) 465 466 return; … … 473 474 if (!sessionID.isEphemeral() && sessionID != PAL::SessionID::defaultSessionID()) 474 475 [NSException raise:NSInvalidArgumentException format:@"_WKWebsitePolicies.websiteDataStore must be nil, default, or non-persistent."]; 476 webPageProxy->changeWebsiteDataStore(websitePolicies->_websitePolicies->websiteDataStore()->websiteDataStore()); 475 477 } 476 478 } -
trunk/Source/WebKit/UIProcess/WebPageProxy.cpp
r226323 r226325 445 445 } 446 446 447 void WebPageProxy::changeWebsiteDataStore(WebsiteDataStore& websiteDataStore) 448 { 449 m_process->processPool().pageEndUsingWebsiteDataStore(*this); 450 m_websiteDataStore = websiteDataStore; 451 m_process->processPool().pageBeginUsingWebsiteDataStore(*this); 452 } 453 447 454 const API::PageConfiguration& WebPageProxy::configuration() const 448 455 { -
trunk/Source/WebKit/UIProcess/WebPageProxy.h
r226323 r226325 325 325 326 326 WebsiteDataStore& websiteDataStore() { return m_websiteDataStore; } 327 void changeWebsiteDataStore(WebsiteDataStore&); 327 328 328 329 #if ENABLE(DATA_DETECTION) -
trunk/Source/WebKit/UIProcess/WebProcessPool.cpp
r226257 r226325 1046 1046 #endif 1047 1047 1048 void WebProcessPool::page AddedToProcess(WebPageProxy& page)1048 void WebProcessPool::pageBeginUsingWebsiteDataStore(WebPageProxy& page) 1049 1049 { 1050 1050 auto result = m_sessionToPagesMap.add(page.sessionID(), HashSet<WebPageProxy*>()).iterator->value.add(&page); … … 1075 1075 } 1076 1076 1077 void WebProcessPool::page RemovedFromProcess(WebPageProxy& page)1077 void WebProcessPool::pageEndUsingWebsiteDataStore(WebPageProxy& page) 1078 1078 { 1079 1079 auto sessionID = page.sessionID(); -
trunk/Source/WebKit/UIProcess/WebProcessPool.h
r226257 r226325 177 177 Ref<WebPageProxy> createWebPage(PageClient&, Ref<API::PageConfiguration>&&); 178 178 179 void page AddedToProcess(WebPageProxy&);180 void page RemovedFromProcess(WebPageProxy&);179 void pageBeginUsingWebsiteDataStore(WebPageProxy&); 180 void pageEndUsingWebsiteDataStore(WebPageProxy&); 181 181 182 182 const String& injectedBundlePath() const { return m_configuration->injectedBundlePath(); } -
trunk/Source/WebKit/UIProcess/WebProcessProxy.cpp
r225984 r226325 361 361 ASSERT(!globalPageMap().contains(pageID)); 362 362 363 m_processPool->page AddedToProcess(webPage);363 m_processPool->pageBeginUsingWebsiteDataStore(webPage); 364 364 365 365 m_pageMap.set(pageID, &webPage); … … 376 376 ASSERT_UNUSED(removedPage, removedPage == &webPage); 377 377 378 m_processPool->page RemovedFromProcess(webPage);378 m_processPool->pageEndUsingWebsiteDataStore(webPage); 379 379 380 380 updateBackgroundResponsivenessTimer(); -
trunk/Source/WebKit/WebProcess/WebCoreSupport/mac/WebFrameNetworkingContext.mm
r224827 r226325 63 63 64 64 RetainPtr<CFHTTPCookieStorageRef> uiProcessCookieStorage; 65 if (!sessionID.isEphemeral() )65 if (!sessionID.isEphemeral() && !parameters.uiProcessCookieStorageIdentifier.isEmpty()) 66 66 uiProcessCookieStorage = cookieStorageFromIdentifyingData(parameters.uiProcessCookieStorageIdentifier); 67 else68 ASSERT(parameters.uiProcessCookieStorageIdentifier.isEmpty());69 67 70 68 NetworkStorageSession::ensureSession(sessionID, base + '.' + String::number(sessionID.sessionID()), WTFMove(uiProcessCookieStorage)); -
trunk/Tools/ChangeLog
r226320 r226325 1 2018-01-02 Alex Christensen <achristensen@webkit.org> 2 3 Use new WebsiteDataStore passed in through decidePolicyForNavigation SPI 4 https://bugs.webkit.org/show_bug.cgi?id=180897 5 <rdar://problem/35535328> 6 7 Reviewed by Brent Fulgham. 8 9 Test two forms of storage to be sure we are using a different WebsiteDataStore: cookies and sessionStorage. 10 11 * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm: 12 (-[WebsitePoliciesWebsiteDataStoreDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]): 13 (-[WebsitePoliciesWebsiteDataStoreDelegate webView:startURLSchemeTask:]): 14 (-[WebsitePoliciesWebsiteDataStoreDelegate webView:runJavaScriptAlertPanelWithMessage:initiatedByFrame:completionHandler:]): 15 (websiteDataStoreTestWebView): 16 (TEST): 17 1 18 == Rolled over to ChangeLog-2018-01-01 == -
trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm
r225989 r226325 790 790 static bool done; 791 791 792 @interface WebsitePoliciesWebsiteDataStoreDelegate : NSObject <WKNavigationDelegatePrivate, WKURLSchemeHandler >792 @interface WebsitePoliciesWebsiteDataStoreDelegate : NSObject <WKNavigationDelegatePrivate, WKURLSchemeHandler, WKUIDelegate> 793 793 @end 794 794 … … 797 797 - (void)_webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy, _WKWebsitePolicies *))decisionHandler 798 798 { 799 if ([navigationAction.request.URL.path isEqualToString:@"/invalid"]) { 799 NSURL *url = navigationAction.request.URL; 800 if ([url.path isEqualToString:@"/invalid"]) { 800 801 _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease]; 801 802 websitePolicies.websiteDataStore = [[[WKWebsiteDataStore alloc] _initWithConfiguration:[[[_WKWebsiteDataStoreConfiguration alloc] init] autorelease]] autorelease]; … … 811 812 done = true; 812 813 } 813 } 814 815 - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)urlSchemeTask 816 { 814 if ([url.path isEqualToString:@"/checkStorage"] || [url.path isEqualToString:@"/checkCookies"]) { 815 _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease]; 816 websitePolicies.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore]; 817 decisionHandler(WKNavigationActionPolicyAllow, websitePolicies); 818 } 819 } 820 821 - (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)task 822 { 823 NSURL *url = task.request.URL; 824 if ([url.path isEqualToString:@"/checkStorage"]) { 825 NSString *html = @"<script>var oldValue = window.sessionStorage['storageKey']; window.sessionStorage['storageKey'] = 'value'; alert('old value: <' + (oldValue ? 'fail' : '') + '>');</script>"; 826 [task didReceiveResponse:[[NSURLResponse alloc] initWithURL:url MIMEType:@"text/html" expectedContentLength:html.length textEncodingName:nil]]; 827 [task didReceiveData:[html dataUsingEncoding:NSUTF8StringEncoding]]; 828 [task didFinish]; 829 } 817 830 } 818 831 … … 821 834 } 822 835 823 @end 836 - (void)webView:(WKWebView *)webView runJavaScriptAlertPanelWithMessage:(NSString *)message initiatedByFrame:(WKFrameInfo *)frame completionHandler:(void (^)(void))completionHandler 837 { 838 EXPECT_STREQ(message.UTF8String, "old value: <>"); 839 completionHandler(); 840 done = true; 841 } 842 843 @end 844 845 RetainPtr<WKWebView> websiteDataStoreTestWebView() 846 { 847 auto delegate = adoptNS([[WebsitePoliciesWebsiteDataStoreDelegate alloc] init]); 848 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 849 [configuration setURLSchemeHandler:delegate.get() forURLScheme:@"test"]; 850 [configuration setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]]; 851 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 852 [webView setNavigationDelegate:delegate.get()]; 853 [webView setUIDelegate:delegate.get()]; 854 return webView; 855 } 824 856 825 857 TEST(WebKit, UpdateWebsitePoliciesInvalid) 826 858 { 827 auto delegate = adoptNS([[WebsitePoliciesWebsiteDataStoreDelegate alloc] init]); 828 auto configuration = adoptNS([[WKWebViewConfiguration alloc] init]); 829 [configuration setURLSchemeHandler:delegate.get() forURLScheme:@"test"]; 830 auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:configuration.get()]); 831 [webView setNavigationDelegate:delegate.get()]; 832 859 auto webView = websiteDataStoreTestWebView(); 833 860 auto policies = adoptNS([[_WKWebsitePolicies alloc] init]); 834 861 [policies setWebsiteDataStore:[WKWebsiteDataStore nonPersistentDataStore]]; … … 845 872 } 846 873 847 // FIXME: Use _WKWebsitePolicies.websiteDataStore and test that it is used. 874 TEST(WebKit, WebsitePoliciesDataStore) 875 { 876 auto cookieWebView = websiteDataStoreTestWebView(); 877 NSString *alertOldCookie = @"<script>var oldCookie = document.cookie; document.cookie = 'key=value'; alert('old value: <' + oldCookie + '>');</script>"; 878 [cookieWebView loadHTMLString:alertOldCookie baseURL:[NSURL URLWithString:@"http://example.com/checkCookies"]]; 879 TestWebKitAPI::Util::run(&done); 880 done = false; 881 [cookieWebView loadHTMLString:alertOldCookie baseURL:[NSURL URLWithString:@"http://example.com/checkCookies"]]; 882 TestWebKitAPI::Util::run(&done); 883 } 848 884 849 885 #endif // WK_API_ENABLED
Note: See TracChangeset
for help on using the changeset viewer.