Bug 29481 - [Qt] QWebFrame::evaluateJavaScript() always returns null
Summary: [Qt] QWebFrame::evaluateJavaScript() always returns null
Status: RESOLVED INVALID
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebKit Qt (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Nobody
URL:
Keywords: Qt
Depends on:
Blocks:
 
Reported: 2009-09-18 08:44 PDT by Tor Arne Vestbø
Modified: 2009-11-04 05:05 PST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tor Arne Vestbø 2009-09-18 08:44:50 PDT
This bug report originated from issue QTBUG-3019
http://bugreports.qt.nokia.com/browse/QTBUG-3019

--- Description ---

EvaluateJavaScript is supposed to provide the return value of the script. It's always null. 
http://doc.trolltech.com/4.4/qwebframe.html#evaluateJavaScript


int main(int argc, char *argv[])
{
    QApplication app(argc, argv);

    QWebView *view = new QWebView;
    view->setHtml("<html><body>Hello world</body></html>");
    view->show();

    QEventLoop l;
    QTimer::singleShot(2000, &l, SLOT(quit()));
    l.exec();

    qDebug() << "evaluating javascript";

    QVariant retval = view->page()->mainFrame()->evaluateJavaScript("alert('hi'); return true;");
    qDebug() << retval;

    return app.exec();
}
Comment 1 Jędrzej Nowacki 2009-10-29 06:21:12 PDT
In example JavaScript code: "alert('hi'); return true;" throw an exception. 
SyntaxError: Invalid return statement. 
Return key word can't be used outside functions body.

Should be:
"alert('hi'); a = true;" or just "alert('hi'); true;"

The test case is wrong. Please close the bug.
Comment 2 Jędrzej Nowacki 2009-11-04 05:05:52 PST
(In reply to comment #1)
> The test case is wrong. Please close the bug.
Closing.