Commit d9c1df13 authored by hausmann@webkit.org's avatar hausmann@webkit.org

2009-04-14 Benjamin C Meyer <benjamin.meyer@torchmobile.com>

        Reviewed by George Staikos.

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

        When creating a QNetworkRequest make sure to populate the
        CacheLoadControlAttribute with the value set by the ResourceRequest::cachePolicy() so that the cache will be used as WebKit expects.

git-svn-id: svn://svn.chromium.org/blink/trunk@42516 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 60a7dd35
2009-04-14 Benjamin C Meyer <benjamin.meyer@torchmobile.com>
Reviewed by George Staikos.
https://bugs.webkit.org/show_bug.cgi?id=25099
When creating a QNetworkRequest make sure to populate the
CacheLoadControlAttribute with the value set by the ResourceRequest::cachePolicy() so that the cache will be used as WebKit expects.
* WebKit/qt/tests/qwebpage/tst_qwebpage.cpp:
(tst_QWebPage::requestCache):
* platform/network/qt/ResourceRequestQt.cpp:
(WebCore::ResourceRequest::toNetworkRequest):
2009-04-14 Timothy Hatcher <timothy@apple.com>
Fix a world leak caused by opening the Web Inspector. This was
......@@ -41,6 +41,22 @@ QNetworkRequest ResourceRequest::toNetworkRequest() const
request.setRawHeader(name, value);
}
switch (cachePolicy()) {
case ReloadIgnoringCacheData:
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysNetwork);
break;
case ReturnCacheDataElseLoad:
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferCache);
break;
case ReturnCacheDataDontLoad:
request.setAttribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::AlwaysCache);
break;
case UseProtocolCachePolicy:
// QNetworkRequest::PreferNetwork
default:
break;
}
return request;
}
......
......@@ -106,6 +106,8 @@ private slots:
void textSelection();
void textEditing();
void requestCache();
private:
......@@ -1069,6 +1071,32 @@ void tst_QWebPage::textEditing()
delete page;
}
void tst_QWebPage::requestCache()
{
TestPage page;
QSignalSpy loadSpy(&page, SIGNAL(loadFinished(bool)));
page.mainFrame()->setUrl(QString("data:text/html,<a href=\"data:text/html,Reached\" target=\"_blank\">Click me</a>"));
QTRY_COMPARE(loadSpy.count(), 1);
QTRY_COMPARE(page.navigations.count(), 1);
page.mainFrame()->setUrl(QString("data:text/html,<a href=\"data:text/html,Reached\" target=\"_blank\">Click me2</a>"));
QTRY_COMPARE(loadSpy.count(), 2);
QTRY_COMPARE(page.navigations.count(), 2);
page.triggerAction(QWebPage::Stop);
QVERIFY(page.history()->canGoBack());
page.triggerAction(QWebPage::Back);
QTRY_COMPARE(loadSpy.count(), 3);
QTRY_COMPARE(page.navigations.count(), 3);
QCOMPARE(page.navigations.at(0).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
(int)QNetworkRequest::PreferNetwork);
QCOMPARE(page.navigations.at(1).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
(int)QNetworkRequest::PreferNetwork);
QCOMPARE(page.navigations.at(2).request.attribute(QNetworkRequest::CacheLoadControlAttribute, QNetworkRequest::PreferNetwork).toInt(),
(int)QNetworkRequest::PreferCache);
}
QTEST_MAIN(tst_QWebPage)
#include "tst_qwebpage.moc"
Markdown is supported
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