Changeset 237386 in webkit


Ignore:
Timestamp:
Oct 24, 2018 9:39:19 AM (5 years ago)
Author:
Chris Dumez
Message:

[PSON] When navigating back and forth, 'about:blank' shows up in the back/forward list
https://bugs.webkit.org/show_bug.cgi?id=190846
<rdar://problem/45058938>

Reviewed by Antti Koivisto.

Source/WebCore:

When a page gets suspended after a process-swap, we navigate it to about:blank from inside the navigation
policy handler, by overriding the request URL. This normally works fine because we usually process-swap
on standard navigation. However, when we would process-swap on a back/forward navigation, we would end
up using the back/forward navigation load type to do the about:blank load. This would have repercussions
because history navigations update the current history item with the new URL (in this case 'about:blank').
To avoid the issue, switch to a standard load type whenever the client asks us to suspend and we load
'about:blank' as a result.

  • loader/FrameLoader.cpp:

(WebCore::FrameLoader::continueLoadAfterNavigationPolicy):

Tools:

Add API test coverage.

  • TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
Location:
trunk
Files:
4 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebCore/ChangeLog

    r237381 r237386  
     12018-10-24  Chris Dumez  <cdumez@apple.com>
     2
     3        [PSON] When navigating back and forth, 'about:blank' shows up in the back/forward list
     4        https://bugs.webkit.org/show_bug.cgi?id=190846
     5        <rdar://problem/45058938>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        When a page gets suspended after a process-swap, we navigate it to about:blank from inside the navigation
     10        policy handler, by overriding the request URL. This normally works fine because we usually process-swap
     11        on standard navigation. However, when we would process-swap on a back/forward navigation, we would end
     12        up using the back/forward navigation load type to do the about:blank load. This would have repercussions
     13        because history navigations update the current history item with the new URL (in this case 'about:blank').
     14        To avoid the issue, switch to a standard load type whenever the client asks us to suspend and we load
     15        'about:blank' as a result.
     16
     17        * loader/FrameLoader.cpp:
     18        (WebCore::FrameLoader::continueLoadAfterNavigationPolicy):
     19
    1202018-10-24  Andy Estes  <aestes@apple.com>
    221
  • trunk/Source/WebCore/loader/FrameLoader.cpp

    r237355 r237386  
    33643364
    33653365        // We handle suspension by navigating forward to about:blank, which leaves us setup to navigate back to resume.
    3366         if (shouldContinue == ShouldContinue::ForSuspension)
     3366        if (shouldContinue == ShouldContinue::ForSuspension) {
     3367            // Make sure we do a standard load to about:blank instead of reusing whatever the load type was on process swap.
     3368            // For example, using a Back/Forward load to load about blank would cause the current HistoryItem's url to be
     3369            // overwritten with 'about:blank', which we do not want.
     3370            m_loadType = FrameLoadType::Standard;
    33673371            m_provisionalDocumentLoader->willContinueMainResourceLoadAfterRedirect({ blankURL() });
     3372        }
    33683373
    33693374        m_provisionalDocumentLoader->startLoadingMainResource(shouldContinue);
  • trunk/Tools/ChangeLog

    r237383 r237386  
     12018-10-24  Chris Dumez  <cdumez@apple.com>
     2
     3        [PSON] When navigating back and forth, 'about:blank' shows up in the back/forward list
     4        https://bugs.webkit.org/show_bug.cgi?id=190846
     5        <rdar://problem/45058938>
     6
     7        Reviewed by Antti Koivisto.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm:
     12
    1132018-10-24  Claudio Saavedra  <csaavedra@igalia.com>
    214
  • trunk/Tools/TestWebKitAPI/Tests/WebKitCocoa/ProcessSwapOnNavigation.mm

    r237355 r237386  
    12531253    EXPECT_EQ(1U, backForwardList.backList.count);
    12541254
    1255     // FIXME: uncomment the following once <rdar://problem/45058938> has been fixed. When enabling PSON
    1256     // the backItem's URL currently becomes about:blank.
    1257     // backItem = backForwardList.backItem;
    1258     // EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html", [backItem.URL absoluteString]);
    1259     // EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html", [backItem.initialURL absoluteString]);
     1255    backItem = backForwardList.backItem;
     1256    EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html", [backItem.URL absoluteString]);
     1257    EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html", [backItem.initialURL absoluteString]);
    12601258}
    12611259
     
    22832281}
    22842282
     2283TEST(ProcessSwap, NavigateBackAndForth)
     2284{
     2285    auto processPoolConfiguration = adoptNS([[_WKProcessPoolConfiguration alloc] init]);
     2286    processPoolConfiguration.get().processSwapsOnNavigation = YES;
     2287    auto processPool = adoptNS([[WKProcessPool alloc] _initWithConfiguration:processPoolConfiguration.get()]);
     2288
     2289    auto webViewConfiguration = adoptNS([[WKWebViewConfiguration alloc] init]);
     2290    [webViewConfiguration setProcessPool:processPool.get()];
     2291    auto handler = adoptNS([[PSONScheme alloc] init]);
     2292    [webViewConfiguration setURLSchemeHandler:handler.get() forURLScheme:@"pson"];
     2293
     2294    auto webView = adoptNS([[WKWebView alloc] initWithFrame:NSMakeRect(0, 0, 800, 600) configuration:webViewConfiguration.get()]);
     2295    auto delegate = adoptNS([[PSONNavigationDelegate alloc] init]);
     2296    [webView setNavigationDelegate:delegate.get()];
     2297
     2298    NSURLRequest *request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.webkit.org/main.html"]];
     2299    [webView loadRequest:request];
     2300
     2301    TestWebKitAPI::Util::run(&done);
     2302    done = false;
     2303
     2304    request = [NSURLRequest requestWithURL:[NSURL URLWithString:@"pson://www.apple.com/main.html"]];
     2305    [webView loadRequest:request];
     2306
     2307    TestWebKitAPI::Util::run(&done);
     2308    done = false;
     2309
     2310    auto* backForwardList = [webView backForwardList];
     2311    EXPECT_WK_STREQ(@"pson://www.apple.com/main.html", [backForwardList.currentItem.URL absoluteString]);
     2312    EXPECT_TRUE(!backForwardList.forwardItem);
     2313    EXPECT_EQ(1U, backForwardList.backList.count);
     2314    EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html", [backForwardList.backItem.URL absoluteString]);
     2315
     2316    [webView goBack];
     2317    TestWebKitAPI::Util::run(&done);
     2318    done = false;
     2319
     2320    EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html", [backForwardList.currentItem.URL absoluteString]);
     2321    EXPECT_TRUE(!backForwardList.backItem);
     2322    EXPECT_EQ(1U, backForwardList.forwardList.count);
     2323    EXPECT_WK_STREQ(@"pson://www.apple.com/main.html", [backForwardList.forwardItem.URL absoluteString]);
     2324
     2325    [webView goForward];
     2326    TestWebKitAPI::Util::run(&done);
     2327    done = false;
     2328
     2329    EXPECT_WK_STREQ(@"pson://www.apple.com/main.html", [backForwardList.currentItem.URL absoluteString]);
     2330    EXPECT_TRUE(!backForwardList.forwardItem);
     2331    EXPECT_EQ(1U, backForwardList.backList.count);
     2332    EXPECT_WK_STREQ(@"pson://www.webkit.org/main.html", [backForwardList.backItem.URL absoluteString]);
     2333}
     2334
    22852335#if PLATFORM(MAC)
    22862336
Note: See TracChangeset for help on using the changeset viewer.