Changeset 55893 in webkit


Ignore:
Timestamp:
Mar 12, 2010 6:06:31 AM (14 years ago)
Author:
eric@webkit.org
Message:

2010-03-12 Jochen Eisinger <jochen@chromium.org>

Reviewed by Jeremy Orlow.

Test for referrer information being stripped when the header is removed in willSendRequest
https://bugs.webkit.org/show_bug.cgi?id=35920

  • http/tests/security/no-referrer-expected.txt: Added.
  • http/tests/security/no-referrer.html: Added.
  • http/tests/security/resources/no-referrer-frame.php: Added.
  • http/tests/security/resources/no-referrer.php: Added.
  • platform/gtk/Skipped:
  • platform/qt/Skipped:

2010-03-12 Jochen Eisinger <jochen@chromium.org>

Reviewed by Jeremy Orlow.

Introduce setWillSendRequestClearHeader to LayoutTestController to selectively remove headers in willSendRequest. Used in http/tests/security/no-referrer.html
https://bugs.webkit.org/show_bug.cgi?id=35920

  • DumpRenderTree/LayoutTestController.cpp: (setWillSendRequestClearHeaderCallback): (LayoutTestController::staticFunctions):
  • DumpRenderTree/LayoutTestController.h: (LayoutTestController::willSendRequestClearHeaders): (LayoutTestController::setWillSendRequestClearHeader):
  • DumpRenderTree/mac/ResourceLoadDelegate.mm: (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):
  • DumpRenderTree/win/ResourceLoadDelegate.cpp: (ResourceLoadDelegate::willSendRequest):
Location:
trunk
Files:
4 added
8 edited

Legend:

Unmodified
Added
Removed
  • trunk/LayoutTests/ChangeLog

    r55892 r55893  
     12010-03-12  Jochen Eisinger  <jochen@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        Test for referrer information being stripped when the header is removed in willSendRequest
     6        https://bugs.webkit.org/show_bug.cgi?id=35920
     7
     8        * http/tests/security/no-referrer-expected.txt: Added.
     9        * http/tests/security/no-referrer.html: Added.
     10        * http/tests/security/resources/no-referrer-frame.php: Added.
     11        * http/tests/security/resources/no-referrer.php: Added.
     12        * platform/gtk/Skipped:
     13        * platform/qt/Skipped:
     14
    1152010-03-12  Nikolas Zimmermann  <nzimmermann@rim.com>
    216
  • trunk/LayoutTests/platform/gtk/Skipped

    r55852 r55893  
    56775677media/video-loop.html
    56785678
     5679# GTK+ does not have layoutTestController.setWillSendRequestClearHeader.
     5680http/tests/security/no-referrer.html
     5681
    56795682# GTK+ does not have layoutTestController.setWillSendRequestReturnsNull.
    56805683fast/loader/onload-willSendRequest-null-for-script.html
  • trunk/LayoutTests/platform/qt/Skipped

    r55886 r55893  
    199199http/tests/misc/redirect-to-external-url.html
    200200http/tests/security/feed-urls-from-remote.html
     201
     202# Missing layoutTestController.setWillSendRequestClearHeader()
     203http/tests/security/no-referrer.html
    201204
    202205# Missing layoutTestController.setWillSendRequestReturnsNull()
  • trunk/WebKitTools/ChangeLog

    r55884 r55893  
     12010-03-12  Jochen Eisinger  <jochen@chromium.org>
     2
     3        Reviewed by Jeremy Orlow.
     4
     5        Introduce setWillSendRequestClearHeader to LayoutTestController to selectively remove headers in willSendRequest. Used in http/tests/security/no-referrer.html
     6        https://bugs.webkit.org/show_bug.cgi?id=35920
     7
     8        * DumpRenderTree/LayoutTestController.cpp:
     9        (setWillSendRequestClearHeaderCallback):
     10        (LayoutTestController::staticFunctions):
     11        * DumpRenderTree/LayoutTestController.h:
     12        (LayoutTestController::willSendRequestClearHeaders):
     13        (LayoutTestController::setWillSendRequestClearHeader):
     14        * DumpRenderTree/mac/ResourceLoadDelegate.mm:
     15        (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]):
     16        * DumpRenderTree/win/ResourceLoadDelegate.cpp:
     17        (ResourceLoadDelegate::willSendRequest):
     18
    1192010-03-11  Fumitoshi Ukai  <ukai@chromium.org>
    220
  • trunk/WebKitTools/DumpRenderTree/LayoutTestController.cpp

    r55582 r55893  
    10201020    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
    10211021    controller->setUserStyleSheetLocation(path.get());
     1022
     1023    return JSValueMakeUndefined(context);
     1024}
     1025
     1026static JSValueRef setWillSendRequestClearHeaderCallback(JSContextRef context, JSObjectRef function, JSObjectRef thisObject, size_t argumentCount, const JSValueRef arguments[], JSValueRef* exception)
     1027{
     1028    // Has mac & windows implementation
     1029    if (argumentCount < 1)
     1030        return JSValueMakeUndefined(context);
     1031
     1032    JSRetainPtr<JSStringRef> header(Adopt, JSValueToStringCopy(context, arguments[0], exception));
     1033    ASSERT(!*exception);
     1034
     1035    size_t maxLength = JSStringGetMaximumUTF8CStringSize(header.get());
     1036    char* headerBuffer = new char[maxLength + 1];
     1037    JSStringGetUTF8CString(header.get(), headerBuffer, maxLength + 1);
     1038
     1039    LayoutTestController* controller = static_cast<LayoutTestController*>(JSObjectGetPrivate(thisObject));
     1040    controller->setWillSendRequestClearHeader(headerBuffer);
    10221041
    10231042    return JSValueMakeUndefined(context);
     
    14641483        { "setUserStyleSheetEnabled", setUserStyleSheetEnabledCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    14651484        { "setUserStyleSheetLocation", setUserStyleSheetLocationCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
     1485        { "setWillSendRequestClearHeader", setWillSendRequestClearHeaderCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    14661486        { "setWillSendRequestReturnsNull", setWillSendRequestReturnsNullCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
    14671487        { "setWillSendRequestReturnsNullOnRedirect", setWillSendRequestReturnsNullOnRedirectCallback, kJSPropertyAttributeReadOnly | kJSPropertyAttributeDontDelete },
  • trunk/WebKitTools/DumpRenderTree/LayoutTestController.h

    r55582 r55893  
    3232#include <JavaScriptCore/JSObjectRef.h>
    3333#include <JavaScriptCore/JSRetainPtr.h>
    34 #include <wtf/RefCounted.h>
     34#include <set>
    3535#include <string>
    3636#include <vector>
     37#include <wtf/RefCounted.h>
    3738
    3839class LayoutTestController : public RefCounted<LayoutTestController> {
     
    187188    void waitToDumpWatchdogTimerFired();
    188189
     190    const std::set<std::string>& willSendRequestClearHeaders() const { return m_willSendRequestClearHeaders; }
     191    void setWillSendRequestClearHeader(std::string header) { m_willSendRequestClearHeaders.insert(header); }
     192
    189193    bool willSendRequestReturnsNull() const { return m_willSendRequestReturnsNull; }
    190194    void setWillSendRequestReturnsNull(bool returnsNull) { m_willSendRequestReturnsNull = returnsNull; }
     
    285289    std::string m_testPathOrURL;
    286290    std::string m_expectedPixelHash;    // empty string if no hash
     291
     292    std::set<std::string> m_willSendRequestClearHeaders;
    287293   
    288294    // origins which have been granted desktop notification access
  • trunk/WebKitTools/DumpRenderTree/mac/ResourceLoadDelegate.mm

    r53277 r55893  
    3636#import <wtf/Assertions.h>
    3737
     38using namespace std;
     39
    3840@interface NSURL (DRTExtras)
    3941- (NSString *)_drt_descriptionSuitableForTestResult;
     
    122124}
    123125
    124 -(NSURLRequest *)webView: (WebView *)wv resource:identifier willSendRequest: (NSURLRequest *)newRequest redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
    125 {
    126     if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) {
    127         NSString *string = [NSString stringWithFormat:@"%@ - willSendRequest %@ redirectResponse %@", identifier, [newRequest _drt_descriptionSuitableForTestResult],
     126-(NSURLRequest *)webView: (WebView *)wv resource:identifier willSendRequest: (NSURLRequest *)request redirectResponse:(NSURLResponse *)redirectResponse fromDataSource:(WebDataSource *)dataSource
     127{
     128    if (!done && gLayoutTestController->dumpResourceLoadCallbacks()) {
     129        NSString *string = [NSString stringWithFormat:@"%@ - willSendRequest %@ redirectResponse %@", identifier, [request _drt_descriptionSuitableForTestResult],
    128130            [redirectResponse _drt_descriptionSuitableForTestResult]];
    129131        printf("%s\n", [string UTF8String]);
     
    138140    }
    139141
    140     NSURL *url = [newRequest URL];
     142    NSURL *url = [request URL];
    141143    NSString *host = [url host];
    142144    if (host
     
    152154        return nil;
    153155
    154     return newRequest;
     156    NSMutableURLRequest *newRequest = [request mutableCopy];
     157    const set<string>& clearHeaders = gLayoutTestController->willSendRequestClearHeaders();
     158    for (set<string>::const_iterator header = clearHeaders.begin(); header != clearHeaders.end(); ++header) {
     159        NSString *nsHeader = [[NSString alloc] initWithUTF8String:header->c_str()];
     160        [newRequest setValue:nil forHTTPHeaderField:nsHeader];
     161        [nsHeader release];
     162    }
     163
     164    return [newRequest autorelease];
    155165}
    156166
  • trunk/WebKitTools/DumpRenderTree/win/ResourceLoadDelegate.cpp

    r53277 r55893  
    3232#include "DumpRenderTree.h"
    3333#include "LayoutTestController.h"
     34#include <WebKit/WebKitCOMAPI.h>
    3435#include <comutil.h>
    35 #include <WebKit/WebKitCOMAPI.h>
     36#include <sstream>
     37#include <tchar.h>
    3638#include <wtf/HashMap.h>
    3739#include <wtf/Vector.h>
    38 #include <sstream>
    39 
    40 
    41 using std::wstring;
    42 using std::wiostream;
     40
     41using namespace std;
    4342
    4443static inline wstring wstringFromBSTR(BSTR str)
     
    4746}
    4847
    49 wstring wstringFromInt(int i)
    50 {
    51     std::wostringstream ss;
     48static inline wstring wstringFromInt(int i)
     49{
     50    wostringstream ss;
    5251    ss << i;
    5352    return ss.str();
     53}
     54
     55static inline BSTR BSTRFromString(const string& str)
     56{
     57    int length = ::MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), 0, 0);
     58    BSTR result = ::SysAllocStringLen(0, length);
     59    ::MultiByteToWideChar(CP_UTF8, 0, str.c_str(), str.length(), result, length);
     60    return result;
    5461}
    5562
     
    255262    }
    256263
    257     request->AddRef();
    258     *newRequest = request;
     264    IWebMutableURLRequest* requestCopy = 0;
     265    request->mutableCopy(&requestCopy);
     266    const set<string>& clearHeaders = gLayoutTestController->willSendRequestClearHeaders();
     267    for (set<string>::const_iterator header = clearHeaders.begin(); header != clearHeaders.end(); ++header) {
     268      BSTR bstrHeader = BSTRFromString(*header);
     269      requestCopy->setValue(0, bstrHeader);
     270      SysFreeString(bstrHeader);
     271    }
     272
     273    *newRequest = requestCopy;
    259274    return S_OK;
    260275}
Note: See TracChangeset for help on using the changeset viewer.