Title: [226472] trunk
- Revision
- 226472
- Author
- [email protected]
- Date
- 2018-01-05 16:08:05 -0800 (Fri, 05 Jan 2018)
Log Message
Restrict navigation-time WKWebsiteDataStore swapping to main frame navigations
https://bugs.webkit.org/show_bug.cgi?id=181217
Reviewed by Tim Horton.
Source/WebKit:
If we swap during an iframe navigation, then we get a page in a strange state.
The intent of the main frame navigation WKWebsiteDataStore swap is that
that is a time when we can change storages without a page in an inconsistent state.
* UIProcess/Cocoa/NavigationState.mm:
(WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
Tools:
* TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
(-[WebsitePoliciesWebsiteDataStoreDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]):
(TEST):
Modified Paths
Diff
Modified: trunk/Source/WebKit/ChangeLog (226471 => 226472)
--- trunk/Source/WebKit/ChangeLog 2018-01-06 00:05:00 UTC (rev 226471)
+++ trunk/Source/WebKit/ChangeLog 2018-01-06 00:08:05 UTC (rev 226472)
@@ -1,5 +1,19 @@
2018-01-05 Alex Christensen <[email protected]>
+ Restrict navigation-time WKWebsiteDataStore swapping to main frame navigations
+ https://bugs.webkit.org/show_bug.cgi?id=181217
+
+ Reviewed by Tim Horton.
+
+ If we swap during an iframe navigation, then we get a page in a strange state.
+ The intent of the main frame navigation WKWebsiteDataStore swap is that
+ that is a time when we can change storages without a page in an inconsistent state.
+
+ * UIProcess/Cocoa/NavigationState.mm:
+ (WebKit::NavigationState::NavigationClient::decidePolicyForNavigationAction):
+
+2018-01-05 Alex Christensen <[email protected]>
+
Add WKBundleFrameCreateFrameHandle
https://bugs.webkit.org/show_bug.cgi?id=181232
<rdar://problem/35926696>
Modified: trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm (226471 => 226472)
--- trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm 2018-01-06 00:05:00 UTC (rev 226471)
+++ trunk/Source/WebKit/UIProcess/Cocoa/NavigationState.mm 2018-01-06 00:08:05 UTC (rev 226472)
@@ -417,6 +417,7 @@
void NavigationState::NavigationClient::decidePolicyForNavigationAction(WebPageProxy& webPageProxy, Ref<API::NavigationAction>&& navigationAction, Ref<WebFramePolicyListenerProxy>&& listener, API::Object* userInfo)
{
String mainFrameURLString = webPageProxy.mainFrame()->url();
+ bool subframeNavigation = navigationAction->targetFrame() && !navigationAction->targetFrame()->isMainFrame();
if (!m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandler
&& !m_navigationState.m_navigationDelegateMethods.webViewDecidePolicyForNavigationActionDecisionHandlerWebsitePolicies
@@ -461,7 +462,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, webPageProxy = makeRef(webPageProxy)](WKNavigationActionPolicy actionPolicy, _WKWebsitePolicies *websitePolicies) mutable {
+ auto decisionHandlerWithPolicies = [localListener = WTFMove(listener), navigationAction = navigationAction.copyRef(), checker = WTFMove(checker), mainFrameURLString, webPageProxy = makeRef(webPageProxy), subframeNavigation](WKNavigationActionPolicy actionPolicy, _WKWebsitePolicies *websitePolicies) mutable {
if (checker->completionHandlerHasBeenCalled())
return;
checker->didCallCompletionHandler();
@@ -473,6 +474,9 @@
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."];
+ if (subframeNavigation)
+ [NSException raise:NSInvalidArgumentException format:@"_WKWebsitePolicies.websiteDataStore must be nil for subframe navigations."];
+
webPageProxy->changeWebsiteDataStore(websitePolicies->_websitePolicies->websiteDataStore()->websiteDataStore());
}
}
Modified: trunk/Tools/ChangeLog (226471 => 226472)
--- trunk/Tools/ChangeLog 2018-01-06 00:05:00 UTC (rev 226471)
+++ trunk/Tools/ChangeLog 2018-01-06 00:08:05 UTC (rev 226472)
@@ -1,5 +1,16 @@
2018-01-05 Alex Christensen <[email protected]>
+ Restrict navigation-time WKWebsiteDataStore swapping to main frame navigations
+ https://bugs.webkit.org/show_bug.cgi?id=181217
+
+ Reviewed by Tim Horton.
+
+ * TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm:
+ (-[WebsitePoliciesWebsiteDataStoreDelegate _webView:decidePolicyForNavigationAction:decisionHandler:]):
+ (TEST):
+
+2018-01-05 Alex Christensen <[email protected]>
+
Add WKBundleFrameCreateFrameHandle
https://bugs.webkit.org/show_bug.cgi?id=181232
<rdar://problem/35926696>
Modified: trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm (226471 => 226472)
--- trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm 2018-01-06 00:05:00 UTC (rev 226471)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/WebsitePolicies.mm 2018-01-06 00:08:05 UTC (rev 226472)
@@ -811,11 +811,25 @@
done = true;
}
- if ([url.path isEqualToString:@"/checkStorage"] || [url.path isEqualToString:@"/checkCookies"]) {
+ if ([url.path isEqualToString:@"/checkStorage"]
+ || [url.path isEqualToString:@"/checkCookies"]
+ || [url.path isEqualToString:@"/mainFrame"]) {
_WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease];
websitePolicies.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
decisionHandler(WKNavigationActionPolicyAllow, websitePolicies);
}
+ if ([url.path isEqualToString:@"/subFrame"]) {
+ _WKWebsitePolicies *websitePolicies = [[[_WKWebsitePolicies alloc] init] autorelease];
+ websitePolicies.websiteDataStore = [WKWebsiteDataStore nonPersistentDataStore];
+ bool sawException = false;
+ @try {
+ decisionHandler(WKNavigationActionPolicyCancel, websitePolicies);
+ } @catch (NSException *exception) {
+ sawException = true;
+ }
+ EXPECT_TRUE(sawException);
+ done = true;
+ }
}
- (void)webView:(WKWebView *)webView startURLSchemeTask:(id <WKURLSchemeTask>)task
@@ -869,6 +883,10 @@
[webView loadRequest:[NSURLRequest requestWithURL:[NSURL URLWithString:@"test:///invalid"]]];
TestWebKitAPI::Util::run(&done);
+
+ done = false;
+ [webView loadHTMLString:@"<iframe src=''></iframe>" baseURL:[NSURL URLWithString:@"http://webkit.org/mainFrame"]];
+ TestWebKitAPI::Util::run(&done);
}
TEST(WebKit, WebsitePoliciesDataStore)
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes