Title: [103413] trunk/Source/WebKit2
- Revision
- 103413
- Author
- [email protected]
- Date
- 2011-12-21 10:21:58 -0800 (Wed, 21 Dec 2011)
Log Message
[Qt][WK2] Add tests for favicon and fix icon url decoding issue
https://bugs.webkit.org/show_bug.cgi?id=74967
Patch by Rafael Brandao <[email protected]> on 2011-12-21
Reviewed by Simon Hausmann.
* UIProcess/API/qt/qwebiconimageprovider.cpp: We already receive the url
without the percent encoding and we should access WebIconDatabase with
an encoded url. Added a test to cover this behavior.
(QWebIconImageProvider::requestImage):
* UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml: Added.
* UIProcess/API/qt/tests/qmltests/common/favicon.html: Added.
* UIProcess/API/qt/tests/qmltests/common/favicon.png: Added.
* UIProcess/API/qt/tests/qmltests/common/favicon2.html: Added.
* UIProcess/API/qt/tests/qmltests/common/small-favicon.png: Added.
* UIProcess/API/qt/tests/qmltests/qmltests.pro:
Modified Paths
Added Paths
Diff
Modified: trunk/Source/WebKit2/ChangeLog (103412 => 103413)
--- trunk/Source/WebKit2/ChangeLog 2011-12-21 18:19:08 UTC (rev 103412)
+++ trunk/Source/WebKit2/ChangeLog 2011-12-21 18:21:58 UTC (rev 103413)
@@ -1,3 +1,21 @@
+2011-12-21 Rafael Brandao <[email protected]>
+
+ [Qt][WK2] Add tests for favicon and fix icon url decoding issue
+ https://bugs.webkit.org/show_bug.cgi?id=74967
+
+ Reviewed by Simon Hausmann.
+
+ * UIProcess/API/qt/qwebiconimageprovider.cpp: We already receive the url
+ without the percent encoding and we should access WebIconDatabase with
+ an encoded url. Added a test to cover this behavior.
+ (QWebIconImageProvider::requestImage):
+ * UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml: Added.
+ * UIProcess/API/qt/tests/qmltests/common/favicon.html: Added.
+ * UIProcess/API/qt/tests/qmltests/common/favicon.png: Added.
+ * UIProcess/API/qt/tests/qmltests/common/favicon2.html: Added.
+ * UIProcess/API/qt/tests/qmltests/common/small-favicon.png: Added.
+ * UIProcess/API/qt/tests/qmltests/qmltests.pro:
+
2011-12-21 Sam Weinig <[email protected]>
Exception thrown when running WKBrowsingContextLoadDelegateTest.SimpleLoad test
Modified: trunk/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp (103412 => 103413)
--- trunk/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp 2011-12-21 18:19:08 UTC (rev 103412)
+++ trunk/Source/WebKit2/UIProcess/API/qt/qwebiconimageprovider.cpp 2011-12-21 18:21:58 UTC (rev 103413)
@@ -39,9 +39,9 @@
QImage QWebIconImageProvider::requestImage(const QString& id, QSize* size, const QSize& requestedSize)
{
- QString encodedIconUrl = id;
- encodedIconUrl.remove(0, encodedIconUrl.indexOf('#') + 1);
- String pageURL = QUrl::fromPercentEncoding(encodedIconUrl.toUtf8());
+ QString decodedIconUrl = id;
+ decodedIconUrl.remove(0, decodedIconUrl.indexOf('#') + 1);
+ String pageURL = QString::fromUtf8(QUrl(decodedIconUrl).toEncoded());
// The string identifier has the leading image://webicon/ already stripped, so we just
// need to truncate from the first slash to get the context id.
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml (0 => 103413)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/WebView/tst_favIconLoad.qml 2011-12-21 18:21:58 UTC (rev 103413)
@@ -0,0 +1,62 @@
+import QtQuick 2.0
+import QtTest 1.0
+import QtWebKit 3.0
+
+WebView {
+ id: webView
+
+ SignalSpy {
+ id: spy
+ target: webView
+ signalName: "iconChanged"
+ }
+
+ SignalSpy {
+ id: loadSpy
+ target: webView
+ signalName: "loadSucceeded"
+ }
+
+ Image {
+ id: favicon
+ source: webView.icon
+ }
+
+ TestCase {
+ id: test
+ name: "WebViewLoadFavIcon"
+
+ function init() {
+ if (webView.url != '') {
+ // When we already have done a load before, we must restore the initial state.
+ webView.load('')
+ spy.wait()
+ loadSpy.wait()
+ }
+ loadSpy.clear()
+ spy.clear()
+ }
+
+ function test_favIconLoad() {
+ init()
+ compare(spy.count, 0)
+ var url = ""
+ webView.load(url)
+ spy.wait()
+ compare(spy.count, 1)
+ compare(favicon.width, 48)
+ compare(favicon.height, 48)
+ }
+
+ function test_favIconLoadEncodedUrl() {
+ init()
+ compare(spy.count, 0)
+ var url = "" should work with#whitespace!")
+ webView.load(url)
+ spy.wait()
+ compare(spy.count, 1)
+ compare(favicon.width, 16)
+ compare(favicon.height, 16)
+ }
+ }
+}
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.html (0 => 103413)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.html (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.html 2011-12-21 18:21:58 UTC (rev 103413)
@@ -0,0 +1,10 @@
+<html>
+<head>
+</head>
+<link type="image/png" href="" sizes="48x48" rel="icon" />
+<body>
+<p>It's expected that you see a favicon displayed for this page when you open it as a local file.</p>
+<p>The favicon looks like this:</p>
+<img src=""
+</body>
+</html>
Added: trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.png (0 => 103413)
--- trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.png (rev 0)
+++ trunk/Source/WebKit2/UIProcess/API/qt/tests/qmltests/common/favicon.png 2011-12-21 18:21:58 UTC (rev 103413)
@@ -0,0 +1,35 @@
+\x89PNG
+
+
+IHDR 0 0 W\xF9\x87 bKGD \xFE \xFE \xFE\xEBԂ pHYs H H F\xC9k>