Changeset 226929 in webkit


Ignore:
Timestamp:
Jan 12, 2018, 4:39:34 PM (8 years ago)
Author:
achristensen@apple.com
Message:

History state should be updated during client redirects with asynchronous policy decisions
https://bugs.webkit.org/show_bug.cgi?id=181358
<rdar://problem/35547689>

Reviewed by Andy Estes.

Source/WebCore:

When decidePolicyForNavigationAction is responded to asynchronously during a client redirect,
HistoryController::updateForRedirectWithLockedBackForwardList does not update the history because
the document loader has not been marked as a client redirect because the FrameLoader only looks
at its provisional document loader to mark it as a client redirect. When decidePolicyForNavigationAction
is responded to asynchronously, though, the FrameLoader's provisional document loader has moved to
its policy document loader. To get both asynchronous and synchronous cases, let's just mark the document
loader as a client redirect whether it's the provisional or policy document loader.

Covered by a new API test.

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::loadURL):
(WebCore::FrameLoader::loadPostRequest):

Tools:

  • TestWebKitAPI/Tests/WebKit/WKBackForwardList.mm:

(-[AsyncPolicyDecisionDelegate webView:didFinishNavigation:]):
(-[AsyncPolicyDecisionDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
(TEST):

Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • TabularUnified trunk/Source/WebCore/ChangeLog

    r226927 r226929  
     12018-01-12  Alex Christensen  <achristensen@webkit.org>
     2
     3        History state should be updated during client redirects with asynchronous policy decisions
     4        https://bugs.webkit.org/show_bug.cgi?id=181358
     5        <rdar://problem/35547689>
     6
     7        Reviewed by Andy Estes.
     8
     9        When decidePolicyForNavigationAction is responded to asynchronously during a client redirect,
     10        HistoryController::updateForRedirectWithLockedBackForwardList does not update the history because
     11        the document loader has not been marked as a client redirect because the FrameLoader only looks
     12        at its provisional document loader to mark it as a client redirect.  When decidePolicyForNavigationAction
     13        is responded to asynchronously, though, the FrameLoader's provisional document loader has moved to
     14        its policy document loader.  To get both asynchronous and synchronous cases, let's just mark the document
     15        loader as a client redirect whether it's the provisional or policy document loader.
     16
     17        Covered by a new API test.
     18
     19        * loader/FrameLoader.cpp:
     20        (WebCore::FrameLoader::loadURL):
     21        (WebCore::FrameLoader::loadPostRequest):
     22
    1232018-01-12  Dean Jackson  <dino@apple.com>
    224
  • TabularUnified trunk/Source/WebCore/loader/FrameLoader.cpp

    r226745 r226929  
    13431343        if (m_provisionalDocumentLoader)
    13441344            m_provisionalDocumentLoader->setIsClientRedirect(true);
     1345        else if (m_policyDocumentLoader)
     1346            m_policyDocumentLoader->setIsClientRedirect(true);
    13451347    } else if (sameURL && !isReload(newLoadType)) {
    13461348        // Example of this case are sites that reload the same URL with a different cookie
     
    27762778        if (m_provisionalDocumentLoader)
    27772779            m_provisionalDocumentLoader->setIsClientRedirect(true);
     2780        else if (m_policyDocumentLoader)
     2781            m_policyDocumentLoader->setIsClientRedirect(true);
    27782782    }
    27792783}
  • TabularUnified trunk/Tools/ChangeLog

    r226918 r226929  
     12018-01-12  Alex Christensen  <achristensen@webkit.org>
     2
     3        History state should be updated during client redirects with asynchronous policy decisions
     4        https://bugs.webkit.org/show_bug.cgi?id=181358
     5        <rdar://problem/35547689>
     6
     7        Reviewed by Andy Estes.
     8
     9        * TestWebKitAPI/Tests/WebKit/WKBackForwardList.mm:
     10        (-[AsyncPolicyDecisionDelegate webView:didFinishNavigation:]):
     11        (-[AsyncPolicyDecisionDelegate webView:decidePolicyForNavigationAction:decisionHandler:]):
     12        (TEST):
     13
    1142018-01-12  Jonathan Bedard  <jbedard@apple.com>
    215
  • TabularUnified trunk/Tools/TestWebKitAPI/Tests/WebKit/WKBackForwardList.mm

    r207445 r226929  
    104104}
    105105
     106static bool done;
     107static size_t navigations;
     108
     109@interface AsyncPolicyDecisionDelegate : NSObject <WKNavigationDelegate, WKUIDelegate>
     110@end
     111
     112@implementation AsyncPolicyDecisionDelegate
     113
     114- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation
     115{
     116    if (navigations++)
     117        done = true;
     118}
     119
     120- (void)webView:(WKWebView *)webView decidePolicyForNavigationAction:(WKNavigationAction *)navigationAction decisionHandler:(void (^)(WKNavigationActionPolicy))decisionHandler
     121{
     122    dispatch_async(dispatch_get_main_queue(), ^{
     123        decisionHandler(WKNavigationActionPolicyAllow);
     124    });
     125}
     126
     127@end
     128
     129TEST(WKBackForwardList, WindowLocationAsyncPolicyDecision)
     130{
     131    NSURL *simple = [[NSBundle mainBundle] URLForResource:@"simple" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     132    NSURL *simple2 = [[NSBundle mainBundle] URLForResource:@"simple2" withExtension:@"html" subdirectory:@"TestWebKitAPI.resources"];
     133    auto webView = adoptNS([[WKWebView alloc] init]);
     134    auto delegate = adoptNS([[AsyncPolicyDecisionDelegate alloc] init]);
     135    [webView setNavigationDelegate:delegate.get()];
     136    [webView loadHTMLString:@"<script>window.location='simple.html'</script>" baseURL:simple2];
     137    TestWebKitAPI::Util::run(&done);
     138    EXPECT_STREQ(webView.get().backForwardList.currentItem.URL.absoluteString.UTF8String, simple.absoluteString.UTF8String);
     139}
     140
    106141#endif
Note: See TracChangeset for help on using the changeset viewer.