Changeset 59669 in webkit


Ignore:
Timestamp:
May 18, 2010 7:07:00 AM (14 years ago)
Author:
Simon Hausmann
Message:

[Qt] Fix http/tests/xmlhttprequest/cross-origin-no-authorization.html

2010-05-08 Robert Hogan <robert@roberthogan.net>

Reviewed by Simon Hausmann.

[Qt] Fix http/tests/xmlhttprequest/cross-origin-no-authorization.html

and http/tests/xmlhttprequest/cross-origin-authorization.html

QHttpNetworkRequest adds Authorization and Cookie headers to XHRs
without knowing if this is valid behaviour or not. In order to allow
Qt to decide whether Cookie/Authorization headers should be added
to an XHR QtWebKit needs to use an attribute added to QNetworkRequest.
These new attributes are: QNetworkRequest::CookieLoadControlAttribute,
QNetworkRequest::CookieSaveControlAttribute,and
QNetworkRequest::AuthenticationReuseControlAttribute.

QtWebKit will set QNetworkRequest::AuthenticationReuseControlAttribute to false
unless withCredentials is set to true in the XHR.

QtWebkit will set CookieLoad/SaveControlAttribute to false unless withCredentials
is set to true in the XHR.

Qt will pass the values onto QHttpNetworkRequest and this will permit
the Qt network access processing to decide whether or not to add either
or both of the Cookie/Authorisation headers, and whether to save cookies
returned from such requests. By default the attribute
will always be true so unless QtWebKit sets it to false normal
header processing is unaffected.

There are platform-specific results for cross-origin-no-authorization.html:

  1. Qt's DRT does not capture the final 'DONE'.
  2. QNetworkReplyHandler.cpp's ignoreHttpError() means that async requests do not execute didFail() when they receive a 401 HTTP response. This results in async tests passing with '401 Authorisation required' rather than 'received error event'.

The Qt part of these changes was merged at: http://gitorious.org/qt/qt/merge_requests/592

In order to properly support the tests, Qt's DRT needs to use one
NetworkAccessManager for all pages. This allows it to use cached
credentials where appropriate.

The tests now pass when run individually but there seems to be a problem with
leaking the results of requests across tests when run with the others in
http/tests. This will be addressed in a separate patch.

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

  • DumpRenderTree/qt/DumpRenderTreeQt.cpp: (WebCore::WebPage::WebPage): (WebCore::DumpRenderTree::DumpRenderTree):
  • DumpRenderTree/qt/DumpRenderTreeQt.h:
  • platform/network/qt/ResourceRequestQt.cpp: (WebCore::ResourceRequest::toNetworkRequest):
  • platform/qt/Skipped: Group together the tests that are waiting for 4.7 to be unskipped.
  • platform/qt/http/tests/xmlhttprequest/cross-origin-no-authorization-expected.txt: Added.
Location:
trunk
Files:
5 edited

Legend:

