Title: [176096] trunk
Revision
176096
Author
m...@apple.com
Date
2014-11-13 15:22:50 -0800 (Thu, 13 Nov 2014)

Log Message

Policy client not called for navigations through the page cache
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:]):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (176095 => 176096)


--- trunk/Source/WebCore/ChangeLog	2014-11-13 23:00:07 UTC (rev 176095)
+++ trunk/Source/WebCore/ChangeLog	2014-11-13 23:22:50 UTC (rev 176096)
@@ -1,3 +1,18 @@
+2014-11-13  Dan Bernstein  <m...@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  <jdi...@igalia.com>
 
         AX: [ATK] Do not return ATK_ROLE_UNKNOWN for null or otherwise invalid accessible objects

Modified: trunk/Source/WebCore/loader/FrameLoader.cpp (176095 => 176096)


--- trunk/Source/WebCore/loader/FrameLoader.cpp	2014-11-13 23:00:07 UTC (rev 176095)
+++ trunk/Source/WebCore/loader/FrameLoader.cpp	2014-11-13 23:22:50 UTC (rev 176096)
@@ -3153,7 +3153,10 @@
     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;
     }
 

Modified: trunk/Tools/ChangeLog (176095 => 176096)


--- trunk/Tools/ChangeLog	2014-11-13 23:00:07 UTC (rev 176095)
+++ trunk/Tools/ChangeLog	2014-11-13 23:22:50 UTC (rev 176096)
@@ -1,3 +1,14 @@
+2014-11-13  Dan Bernstein  <m...@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  <jdi...@igalia.com>
 
         AX: [ATK] Do not return ATK_ROLE_UNKNOWN for null or otherwise invalid accessible objects

Modified: trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm (176095 => 176096)


--- trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm	2014-11-13 23:00:07 UTC (rev 176095)
+++ trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm	2014-11-13 23:22:50 UTC (rev 176096)
@@ -90,6 +90,7 @@
     ASSERT_NOT_NULL(currentNavigation);
     ASSERT_TRUE([[currentNavigation _request] isEqual:request]);
 
+    isDone = false;
     TestWebKitAPI::Util::run(&isDone);
 }
 
@@ -135,7 +136,55 @@
     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
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to