https://bugs.webkit.org/show_bug.cgi?id=138703
Reviewed by Alexey Proskuryakov.
Source/WebCore:
Test added to TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm.
* loader/FrameLoader.cpp:
(WebCore::FrameLoader::loadDifferentDocumentItem): When using a cached page, which already
has a document loader, set the document loader’s triggering action (so that the policy
client sees that this is a back/forward navigation) and clear its last checked request (so
that the policy client gets called).
Tools:
* TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm:
(-[DecidePolicyForPageCacheNavigationDelegate webView:didFinishNavigation:]):
(-[DecidePolicyForPageCacheNavigationDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@176096
268f45cc-cd09-0410-ab3c-
d52691b4dbfc
+2014-11-13 Dan Bernstein <mitz@apple.com>
+
+ Policy client not called for navigations through the page cache
+ https://bugs.webkit.org/show_bug.cgi?id=138703
+
+ Reviewed by Alexey Proskuryakov.
+
+ Test added to TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm.
+
+ * loader/FrameLoader.cpp:
+ (WebCore::FrameLoader::loadDifferentDocumentItem): When using a cached page, which already
+ has a document loader, set the document loader’s triggering action (so that the policy
+ client sees that this is a back/forward navigation) and clear its last checked request (so
+ that the policy client gets called).
+
2014-11-13 Joanmarie Diggs <jdiggs@igalia.com>
AX: [ATK] Do not return ATK_ROLE_UNKNOWN for null or otherwise invalid accessible objects
history().setProvisionalItem(item);
if (CachedPage* cachedPage = pageCache()->get(item)) {
- loadWithDocumentLoader(cachedPage->documentLoader(), loadType, 0, AllowNavigationToInvalidURL::Yes);
+ auto documentLoader = cachedPage->documentLoader();
+ documentLoader->setTriggeringAction(NavigationAction(documentLoader->request(), loadType, false));
+ documentLoader->setLastCheckedRequest(ResourceRequest());
+ loadWithDocumentLoader(documentLoader, loadType, 0, AllowNavigationToInvalidURL::Yes);
return;
}
+2014-11-13 Dan Bernstein <mitz@apple.com>
+
+ Policy client not called for navigations through the page cache
+ https://bugs.webkit.org/show_bug.cgi?id=138703
+
+ Reviewed by Alexey Proskuryakov.
+
+ * TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm:
+ (-[DecidePolicyForPageCacheNavigationDelegate webView:didFinishNavigation:]):
+ (-[DecidePolicyForPageCacheNavigationDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
+
2014-11-13 Joanmarie Diggs <jdiggs@igalia.com>
AX: [ATK] Do not return ATK_ROLE_UNKNOWN for null or otherwise invalid accessible objects
ASSERT_NOT_NULL(currentNavigation);
ASSERT_TRUE([[currentNavigation _request] isEqual:request]);
+ isDone = false;
TestWebKitAPI::Util::run(&isDone);
}
ASSERT_NOT_NULL(currentNavigation);
ASSERT_TRUE([[currentNavigation _request] isEqual:request]);
+ isDone = false;
TestWebKitAPI::Util::run(&isDone);
}
+@interface DecidePolicyForPageCacheNavigationDelegate : NSObject <WKNavigationDelegate>
+@property (nonatomic) BOOL decidedPolicyForBackForwardNavigation;
+@end
+
+@implementation DecidePolicyForPageCacheNavigationDelegate
+
+- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
+{
+ isDone = true;
+}
+
+- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
+{
+ if (navigationAction.navigationType == WKNavigationTypeBackForward)
+ _decidedPolicyForBackForwardNavigation = YES;
+
+ decisionHandler(WKNavigationActionPolicyAllow);
+}
+
+@end
+
+TEST(WKNavigation, DecidePolicyForPageCacheNavigation)
+{
+ RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
+
+ RetainPtr<DecidePolicyForPageCacheNavigationDelegate> delegate = adoptNS([[DecidePolicyForPageCacheNavigationDelegate alloc] init]);
+ [webView setNavigationDelegate:delegate.get()];
+
+ NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,1"]];
+
+ isDone = false;
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&isDone);
+
+ request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,2"]];
+
+ isDone = false;
+ [webView loadRequest:request];
+ TestWebKitAPI::Util::run(&isDone);
+
+ isDone = false;
+ [webView goBack];
+ TestWebKitAPI::Util::run(&isDone);
+
+ ASSERT_TRUE([delegate decidedPolicyForBackForwardNavigation]);
+}
+
#endif