Changeset 64036 in webkit


Ignore:
Timestamp:
Jul 26, 2010 1:53:50 AM (14 years ago)
Author:
Simon Hausmann
Message:

[Qt] Use the default timeout interval for JS as the HTML tokenizer delay for setHtml()

Patch by Tor Arne Vestbø <tor.arne.vestbo@nokia.com> on 2009-10-30
Reviewed by Kenneth Rohde Christiansen.

This ensures that long-running JavaScript (for example due to a modal alert() dialog),
will not trigger a deferred load after only 500ms (the default tokenizer delay) while
still giving a reasonable timeout (10 seconds) to prevent deadlock.

https://bugs.webkit.org/show_bug.cgi?id=29381

JavaScriptCore:

  • runtime/TimeoutChecker.h: Add getter for the timeout interval

WebKit/qt:

  • Api/qwebframe.cpp: Document the behaviour
  • WebCoreSupport/FrameLoaderClientQt.cpp: set the custom tokenizer delay for substitute loads
  • tests/qwebframe/tst_qwebframe.cpp: Add test
Location:
trunk
Files:
6 edited

Legend:

Unmodified
Added
Removed
  • trunk/JavaScriptCore/ChangeLog

    r64027 r64036  
     12009-10-30  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] Use the default timeout interval for JS as the HTML tokenizer delay for setHtml()
     6
     7        This ensures that long-running JavaScript (for example due to a modal alert() dialog),
     8        will not trigger a deferred load after only 500ms (the default tokenizer delay) while
     9        still giving a reasonable timeout (10 seconds) to prevent deadlock.
     10
     11        https://bugs.webkit.org/show_bug.cgi?id=29381
     12
     13        * runtime/TimeoutChecker.h: Add getter for the timeout interval
     14
    1152010-07-25  Patrick Gansterer  <paroga@paroga.com>
    216
  • trunk/JavaScriptCore/runtime/TimeoutChecker.h

    r41126 r64036  
    4141
    4242        void setTimeoutInterval(unsigned timeoutInterval) { m_timeoutInterval = timeoutInterval; }
     43        unsigned timeoutInterval() const { return m_timeoutInterval; }
    4344       
    4445        unsigned ticksUntilNextCheck() { return m_ticksUntilNextCheck; }
  • trunk/WebKit/qt/Api/qwebframe.cpp

    r62903 r64036  
    785785  The \a html is loaded immediately; external objects are loaded asynchronously.
    786786
     787  If a script in the \a html runs longer than the default script timeout (currently 10 seconds),
     788  for example due to being blocked by a modal JavaScript alert dialog, this method will return
     789  as soon as possible after the timeout and any subsequent \a html will be loaded asynchronously.
     790
    787791  When using this method WebKit assumes that external resources such as JavaScript programs or style
    788792  sheets are encoded in UTF-8 unless otherwise specified. For example, the encoding of an external
  • trunk/WebKit/qt/ChangeLog

    r63974 r64036  
     12009-10-30  Tor Arne Vestbø  <tor.arne.vestbo@nokia.com>
     2
     3        Reviewed by Kenneth Rohde Christiansen.
     4
     5        [Qt] Use the default timeout interval for JS as the HTML tokenizer delay for setHtml()
     6
     7        This ensures that long-running JavaScript (for example due to a modal alert() dialog),
     8        will not trigger a deferred load after only 500ms (the default tokenizer delay) while
     9        still giving a reasonable timeout (10 seconds) to prevent deadlock.
     10
     11        https://bugs.webkit.org/show_bug.cgi?id=29381
     12
     13        * Api/qwebframe.cpp: Document the behaviour
     14        * WebCoreSupport/FrameLoaderClientQt.cpp: set the custom tokenizer delay for substitute loads
     15        * tests/qwebframe/tst_qwebframe.cpp: Add test
     16
    1172010-07-23  David Boddie  <dboddie@trolltech.com>
    218
  • trunk/WebKit/qt/WebCoreSupport/FrameLoaderClientQt.cpp

    r63191 r64036  
    4040#include "DocumentLoader.h"
    4141#include "HitTestResult.h"
     42#include "JSDOMWindowBase.h"
    4243#include "MIMETypeRegistry.h"
    4344#include "MouseEvent.h"
     
    880881{
    881882    RefPtr<DocumentLoader> loader = DocumentLoader::create(request, substituteData);
    882     if (!deferMainResourceDataLoad || substituteData.isValid())
     883    if (!deferMainResourceDataLoad || substituteData.isValid()) {
    883884        loader->setDeferMainResourceDataLoad(false);
     885        // Use the default timeout interval for JS as the HTML tokenizer delay. This ensures
     886        // that long-running JavaScript will still allow setHtml() to be synchronous, while
     887        // still giving a reasonable timeout to prevent deadlock.
     888        double delay = JSDOMWindowBase::commonJSGlobalData()->timeoutChecker.timeoutInterval() / 1000.0f;
     889        m_frame->page()->setCustomHTMLTokenizerTimeDelay(delay);
     890    } else
     891        m_frame->page()->setCustomHTMLTokenizerTimeDelay(-1);
    884892    return loader.release();
    885893}
  • trunk/WebKit/qt/tests/qwebframe/tst_qwebframe.cpp

    r62898 r64036  
    602602    void setHtmlWithResource();
    603603    void setHtmlWithBaseURL();
     604    void setHtmlWithJSAlert();
    604605    void ipv6HostEncoding();
    605606    void metaData();
     
    25562557}
    25572558
     2559class MyPage : public QWebPage
     2560{
     2561public:
     2562    MyPage() :  QWebPage(), alerts(0) {}
     2563    int alerts;
     2564
     2565protected:
     2566    virtual void javaScriptAlert(QWebFrame*, const QString& msg)
     2567    {
     2568        alerts++;
     2569        QCOMPARE(msg, QString("foo"));
     2570        // Should not be enough to trigger deferred loading, since we've upped the HTML
     2571        // tokenizer delay in the Qt frameloader. See HTMLTokenizer::continueProcessing()
     2572        QTest::qWait(1000);
     2573    }
     2574};
     2575
     2576void tst_QWebFrame::setHtmlWithJSAlert()
     2577{
     2578    QString html("<html><head></head><body><script>alert('foo');</script><p>hello world</p></body></html>");
     2579    MyPage page;
     2580    m_view->setPage(&page);
     2581    page.mainFrame()->setHtml(html);
     2582    QCOMPARE(page.alerts, 1);
     2583    QCOMPARE(m_view->page()->mainFrame()->toHtml(), html);
     2584}
     2585
    25582586class TestNetworkManager : public QNetworkAccessManager
    25592587{
Note: See TracChangeset for help on using the changeset viewer.