Changeset 261394 in webkit


Ignore:
Timestamp:
May 8, 2020 10:33:58 AM (4 years ago)
Author:
Chris Dumez
Message:

REGRESSION(r259209) Webview's pending URL is null after restoring session state
https://bugs.webkit.org/show_bug.cgi?id=211626
<rdar://problem/62992262>

Reviewed by Alex Christensen.

Source/WebKit:

The issue was that WebPageProxy::goToBackForwardItem() would behave differently whether
the page has a running process or not. In particular, when the page did not have a
running process, goToBackForwardItem() would return early and call launchProcessWithItem()
instead. Unlike goToBackForwardItem(), launchProcessWithItem() would fail to set the
pending API request.

To address the issue, I am getting rid of launchProcessWithItem() and merging its logic
into goToBackForwardItem() instead. Both methods shared a lot of code anyway and having
2 separate code paths that may diverge is error prone.

Change is covered by new API test.

  • UIProcess/WebPageProxy.cpp:

(WebKit::WebPageProxy::goToBackForwardItem):
(WebKit::WebPageProxy::launchProcessWithItem): Deleted.

  • UIProcess/WebPageProxy.h:

Tools:

Add API test coverage.

  • TestWebKitAPI/Tests/WebKit/RestoreSessionState.cpp:

(TestWebKitAPI::TEST):

Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/Source/WebKit/ChangeLog

    r261390 r261394  
     12020-05-08  Chris Dumez  <cdumez@apple.com>
     2
     3        REGRESSION(r259209) Webview's pending URL is null after restoring session state
     4        https://bugs.webkit.org/show_bug.cgi?id=211626
     5        <rdar://problem/62992262>
     6
     7        Reviewed by Alex Christensen.
     8
     9        The issue was that WebPageProxy::goToBackForwardItem() would behave differently whether
     10        the page has a running process or not. In particular, when the page did not have a
     11        running process, goToBackForwardItem() would return early and call launchProcessWithItem()
     12        instead. Unlike goToBackForwardItem(), launchProcessWithItem() would fail to set the
     13        pending API request.
     14
     15        To address the issue, I am getting rid of launchProcessWithItem() and merging its logic
     16        into goToBackForwardItem() instead. Both methods shared a lot of code anyway and having
     17        2 separate code paths that may diverge is error prone.
     18
     19        Change is covered by new API test.
     20
     21        * UIProcess/WebPageProxy.cpp:
     22        (WebKit::WebPageProxy::goToBackForwardItem):
     23        (WebKit::WebPageProxy::launchProcessWithItem): Deleted.
     24        * UIProcess/WebPageProxy.h:
     25
    1262020-05-08  Alex Christensen  <achristensen@webkit.org>
    227
  • trunk/Source/WebKit/UIProcess/WebPageProxy.cpp

    r261390 r261394  
    10251025}
    10261026
    1027 RefPtr<API::Navigation> WebPageProxy::launchProcessWithItem(WebBackForwardListItem& item)
    1028 {
    1029     RELEASE_LOG_IF_ALLOWED(Loading, "launchProcessWithItem:");
    1030 
    1031     if (m_isClosed) {
    1032         RELEASE_LOG_IF_ALLOWED(Loading, "launchProcessWithItem: page is closed");
    1033         return nullptr;
    1034     }
    1035 
    1036     ASSERT(!hasRunningProcess());
    1037     launchProcess(RegistrableDomain { URL(URL(), item.url()) }, ProcessLaunchReason::InitialProcess);
    1038 
    1039     if (&item != m_backForwardList->currentItem())
    1040         m_backForwardList->goToItem(item);
    1041 
    1042     auto navigation = m_navigationState->createBackForwardNavigation(item, m_backForwardList->currentItem(), FrameLoadType::IndexedBackForward);
    1043 
    1044     send(Messages::WebPage::GoToBackForwardItem(navigation->navigationID(), item.itemID(), FrameLoadType::IndexedBackForward, ShouldTreatAsContinuingLoad::No, WTF::nullopt));
    1045     m_process->startResponsivenessTimer();
    1046 
    1047     return navigation;
    1048 }
    1049 
    10501027void WebPageProxy::setDrawingArea(std::unique_ptr<DrawingAreaProxy>&& drawingArea)
    10511028{
     
    16551632    LOG(Loading, "WebPageProxy %p goToBackForwardItem to item URL %s", this, item.url().utf8().data());
    16561633
    1657     if (!hasRunningProcess())
    1658         return launchProcessWithItem(item);
     1634    if (m_isClosed) {
     1635        RELEASE_LOG_IF_ALLOWED(Loading, "goToBackForwardItem: page is closed");
     1636        return nullptr;
     1637    }
     1638
     1639    if (!hasRunningProcess()) {
     1640        launchProcess(RegistrableDomain { URL(URL(), item.url()) }, ProcessLaunchReason::InitialProcess);
     1641
     1642        if (&item != m_backForwardList->currentItem())
     1643            m_backForwardList->goToItem(item);
     1644    }
    16591645
    16601646    RefPtr<API::Navigation> navigation;
  • trunk/Source/WebKit/UIProcess/WebPageProxy.h

    r261364 r261394  
    19481948
    19491949    RefPtr<API::Navigation> launchProcessForReload();
    1950     RefPtr<API::Navigation> launchProcessWithItem(WebBackForwardListItem&);
    19511950
    19521951    void requestNotificationPermission(uint64_t notificationID, const String& originString);
  • trunk/Tools/ChangeLog

    r261390 r261394  
     12020-05-08  Chris Dumez  <cdumez@apple.com>
     2
     3        REGRESSION(r259209) Webview's pending URL is null after restoring session state
     4        https://bugs.webkit.org/show_bug.cgi?id=211626
     5        <rdar://problem/62992262>
     6
     7        Reviewed by Alex Christensen.
     8
     9        Add API test coverage.
     10
     11        * TestWebKitAPI/Tests/WebKit/RestoreSessionState.cpp:
     12        (TestWebKitAPI::TEST):
     13
    1142020-05-08  Alex Christensen  <achristensen@webkit.org>
    215
  • trunk/Tools/TestWebKitAPI/Tests/WebKit/RestoreSessionState.cpp

    r244390 r261394  
    138138    WKPageRestoreFromSessionState(webView.page(), sessionState.get());
    139139}
     140
     141TEST(WebKit, PendingURLAfterRestoreSessionState)
     142{
     143    auto context = adoptWK(WKContextCreateWithConfiguration(nullptr));
     144    PlatformWebView webView(context.get());
     145    setPageLoaderClient(webView.page());
     146    auto data = createSessionStateData(context.get());
     147    EXPECT_NOT_NULL(data);
     148    auto sessionState = adoptWK(WKSessionStateCreateFromData(data.get()));
     149    WKPageRestoreFromSessionState(webView.page(), sessionState.get());
     150    auto pendingURL = adoptWK(WKPageCopyPendingAPIRequestURL(webView.page()));
     151    EXPECT_NOT_NULL(pendingURL);
     152    if (!pendingURL)
     153        return;
     154
     155    auto expectedURL = adoptWK(Util::createURLForResource("simple-form", "html"));
     156    EXPECT_WK_STREQ(adoptWK(WKURLCopyString(expectedURL.get())).get(), adoptWK(WKURLCopyString(pendingURL.get())).get());
     157}
    140158   
    141159} // namespace TestWebKitAPI
Note: See TracChangeset for help on using the changeset viewer.