Unmodified
Added
Removed
  • trunk/WebCore/ChangeLog

    r59668 r59669  
     12010-05-08  Robert Hogan  <robert@roberthogan.net>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Fix http/tests/xmlhttprequest/cross-origin-no-authorization.html
     6             and http/tests/xmlhttprequest/cross-origin-authorization.html
     7
     8        QHttpNetworkRequest adds Authorization and Cookie headers to XHRs
     9        without knowing if this is valid behaviour or not. In order to allow
     10        Qt to decide whether Cookie/Authorization headers should be added
     11        to an XHR QtWebKit needs to use an attribute added to QNetworkRequest.
     12        These new attributes are: QNetworkRequest::CookieLoadControlAttribute,
     13        QNetworkRequest::CookieSaveControlAttribute,and
     14        QNetworkRequest::AuthenticationReuseControlAttribute.
     15
     16        QtWebKit will set QNetworkRequest::AuthenticationReuseControlAttribute to false
     17        unless withCredentials is set to true in the XHR.
     18
     19        QtWebkit will set CookieLoad/SaveControlAttribute to false unless withCredentials
     20        is set to true in the XHR.
     21
     22        Qt will pass the values onto QHttpNetworkRequest and this will permit
     23        the Qt network access processing to decide whether or not to add either
     24        or both of the Cookie/Authorisation headers, and whether to save cookies
     25        returned from such requests. By default the attribute
     26        will always be true so unless QtWebKit sets it to false normal
     27        header processing is unaffected.
     28
     29        The Qt part of these changes was merged at: http://gitorious.org/qt/qt/merge_requests/592
     30
     31        https://bugs.webkit.org/show_bug.cgi?id=32967
     32
     33        * platform/network/qt/ResourceRequestQt.cpp:
     34        (WebCore::ResourceRequest::toNetworkRequest):
     35
    1362010-05-18  Zoltan Herczeg  <zherczeg@webkit.org>
    237
  • trunk/WebCore/platform/network/qt/ResourceRequestQt.cpp

    r59076 r59669  
    8181    }
    8282
     83#if QT_VERSION >= QT_VERSION_CHECK(4, 7, 0)
     84    if (!allowCookies()) {
     85        request.setAttribute(QNetworkRequest::CookieLoadControlAttribute, QNetworkRequest::Manual);
     86        request.setAttribute(QNetworkRequest::CookieSaveControlAttribute, QNetworkRequest::Manual);
     87        request.setAttribute(QNetworkRequest::AuthenticationReuseAttribute, QNetworkRequest::Manual);
     88    }
     89#endif
     90
    8391    return request;
    8492}
  • trunk/WebKitTools/ChangeLog

    r59666 r59669  
     12010-05-08  Robert Hogan  <robert@roberthogan.net>
     2
     3        Reviewed by Simon Hausmann.
     4
     5        [Qt] Fix http/tests/xmlhttprequest/cross-origin-no-authorization.html
     6             and http/tests/xmlhttprequest/cross-origin-authorization.html
     7
     8        QHttpNetworkRequest adds Authorization and Cookie headers to XHRs
     9        without knowing if this is valid behaviour or not. In order to allow
     10        Qt to decide whether Cookie/Authorization headers should be added
     11        to an XHR QtWebKit needs to use an attribute added to QNetworkRequest.
     12        These new attributes are: QNetworkRequest::CookieLoadControlAttribute,
     13        QNetworkRequest::CookieSaveControlAttribute,and
     14        QNetworkRequest::AuthenticationReuseControlAttribute.
     15
     16        In order to properly support the tests, Qt's DRT needs to use one
     17        NetworkAccessManager for all pages. This allows it to use cached
     18        credentials where appropriate.
     19
     20        The tests now pass when run individually but there seems to be a problem with
     21        leaking the results of requests across tests when run with the others in
     22        http/tests. This will be addressed in a separate patch.
     23
     24        https://bugs.webkit.org/show_bug.cgi?id=32967
     25
     26
     27        * DumpRenderTree/qt/DumpRenderTreeQt.cpp:
     28        (WebCore::WebPage::WebPage):
     29        (WebCore::DumpRenderTree::DumpRenderTree):
     30        * DumpRenderTree/qt/DumpRenderTreeQt.h:
     31
     32
    1332010-05-18  Fumitoshi Ukai  <ukai@chromium.org>
    234
  • trunk/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.cpp

    r59623 r59669  
    157157            this, SLOT(setViewGeometry(const QRect & )));
    158158
    159     setNetworkAccessManager(new NetworkAccessManager(this));
     159    setNetworkAccessManager(m_drt->networkAccessManager());
    160160    setPluginFactory(new TestPlugin(this));
    161161}
     
    347347    QWebSettings::enablePersistentStorage(m_persistentStoragePath);
    348348
     349    m_networkAccessManager = new NetworkAccessManager(this);
    349350    // create our primary testing page/view.
    350351    m_mainView = new QWebView(0);
  • trunk/WebKitTools/DumpRenderTree/qt/DumpRenderTreeQt.h

    r59623 r59669  
    6262
    6363class WebPage;
     64class NetworkAccessManager;
    6465
    6566class DumpRenderTree : public QObject {
     
    8889    TextInputController *textInputController() const { return m_textInputController; }
    8990    QString persistentStoragePath() const { return m_persistentStoragePath; }
     91    NetworkAccessManager *networkAccessManager() const { return m_networkAccessManager; }
    9092
    9193    QWebPage *createWindow();
     
    9597
    9698    WebPage *webPage() const { return m_page; }
    97 
    9899
    99100#if defined(Q_WS_X11)
     
    137138    TextInputController *m_textInputController;
    138139    GCController* m_gcController;
     140    NetworkAccessManager* m_networkAccessManager;
    139141
    140142    QFile *m_stdin;
Note: See TracChangeset for help on using the changeset viewer.