Changeset 230431 in webkit


Ignore:
Timestamp:
Apr 9, 2018 8:46:45 AM (6 years ago)
Author:
Carlos Garcia Campos
Message:
Merge r230245 - ASSERTION FAILED: !m_mainFrame->coreFrame()->loader().frameHasLoaded()
!m_pendingNavigationID when reloading page while a page is loading

https://bugs.webkit.org/show_bug.cgi?id=153210

Reviewed by Alex Christensen.

Source/WebKit:

The assert happens when WebPage::reload() is called twice and the first time the reload is ignored by
FrameLoader because the document URL is empty. In that case the pending navigation is not reset, because
FrameLoader::reload() returns before creating the document loader.

  • WebProcess/WebPage/WebPage.cpp:

(WebKit::WebPage::reload): Check if the pending navigation has been reset after calling FrameLoader::reload()
and reset it otherwise.

Tools:

Add unit tests to WebKit C API and WebKitGLib.

  • TestWebKitAPI/Tests/WebKit/PageLoadBasic.cpp:

(TestWebKitAPI::TEST):

  • TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp:

(LoadTwiceAndReloadTest::reloadOnFinishLoad):
(LoadTwiceAndReloadTest::LoadTwiceAndReloadTest):
(LoadTwiceAndReloadTest::~LoadTwiceAndReloadTest):
(LoadTwiceAndReloadTest::waitUntilFinished):
(testWebViewLoadTwiceAndReload):
(beforeAll):

