Bug 29381 - [Qt] [Regression] QWebView::setHtml() executes script body twice
Summary: [Qt] [Regression] QWebView::setHtml() executes script body twice
Status: RESOLVED FIXED
Alias: None
Product: WebKit
Classification: Unclassified
Component: WebCore JavaScript (show other bugs)
Version: 528+ (Nightly build)
Hardware: Other OS X 10.5
: P2 Normal
Assignee: Tor Arne Vestbø
URL:
Keywords: Qt
Depends on: 30879
Blocks:
  Show dependency treegraph
 
Reported: 2009-09-18 07:04 PDT by Tor Arne Vestbø
Modified: 2011-04-19 05:15 PDT (History)
4 users (show)

See Also:


Attachments
[Qt] Use the default timeout interval for JS as the HTML tokenizer delay for setHtml() (7.84 KB, patch)
2009-10-30 06:27 PDT, Tor Arne Vestbø
no flags Details | Formatted Diff | Diff

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

--- Description ---

QWebView::setHtml() executes script body twice, the following example will show the alert message box two times. This is a regression from Qt 4.4.3.


class widget : public QWebView
{
public:
    widget(QWidget* parent = 0)
        : QWebView(parent)
    {
        setHtml("<html><body><script>\n"
                "var x = new Date();\n"
                "alert(x);\n"
                "</script></body></html>\n");
    }
};

int main(int argc, char **argv)
{
    QApplication a(argc, argv);
    widget w;
    w.show();
    return a.exec();
}
Comment 1 Tor Arne Vestbø 2009-09-25 04:25:34 PDT
Confirmed in trunk. Also, when the alert() is active the body element will contain the following innerHTML:

<script>
var x = new Date();
alert('foo');
document.write('Date: ' + x + '<br>');
</script>Date: Fri Sep 25 2009 13:23:25 GMT+0200 (CEST)<br><script>
var x = new Date();
alert('foo');
document.write('Date: ' + x + '<br>');
</script>Date: Fri Sep 25 2009 13:23:26 GMT+0200 (CEST)<br>hallo
hallo


using the following snippet:

#include <QtGui>
#include <QWebView.h>

int main(int argc, char **argv)
{
    QApplication a(argc, argv);
    QWebView w;
    w.setHtml("<html><body><script>\n"
                "var x = new Date();\n"
                "alert('foo');\n"
                "document.write('Date: ' + x + '<br>');\n"
                "</script>hallo</body></html>\n");
    w.show();
    return a.exec();
}
Comment 2 Tor Arne Vestbø 2009-10-30 06:27:35 PDT
Created attachment 42209 [details]
[Qt] Use the default timeout interval for JS as the HTML tokenizer delay for setHtml()
Comment 3 Kenneth Rohde Christiansen 2009-11-10 05:15:46 PST
Would be nice to have API for setting the default timeout. Especially for slower embedded devices.
Comment 4 Tor Arne Vestbø 2009-11-10 06:36:31 PST
(In reply to comment #3)
> Would be nice to have API for setting the default timeout. Especially for
> slower embedded devices.

True, this also relates to the QtScript stuff.

Btw, this patch needs 30879 to land first.
Comment 5 Eric Seidel (no email) 2009-12-28 23:00:14 PST
Ping?  Should this still be marked r+ and in the pending-commit list?  There has been no action on this bug in over a month and a half...
Comment 6 Tor Arne Vestbø 2010-01-04 00:29:58 PST
Pong. It depends on bug 30879, which I need to write a LayoutTest for first.
Comment 7 Tor Arne Vestbø 2010-02-09 02:20:40 PST
Comment on attachment 42209 [details]
[Qt] Use the default timeout interval for JS as the HTML tokenizer delay for setHtml()

Clearing r+ since this patch depends on another bug to be landed first.
Comment 8 Simon Hausmann 2010-03-28 23:46:42 PDT
Should we backport this patch and the one in the depending bug into the branch?
Comment 9 Simon Hausmann 2010-07-26 01:54:29 PDT
Committed r64036: <http://trac.webkit.org/changeset/64036>
Comment 10 Simon Hausmann 2010-07-26 06:54:14 PDT
Revision r64036 cherry-picked into qtwebkit-2.0 with commit a72015752c7cd51dad5602166422c5cce9332d95
Comment 11 Simon Hausmann 2010-07-30 04:11:00 PDT
Revision r64036 cherry-picked into qtwebkit-2.1 with commit 0698601d6735cfc493ecd0177b6cfadfc48e6188