2011-03-16 Benjamin Poulain <benjamin.poulain@nokia.com>

        Reviewed by Kenneth Rohde Christiansen.

        [Qt][WK2] Loading an empty URL crashes
        https://bugs.webkit.org/show_bug.cgi?id=55501

        A null WKURLRef is created in the API of WebKit 2 when converting a null string. The code
        of WKPageLoadURL assume the WKPageRef is not null which causes crashes if it is.

        This patch uses the converter toWTFString() to pass from WKPageRef to WTFString. This converter
        ensure the returned string is a valid null string.

        Tested through the Qt API tests.

        * UIProcess/API/C/WKPage.cpp:
        (WKPageLoadURL):
        * UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp:
        (tst_QGraphicsWKView::loadEmptyUrl):
        * UIProcess/API/qt/tests/qwkpage/qwkpage.pro: Added.
        * UIProcess/API/qt/tests/qwkpage/tst_qwkpage.cpp: Added.
        (tst_QWKPage::init):
        (tst_QWKPage::cleanup):
        (tst_QWKPage::loadEmptyUrl):
        * UIProcess/API/qt/tests/tests.pro:

git-svn-id: svn://svn.chromium.org/blink/trunk@81237 bbb929c8-8fbe-4397-9dbb-9b2b20218538
parent 9badc0f6
2011-03-16 Benjamin Poulain <benjamin.poulain@nokia.com>
Reviewed by Kenneth Rohde Christiansen.
[Qt][WK2] Loading an empty URL crashes
https://bugs.webkit.org/show_bug.cgi?id=55501
A null WKURLRef is created in the API of WebKit 2 when converting a null string. The code
of WKPageLoadURL assume the WKPageRef is not null which causes crashes if it is.
This patch uses the converter toWTFString() to pass from WKPageRef to WTFString. This converter
ensure the returned string is a valid null string.
Tested through the Qt API tests.
* UIProcess/API/C/WKPage.cpp:
(WKPageLoadURL):
* UIProcess/API/qt/tests/qgraphicswkview/tst_qgraphicswkview.cpp:
(tst_QGraphicsWKView::loadEmptyUrl):
* UIProcess/API/qt/tests/qwkpage/qwkpage.pro: Added.
* UIProcess/API/qt/tests/qwkpage/tst_qwkpage.cpp: Added.
(tst_QWKPage::init):
(tst_QWKPage::cleanup):
(tst_QWKPage::loadEmptyUrl):
* UIProcess/API/qt/tests/tests.pro:
2011-03-15 Brady Eidson <beidson@apple.com> 2011-03-15 Brady Eidson <beidson@apple.com>
Reviewed by Sam Weinig. Reviewed by Sam Weinig.
......
...@@ -56,7 +56,7 @@ WKPageGroupRef WKPageGetPageGroup(WKPageRef pageRef) ...@@ -56,7 +56,7 @@ WKPageGroupRef WKPageGetPageGroup(WKPageRef pageRef)
void WKPageLoadURL(WKPageRef pageRef, WKURLRef URLRef) void WKPageLoadURL(WKPageRef pageRef, WKURLRef URLRef)
{ {
toImpl(pageRef)->loadURL(toImpl(URLRef)->string()); toImpl(pageRef)->loadURL(toWTFString(URLRef));
} }
void WKPageLoadURLRequest(WKPageRef pageRef, WKURLRequestRef urlRequestRef) void WKPageLoadURLRequest(WKPageRef pageRef, WKURLRequestRef urlRequestRef)
......
...@@ -35,6 +35,7 @@ private slots: ...@@ -35,6 +35,7 @@ private slots:
void init(); void init();
void cleanup(); void cleanup();
void loadEmptyUrl();
void loadEmptyPage(); void loadEmptyPage();
private: private:
...@@ -87,6 +88,17 @@ void tst_QGraphicsWKView::loadEmptyPage() ...@@ -87,6 +88,17 @@ void tst_QGraphicsWKView::loadEmptyPage()
QVERIFY(waitForSignal(m_view->m_webView, SIGNAL(loadFinished(bool)))); QVERIFY(waitForSignal(m_view->m_webView, SIGNAL(loadFinished(bool))));
} }
void tst_QGraphicsWKView::loadEmptyUrl()
{
// That should not crash.
m_view->show();
m_view->m_webView->load(QUrl());
QVERIFY(!waitForSignal(m_view->m_webView->page(), SIGNAL(engineConnectionChanged(bool)), 50));
m_view->m_webView->load(QUrl(""));
QVERIFY(!waitForSignal(m_view->m_webView->page(), SIGNAL(engineConnectionChanged(bool)), 50));
}
QTEST_MAIN(tst_QGraphicsWKView) QTEST_MAIN(tst_QGraphicsWKView)
#include "tst_qgraphicswkview.moc" #include "tst_qgraphicswkview.moc"
......
/*
Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies)
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Library General Public
License as published by the Free Software Foundation; either
version 2 of the License, or (at your option) any later version.
This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Library General Public License for more details.
You should have received a copy of the GNU Library General Public License
along with this library; see the file COPYING.LIB. If not, write to
the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
Boston, MA 02110-1301, USA.
*/
#include <QScopedPointer>
#include <QtTest/QtTest>
#include <qwkcontext.h>
#include <qwkpage.h>
class tst_QWKPage : public QObject {
Q_OBJECT
private slots:
void init();
void cleanup();
void loadEmptyUrl();
private:
QScopedPointer<QWKContext> m_context;
QScopedPointer<QWKPage> m_page;
};
void tst_QWKPage::init()
{
m_context.reset(new QWKContext);
m_page.reset(new QWKPage(m_context.data()));
}
void tst_QWKPage::cleanup()
{
m_page.reset();
m_context.reset();
}
void tst_QWKPage::loadEmptyUrl()
{
m_page->load(QUrl());
m_page->load(QUrl(""));
}
QTEST_MAIN(tst_QWKPage)
#include "tst_qwkpage.moc"
TEMPLATE = subdirs TEMPLATE = subdirs
SUBDIRS = qgraphicswkview SUBDIRS = qgraphicswkview qwkpage
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