Location:
releases/WebKitGTK/webkit-2.20
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/ChangeLog

    r230425 r230431  
     12018-04-03  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        ASSERTION FAILED: !m_mainFrame->coreFrame()->loader().frameHasLoaded() || !m_pendingNavigationID when reloading page while a page is loading
     4        https://bugs.webkit.org/show_bug.cgi?id=153210
     5
     6        Reviewed by Alex Christensen.
     7
     8        The assert happens when WebPage::reload() is called twice and the first time the reload is ignored by
     9        FrameLoader because the document URL is empty. In that case the pending navigation is not reset, because
     10        FrameLoader::reload() returns before creating the document loader.
     11
     12        * WebProcess/WebPage/WebPage.cpp:
     13        (WebKit::WebPage::reload): Check if the pending navigation has been reset after calling FrameLoader::reload()
     14        and reset it otherwise.
     15
    1162018-04-03  Carlos Garcia Campos  <cgarcia@igalia.com>
    217
  • releases/WebKitGTK/webkit-2.20/Source/WebKit/WebProcess/WebPage/WebPage.cpp

    r228646 r230431  
    13501350    m_sandboxExtensionTracker.beginLoad(m_mainFrame.get(), WTFMove(sandboxExtensionHandle));
    13511351    corePage()->userInputBridge().reloadFrame(m_mainFrame->coreFrame(), OptionSet<ReloadOption>::fromRaw(reloadOptions));
     1352
     1353    if (m_pendingNavigationID) {
     1354        // This can happen if FrameLoader::reload() returns early because the document URL is empty.
     1355        // The reload does nothing so we need to reset the pending navigation. See webkit.org/b/153210.
     1356        m_pendingNavigationID = 0;
     1357    }
    13521358}
    13531359
  • releases/WebKitGTK/webkit-2.20/Tools/ChangeLog

    r230430 r230431  
     12018-04-03  Carlos Garcia Campos  <cgarcia@igalia.com>
     2
     3        ASSERTION FAILED: !m_mainFrame->coreFrame()->loader().frameHasLoaded() || !m_pendingNavigationID when reloading page while a page is loading
     4        https://bugs.webkit.org/show_bug.cgi?id=153210
     5
     6        Reviewed by Alex Christensen.
     7
     8        Add unit tests to WebKit C API and WebKitGLib.
     9
     10        * TestWebKitAPI/Tests/WebKit/PageLoadBasic.cpp:
     11        (TestWebKitAPI::TEST):
     12        * TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp:
     13        (LoadTwiceAndReloadTest::reloadOnFinishLoad):
     14        (LoadTwiceAndReloadTest::LoadTwiceAndReloadTest):
     15        (LoadTwiceAndReloadTest::~LoadTwiceAndReloadTest):
     16        (LoadTwiceAndReloadTest::waitUntilFinished):
     17        (testWebViewLoadTwiceAndReload):
     18        (beforeAll):
     19
    1202018-04-03  Carlos Garcia Campos  <cgarcia@igalia.com>
    221
  • releases/WebKitGTK/webkit-2.20/Tools/TestWebKitAPI/Tests/WebKit/PageLoadBasic.cpp

    r221505 r230431  
    175175}
    176176
     177TEST(WebKit, PageLoadTwiceAndReload)
     178{
     179    WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
     180    PlatformWebView webView(context.get());
     181
     182    test1Done = false;
     183    static unsigned loadsCount = 0;
     184
     185    WKPageLoaderClientV0 loaderClient;
     186    memset(&loaderClient, 0, sizeof(loaderClient));
     187    loaderClient.base.version = 0;
     188    loaderClient.base.clientInfo = nullptr;
     189    loaderClient.didFailProvisionalLoadWithErrorForFrame = [](WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo) {
     190        loadsCount++;
     191        WKPageReload(page);
     192    };
     193    loaderClient.didFinishLoadForFrame = [](WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) {
     194        if (++loadsCount == 3) {
     195            test1Done = true;
     196            return;
     197        }
     198        WKPageReload(page);
     199    };
     200    WKPageSetPageLoaderClient(webView.page(), &loaderClient.base);
     201
     202    WKRetainPtr<WKURLRef> url1(AdoptWK, Util::createURLForResource("simple", "html"));
     203    WKRetainPtr<WKURLRef> url2(AdoptWK, Util::createURLForResource("simple2", "html"));
     204    WKPageLoadURL(webView.page(), url1.get());
     205    WKPageLoadURL(webView.page(), url2.get());
     206
     207    Util::run(&test1Done);
     208}
     209
    177210} // namespace TestWebKitAPI
    178211
  • releases/WebKitGTK/webkit-2.20/Tools/TestWebKitAPI/Tests/WebKitGLib/TestLoaderClient.cpp

    r218686 r230431  
    202202    test->waitUntilLoadFinished();
    203203    assertNormalLoadHappened(test->m_loadEvents);
     204}
     205
     206class LoadTwiceAndReloadTest : public WebViewTest {
     207public:
     208    MAKE_GLIB_TEST_FIXTURE(LoadTwiceAndReloadTest);
     209
     210    static void reloadOnFinishLoad(WebKitWebView* view, WebKitLoadEvent loadEvent, LoadTwiceAndReloadTest* test)
     211    {
     212        if (++test->m_loadsCount == 3)
     213            test->quitMainLoop();
     214        webkit_web_view_reload(view);
     215    }
     216
     217    LoadTwiceAndReloadTest()
     218    {
     219        g_signal_connect(m_webView, "load-changed", G_CALLBACK(reloadOnFinishLoad), this);
     220    }
     221
     222    ~LoadTwiceAndReloadTest()
     223    {
     224        g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
     225    }
     226
     227    void waitUntilFinished()
     228    {
     229        m_loadsCount = 0;
     230        g_main_loop_run(m_mainLoop);
     231    }
     232
     233    unsigned m_loadsCount { 0 };
     234};
     235
     236static void testWebViewLoadTwiceAndReload(LoadTwiceAndReloadTest* test, gconstpointer)
     237{
     238    test->loadURI(kServer->getURIForPath("/normal").data());
     239    test->loadURI(kServer->getURIForPath("/normal2").data());
     240    test->waitUntilFinished();
    204241}
    205242
     
    618655    LoadTrackingTest::add("WebKitWebView", "reload", testWebViewReload);
    619656    LoadTrackingTest::add("WebKitWebView", "history-load", testWebViewHistoryLoad);
     657    LoadTwiceAndReloadTest::add("WebKitWebView", "load-twice-and-reload", testWebViewLoadTwiceAndReload);
    620658
    621659    // This test checks that web view notify::uri signal is correctly emitted
Note: See TracChangeset for help on using the changeset viewer.