Skip to content
Permalink
Browse files
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):

Canonical link: https://commits.webkit.org/199842@main
git-svn-id: https://svn.webkit.org/repository/webkit/trunk@230245 268f45cc-cd09-0410-ab3c-d52691b4dbfc
  • Loading branch information
carlosgcampos committed Apr 4, 2018
1 parent f1e4575 commit 7df57bcfaff3151a242314c00df727787db185e8
@@ -1,3 +1,18 @@
2018-04-03 Carlos Garcia Campos <cgarcia@igalia.com>

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.

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.

2018-04-03 Youenn Fablet <youenn@apple.com>

Make NetworkProcess get ContentBlocker information from UIProcess
@@ -1379,6 +1379,12 @@ void WebPage::reload(uint64_t navigationID, uint32_t reloadOptions, SandboxExten

m_sandboxExtensionTracker.beginLoad(m_mainFrame.get(), WTFMove(sandboxExtensionHandle));
corePage()->userInputBridge().reloadFrame(m_mainFrame->coreFrame(), OptionSet<ReloadOption>::fromRaw(reloadOptions));

if (m_pendingNavigationID) {
// This can happen if FrameLoader::reload() returns early because the document URL is empty.
// The reload does nothing so we need to reset the pending navigation. See webkit.org/b/153210.
m_pendingNavigationID = 0;
}
}

void WebPage::goToBackForwardItem(uint64_t navigationID, uint64_t backForwardItemID, FrameLoadType backForwardType, NavigationPolicyCheck navigationPolicyCheck)
@@ -1,3 +1,22 @@
2018-04-03 Carlos Garcia Campos <cgarcia@igalia.com>

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.

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):

2018-04-03 Carlos Garcia Campos <cgarcia@igalia.com>

[GTK] Test /webkit/WebKitWebPage/context-menu is failing since r229831
@@ -174,6 +174,39 @@ TEST(WebKit, PageReload)
EXPECT_TRUE(WKURLIsEqual(activeUrl.get(), url.get()));
}

TEST(WebKit, PageLoadTwiceAndReload)
{
WKRetainPtr<WKContextRef> context(AdoptWK, WKContextCreate());
PlatformWebView webView(context.get());

test1Done = false;
static unsigned loadsCount = 0;

WKPageLoaderClientV0 loaderClient;
memset(&loaderClient, 0, sizeof(loaderClient));
loaderClient.base.version = 0;
loaderClient.base.clientInfo = nullptr;
loaderClient.didFailProvisionalLoadWithErrorForFrame = [](WKPageRef page, WKFrameRef frame, WKErrorRef error, WKTypeRef userData, const void *clientInfo) {
loadsCount++;
WKPageReload(page);
};
loaderClient.didFinishLoadForFrame = [](WKPageRef page, WKFrameRef frame, WKTypeRef userData, const void* clientInfo) {
if (++loadsCount == 3) {
test1Done = true;
return;
}
WKPageReload(page);
};
WKPageSetPageLoaderClient(webView.page(), &loaderClient.base);

WKRetainPtr<WKURLRef> url1(AdoptWK, Util::createURLForResource("simple", "html"));
WKRetainPtr<WKURLRef> url2(AdoptWK, Util::createURLForResource("simple2", "html"));
WKPageLoadURL(webView.page(), url1.get());
WKPageLoadURL(webView.page(), url2.get());

Util::run(&test1Done);
}

} // namespace TestWebKitAPI

#endif
@@ -203,6 +203,43 @@ static void testWebViewHistoryLoad(LoadTrackingTest* test, gconstpointer)
assertNormalLoadHappened(test->m_loadEvents);
}

class LoadTwiceAndReloadTest : public WebViewTest {
public:
MAKE_GLIB_TEST_FIXTURE(LoadTwiceAndReloadTest);

static void reloadOnFinishLoad(WebKitWebView* view, WebKitLoadEvent loadEvent, LoadTwiceAndReloadTest* test)
{
if (++test->m_loadsCount == 3)
test->quitMainLoop();
webkit_web_view_reload(view);
}

LoadTwiceAndReloadTest()
{
g_signal_connect(m_webView, "load-changed", G_CALLBACK(reloadOnFinishLoad), this);
}

~LoadTwiceAndReloadTest()
{
g_signal_handlers_disconnect_matched(m_webView, G_SIGNAL_MATCH_DATA, 0, 0, nullptr, nullptr, this);
}

void waitUntilFinished()
{
m_loadsCount = 0;
g_main_loop_run(m_mainLoop);
}

unsigned m_loadsCount { 0 };
};

static void testWebViewLoadTwiceAndReload(LoadTwiceAndReloadTest* test, gconstpointer)
{
test->loadURI(kServer->getURIForPath("/normal").data());
test->loadURI(kServer->getURIForPath("/normal2").data());
test->waitUntilFinished();
}

class ViewURITrackingTest: public LoadTrackingTest {
public:
MAKE_GLIB_TEST_FIXTURE(ViewURITrackingTest);
@@ -617,6 +654,7 @@ void beforeAll()
LoadTrackingTest::add("WebKitWebView", "progress", testLoadProgress);
LoadTrackingTest::add("WebKitWebView", "reload", testWebViewReload);
LoadTrackingTest::add("WebKitWebView", "history-load", testWebViewHistoryLoad);
LoadTwiceAndReloadTest::add("WebKitWebView", "load-twice-and-reload", testWebViewLoadTwiceAndReload);

// This test checks that web view notify::uri signal is correctly emitted
// and the uri is already updated when loader client signals are emitted.

0 comments on commit 7df57bc

Please sign in to comment.