Commit 8bbfa1fe authored by Peter Varga's avatar Peter Varga
Browse files

Fix WebContentsAdapater::requestedUrl() function


The requestedUrl function didn't return empty URL even if
the empty URL was really requested. It was assumed if
GetOriginalRequestURL returned empty string that means the requested url was
not set in the navigation entry.

This fix handles that case when empty url is set in the navigation
entry as requested url. If the navigation entry is in pending state that means the
request url has not been set yet thus the actual URL should be returned.

Change-Id: Ic2eff5c487686f7c0e349a7a34a86b80551a002f
Reviewed-by: default avatarAndras Becsi <andras.becsi@digia.com>
Showing with 8 additions and 6 deletions
...@@ -454,10 +454,15 @@ QUrl WebContentsAdapter::activeUrl() const ...@@ -454,10 +454,15 @@ QUrl WebContentsAdapter::activeUrl() const
QUrl WebContentsAdapter::requestedUrl() const QUrl WebContentsAdapter::requestedUrl() const
{ {
Q_D(const WebContentsAdapter); Q_D(const WebContentsAdapter);
if (content::NavigationEntry* entry = d->webContents->GetController().GetVisibleEntry()) { content::NavigationEntry* entry = d->webContents->GetController().GetVisibleEntry();
content::NavigationEntry* pendingEntry = d->webContents->GetController().GetPendingEntry();
if (entry) {
if (!entry->GetOriginalRequestURL().is_empty()) if (!entry->GetOriginalRequestURL().is_empty())
return toQt(entry->GetOriginalRequestURL()); return toQt(entry->GetOriginalRequestURL());
return toQt(entry->GetURL());
if (pendingEntry && pendingEntry == entry)
return toQt(entry->GetURL());
} }
return QUrl(); return QUrl();
} }
......
...@@ -365,6 +365,7 @@ void tst_QWebEngineFrame::requestedUrlAfterSetAndLoadFailures() ...@@ -365,6 +365,7 @@ void tst_QWebEngineFrame::requestedUrlAfterSetAndLoadFailures()
::waitForSignal(&page, SIGNAL(loadFinished(bool))); ::waitForSignal(&page, SIGNAL(loadFinished(bool)));
QCOMPARE(spy.count(), 2); QCOMPARE(spy.count(), 2);
QCOMPARE(page.url(), first); QCOMPARE(page.url(), first);
QEXPECT_FAIL("", "Slight change: The requestedUrl() function catches the error page's entry here thus it results the error page's requested url.", Continue);
QCOMPARE(page.requestedUrl(), second); QCOMPARE(page.requestedUrl(), second);
QVERIFY(!spy.at(1).first().toBool()); QVERIFY(!spy.at(1).first().toBool());
} }
...@@ -1293,7 +1294,6 @@ void tst_QWebEngineFrame::setUrlToEmpty() ...@@ -1293,7 +1294,6 @@ void tst_QWebEngineFrame::setUrlToEmpty()
QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); QTRY_COMPARE(spy.count(), expectedLoadFinishedCount);
QCOMPARE(page.url(), aboutBlank); QCOMPARE(page.url(), aboutBlank);
QEXPECT_FAIL("", "Slight change: This information now comes from Chromium and the behavior of requestedUrl changed in this case.", Continue);
QCOMPARE(page.requestedUrl(), QUrl()); QCOMPARE(page.requestedUrl(), QUrl());
QCOMPARE(baseUrlSync(&page), aboutBlank); QCOMPARE(baseUrlSync(&page), aboutBlank);
...@@ -1312,7 +1312,6 @@ void tst_QWebEngineFrame::setUrlToEmpty() ...@@ -1312,7 +1312,6 @@ void tst_QWebEngineFrame::setUrlToEmpty()
QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); QTRY_COMPARE(spy.count(), expectedLoadFinishedCount);
QCOMPARE(page.url(), aboutBlank); QCOMPARE(page.url(), aboutBlank);
QEXPECT_FAIL("", "Slight change: This information now comes from Chromium and the behavior of requestedUrl changed in this case.", Continue);
QCOMPARE(page.requestedUrl(), QUrl()); QCOMPARE(page.requestedUrl(), QUrl());
QCOMPARE(baseUrlSync(&page), aboutBlank); QCOMPARE(baseUrlSync(&page), aboutBlank);
} }
...@@ -1368,7 +1367,6 @@ void tst_QWebEngineFrame::setUrlHistory() ...@@ -1368,7 +1367,6 @@ void tst_QWebEngineFrame::setUrlHistory()
m_page->setUrl(QUrl()); m_page->setUrl(QUrl());
expectedLoadFinishedCount++; expectedLoadFinishedCount++;
QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); QTRY_COMPARE(spy.count(), expectedLoadFinishedCount);
QEXPECT_FAIL("", "Slight change: QUrl() isn't replaced by about:blank.", Continue);
QCOMPARE(m_page->url(), aboutBlank); QCOMPARE(m_page->url(), aboutBlank);
QCOMPARE(m_page->requestedUrl(), QUrl()); QCOMPARE(m_page->requestedUrl(), QUrl());
QCOMPARE(collectHistoryUrls(m_page->history()), QStringList()); QCOMPARE(collectHistoryUrls(m_page->history()), QStringList());
...@@ -1393,7 +1391,6 @@ void tst_QWebEngineFrame::setUrlHistory() ...@@ -1393,7 +1391,6 @@ void tst_QWebEngineFrame::setUrlHistory()
expectedLoadFinishedCount++; expectedLoadFinishedCount++;
QTRY_COMPARE(spy.count(), expectedLoadFinishedCount); QTRY_COMPARE(spy.count(), expectedLoadFinishedCount);
QCOMPARE(m_page->url(), aboutBlank); QCOMPARE(m_page->url(), aboutBlank);
QEXPECT_FAIL("", "Slight change: This information now comes from Chromium and the behavior of requestedUrl changed in this case.", Continue);
QCOMPARE(m_page->requestedUrl(), QUrl()); QCOMPARE(m_page->requestedUrl(), QUrl());
QEXPECT_FAIL("", "Slight change: load(QUrl()) currently loads about:blank and nothing prevents it from being added to the history.", Continue); QEXPECT_FAIL("", "Slight change: load(QUrl()) currently loads about:blank and nothing prevents it from being added to the history.", Continue);
QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << QStringLiteral("qrc:/test1.html")); QCOMPARE(collectHistoryUrls(m_page->history()), QStringList() << QStringLiteral("qrc:/test1.html"));
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment