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

2009-05-05 Simon Hausmann <simon.hausmann@nokia.com>

        Reviewed by Ariya Hidayat.

        Make convertValueToQVariant more robust against null JSValues.

        Don't require the caller to do the null check.

git-svn-id: http://svn.webkit.org/repository/webkit/trunk@43219 268f45cc-cd09-0410-ab3c-d52691b4dbfc
parent 69965db6
2009-05-05 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Ariya Hidayat.
Make convertValueToQVariant more robust against null JSValues.
Don't require the caller to do the null check.
* bridge/qt/qt_runtime.cpp:
(JSC::Bindings::convertValueToQVariant):
2009-05-05 Eric Seidel <eric@webkit.org>
No review, just a revert.
......@@ -145,6 +145,9 @@ static JSRealType valueRealType(ExecState* exec, JSValue val)
QVariant convertValueToQVariant(ExecState* exec, JSValue value, QMetaType::Type hint, int *distance, HashSet<JSObject*>* visitedObjects)
{
if (!value)
return QVariant();
JSObject* object = 0;
if (value.isObject()) {
object = value.toObject(exec);
......
......@@ -1127,10 +1127,8 @@ QVariant QWebFrame::evaluateJavaScript(const QString& scriptSource)
QVariant rc;
if (proxy) {
JSC::JSValue v = proxy->evaluate(ScriptSourceCode(scriptSource)).jsValue();
if (v) {
int distance = 0;
rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject()->globalExec(), v, QMetaType::Void, &distance);
}
int distance = 0;
rc = JSC::Bindings::convertValueToQVariant(proxy->globalObject()->globalExec(), v, QMetaType::Void, &distance);
}
return rc;
}
......
2009-05-05 Simon Hausmann <simon.hausmann@nokia.com>
Reviewed by Ariya Hidayat.
Simplify variant conversion by moving the null check into
convertValueToQVariant.
* Api/qwebframe.cpp:
(QWebFrame::evaluateJavaScript): Moved null check into conversion function.
* tests/qwebframe/tst_qwebframe.cpp:
Added test to verify the correct conversion of null values to QVariant.
2009-05-01 Geoffrey Garen <ggaren@apple.com>
Rubber Stamped by Sam Weinig.
......
......@@ -579,6 +579,7 @@ private slots:
void hitTestContent();
void jsByteArray();
void ownership();
void nullValue();
private:
QString evalJS(const QString&s) {
// Convert an undefined return variant to the string "undefined"
......@@ -2365,5 +2366,11 @@ void tst_QWebFrame::ownership()
}
}
void tst_QWebFrame::nullValue()
{
QVariant v = m_view->page()->mainFrame()->evaluateJavaScript("null");
QVERIFY(v.isNull());
}
QTEST_MAIN(tst_QWebFrame)
#include "tst_qwebframe.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