Changeset 176096 in webkit


Ignore:
Timestamp:
Nov 13, 2014 3:22:50 PM (9 years ago)
Author:
mitz@apple.com
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:]):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r176091 r176096  
     12014-11-13  Dan Bernstein  <mitz@apple.com>
     2
     3        Policy client not called for navigations through the page cache
     4        https://bugs.webkit.org/show_bug.cgi?id=138703
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        Test added to TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm.
     9
     10        * loader/FrameLoader.cpp:
     11        (WebCore::FrameLoader::loadDifferentDocumentItem): When using a cached page, which already
     12        has a document loader, set the document loader’s triggering action (so that the policy
     13        client sees that this is a back/forward navigation) and clear its last checked request (so
     14        that the policy client gets called).
     15
    1162014-11-13  Joanmarie Diggs  <jdiggs@igalia.com>
    217
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r175719 r176096  
    31543154
    31553155    if (CachedPage* cachedPage = pageCache()->get(item)) {
    3156         loadWithDocumentLoader(cachedPage->documentLoader(), loadType, 0, AllowNavigationToInvalidURL::Yes);
     3156        auto documentLoader = cachedPage->documentLoader();
     3157        documentLoader->setTriggeringAction(NavigationAction(documentLoader->request(), loadType, false));
     3158        documentLoader->setLastCheckedRequest(ResourceRequest());
     3159        loadWithDocumentLoader(documentLoader, loadType, 0, AllowNavigationToInvalidURL::Yes);
    31573160        return;
    31583161    }
  • trunk/Tools/ChangeLog

    r176091 r176096  
     12014-11-13  Dan Bernstein  <mitz@apple.com>
     2
     3        Policy client not called for navigations through the page cache
     4        https://bugs.webkit.org/show_bug.cgi?id=138703
     5
     6        Reviewed by Alexey Proskuryakov.
     7
     8        * TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm:
     9        (-[DecidePolicyForPageCacheNavigationDelegate webView:didFinishNavigation:]):
     10        (-[DecidePolicyForPageCacheNavigationDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
     11
    1122014-11-13  Joanmarie Diggs  <jdiggs@igalia.com>
    213
  • trunk/Tools/TestWebKitAPI/Tests/WebKit2Cocoa/Navigation.mm

    r171626 r176096  
    9191    ASSERT_TRUE([[currentNavigation _request] isEqual:request]);
    9292
     93    isDone = false;
    9394    TestWebKitAPI::Util::run(&isDone);
    9495}
     
    136137    ASSERT_TRUE([[currentNavigation _request] isEqual:request]);
    137138
     139    isDone = false;
    138140    TestWebKitAPI::Util::run(&isDone);
    139141}
    140142
     143@interface DecidePolicyForPageCacheNavigationDelegate : NSObject <WKNavigationDelegate>
     144@property (nonatomic) BOOL decidedPolicyForBackForwardNavigation;
     145@end
     146
     147@implementation DecidePolicyForPageCacheNavigationDelegate
     148
     149- (void)webView:(WKWebView *)webView didFinishNavigation:(WKNavigation *)navigation
     150{
     151    isDone = true;
     152}
     153
     154- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
     155{
     156    if (navigationAction.navigationType == WKNavigationTypeBackForward)
     157        _decidedPolicyForBackForwardNavigation = YES;
     158
     159    decisionHandler(WKNavigationActionPolicyAllow);
     160}
     161
     162@end
     163
     164TEST(WKNavigation, DecidePolicyForPageCacheNavigation)
     165{
     166    RetainPtr<WKWebView> webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600)]);
     167
     168    RetainPtr<DecidePolicyForPageCacheNavigationDelegate> delegate = adoptNS([[DecidePolicyForPageCacheNavigationDelegate alloc] init]);
     169    [webView setNavigationDelegate:delegate.get()];
     170
     171    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,1"]];
     172
     173    isDone = false;
     174    [webView loadRequest:request];
     175    TestWebKitAPI::Util::run(&isDone);
     176
     177    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"data:text/html,2"]];
     178
     179    isDone = false;
     180    [webView loadRequest:request];
     181    TestWebKitAPI::Util::run(&isDone);
     182
     183    isDone = false;
     184    [webView goBack];
     185    TestWebKitAPI::Util::run(&isDone);
     186
     187    ASSERT_TRUE([delegate decidedPolicyForBackForwardNavigation]);
     188}
     189
    141190#endif
Note: See TracChangeset for help on using the changeset viewer.