Skip to content
  • mitz@apple.com's avatar
    <rdar://problem/8827065> REGRESSION (r71884): Cross-origin XHR fails if... · 1c3ad0ea
    mitz@apple.com authored
    <rdar://problem/8827065> REGRESSION (r71884): Cross-origin XHR fails if willSendRequest changes the URL
    https://bugs.webkit.org/show_bug.cgi?id=52419
    
    Reviewed by Alexey Proskuryakov.
    
    Source/WebCore: 
    
    Test: http/tests/loading/cross-origin-XHR-willLoadRequest.html
    
    * loader/ResourceLoader.cpp:
    (WebCore::ResourceLoader::init): Complete r74453 by ensuring that m_request is only set after
    willSendRequest(). Otherwise, willSendRequest() ends up calling into
    ThreadableDocumentRequest::willSendRequest(), which cancels the request.
    
    Tools: 
    
    Allow to further control the behavior of the willSendRequest delegate callback by making it
    set a different URL in the new request.
    
    * DumpRenderTree/LayoutTestController.cpp:
    (addURLToRedirectCallback): Added.
    (LayoutTestController::staticFunctions): Added addURLToRedirect.
    (LayoutTestController::addURLToRedirect): Added. Adds the redirection to the map.
    (LayoutTestController::redirectionDestinationForURL): Added this getter.
    * DumpRenderTree/LayoutTestController.h:
    * DumpRenderTree/mac/ResourceLoadDelegate.mm:
    (-[ResourceLoadDelegate webView:resource:willSendRequest:redirectResponse:fromDataSource:]): Check
    if there is a redirection for the request’s URL, established by addURLToRedirect(), and if so,
    change the URL in the new request to the redirect destination.
    
    LayoutTests: 
    
    * http/tests/loading/cross-origin-XHR-willLoadRequest-expected.txt: Added.
    * http/tests/loading/cross-origin-XHR-willLoadRequest.html: Added.
    * platform/gtk/Skipped: Skip the new test.
    * platform/qt/Skipped: Ditto.
    * platform/win/Skipped: Ditto.
    
    
    
    git-svn-id: http://svn.webkit.org/repository/webkit/trunk@75768 268f45cc-cd09-0410-ab3c-d52691b4dbfc
    1c3ad0ea