diff options
27 files changed, 157 insertions, 258 deletions
diff --git a/chrome/renderer/render_view.cc b/chrome/renderer/render_view.cc index c1ace50..9b5806c 100644 --- a/chrome/renderer/render_view.cc +++ b/chrome/renderer/render_view.cc @@ -1463,7 +1463,8 @@ void RenderView::WillSubmitForm(WebView* webview, WebFrame* frame, } void RenderView::WillSendRequest(WebFrame* frame, uint32 identifier, - WebURLRequest* request) { + WebURLRequest* request, + const WebURLResponse& redirect_response) { request->setRequestorID(routing_id_); } diff --git a/chrome/renderer/render_view.h b/chrome/renderer/render_view.h index 255c7a5..e676272 100644 --- a/chrome/renderer/render_view.h +++ b/chrome/renderer/render_view.h @@ -220,7 +220,8 @@ class RenderView : public RenderWidget, const WebKit::WebForm& form); virtual void WillSendRequest(WebFrame* webframe, uint32 identifier, - WebKit::WebURLRequest* request); + WebKit::WebURLRequest* request, + const WebKit::WebURLResponse& redirect_response); virtual void DidReceiveResponse(WebFrame* webframe, uint32 identifier, const WebKit::WebURLResponse& response); diff --git a/webkit/api/public/WebURLRequest.h b/webkit/api/public/WebURLRequest.h index 6499b85..1f3b506 100644 --- a/webkit/api/public/WebURLRequest.h +++ b/webkit/api/public/WebURLRequest.h @@ -79,7 +79,7 @@ namespace WebKit { WEBKIT_API void reset(); WEBKIT_API void assign(const WebURLRequest&); - bool isNull() const { return m_private == 0; } + WEBKIT_API bool isNull() const; WEBKIT_API WebURL url() const; WEBKIT_API void setURL(const WebURL&); diff --git a/webkit/api/public/WebURLResponse.h b/webkit/api/public/WebURLResponse.h index 2fb51b2..cb17d65 100644 --- a/webkit/api/public/WebURLResponse.h +++ b/webkit/api/public/WebURLResponse.h @@ -62,7 +62,7 @@ namespace WebKit { WEBKIT_API void reset(); WEBKIT_API void assign(const WebURLResponse&); - bool isNull() const { return m_private == 0; } + WEBKIT_API bool isNull() const; WEBKIT_API WebURL url() const; WEBKIT_API void setURL(const WebURL&); diff --git a/webkit/api/src/WebURLRequest.cpp b/webkit/api/src/WebURLRequest.cpp index d6eb114..14f5b8d 100644 --- a/webkit/api/src/WebURLRequest.cpp +++ b/webkit/api/src/WebURLRequest.cpp @@ -78,6 +78,11 @@ void WebURLRequest::assign(const WebURLRequest& r) assign(r.m_private ? new WebURLRequestPrivateImpl(r.m_private) : 0); } +bool WebURLRequest::isNull() const +{ + return !m_private || m_private->m_resourceRequest->isNull(); +} + WebURL WebURLRequest::url() const { return m_private->m_resourceRequest->url(); diff --git a/webkit/api/src/WebURLResponse.cpp b/webkit/api/src/WebURLResponse.cpp index 2fe6d64..14e95b9 100644 --- a/webkit/api/src/WebURLResponse.cpp +++ b/webkit/api/src/WebURLResponse.cpp @@ -78,6 +78,11 @@ void WebURLResponse::assign(const WebURLResponse& r) assign(r.m_private ? new WebURLResponsePrivateImpl(r.m_private) : 0); } +bool WebURLResponse::isNull() const +{ + return !m_private || m_private->m_resourceResponse->isNull(); +} + WebURL WebURLResponse::url() const { return m_private->m_resourceResponse->url(); diff --git a/webkit/api/src/WrappedResourceRequest.h b/webkit/api/src/WrappedResourceRequest.h index f232375..07e14ee 100644 --- a/webkit/api/src/WrappedResourceRequest.h +++ b/webkit/api/src/WrappedResourceRequest.h @@ -65,8 +65,7 @@ namespace WebKit { void bind(const WebCore::ResourceRequest& resourceRequest) { - m_handle.m_resourceRequest = const_cast<WebCore::ResourceRequest*>(&resourceRequest); - assign(&m_handle); + bind(*const_cast<WebCore::ResourceRequest*>(&resourceRequest)); } private: diff --git a/webkit/api/src/WrappedResourceResponse.h b/webkit/api/src/WrappedResourceResponse.h index 8c44315..67d7018 100644 --- a/webkit/api/src/WrappedResourceResponse.h +++ b/webkit/api/src/WrappedResourceResponse.h @@ -65,8 +65,7 @@ namespace WebKit { void bind(const WebCore::ResourceResponse& resourceResponse) { - m_handle.m_resourceResponse = const_cast<WebCore::ResourceResponse*>(&resourceResponse); - assign(&m_handle); + bind(*const_cast<WebCore::ResourceResponse*>(&resourceResponse)); } private: diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/loading/redirect-methods-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/loading/redirect-methods-expected.txt deleted file mode 100644 index b00a006..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/loading/redirect-methods-expected.txt +++ /dev/null @@ -1,99 +0,0 @@ -main frame - didStartProvisionalLoadForFrame -main frame - didCommitLoadForFrame -main frame - didFinishDocumentLoadForFrame -main frame - didHandleOnloadEventsForFrame -main frame - didFinishLoadForFrame -<unknown> - didFinishLoading -frame "0" - didStartProvisionalLoadForFrame -about:blank - willSendRequest <WebRequest URL "about:blank"> -frame "0" - didCommitLoadForFrame -frame "0" - didFinishDocumentLoadForFrame -frame "0" - didHandleOnloadEventsForFrame -frame "0" - didFinishLoadForFrame -about:blank - didFinishLoading -frame "0" - didStartProvisionalLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-form.html"> -frame "0" - didCancelClientRedirectForFrame -frame "0" - didCommitLoadForFrame -frame "0" - didFinishDocumentLoadForFrame -frame "0" - didHandleOnloadEventsForFrame -frame "0" - didFinishLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - didFinishLoading -frame "0" - didStartProvisionalLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-result.php"> -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-result.php?redirected=true"> -frame "0" - didCommitLoadForFrame -frame "0" - didFinishDocumentLoadForFrame -frame "1" - didStartProvisionalLoadForFrame -about:blank - willSendRequest <WebRequest URL "about:blank"> -frame "1" - didCommitLoadForFrame -frame "1" - didFinishDocumentLoadForFrame -frame "1" - didHandleOnloadEventsForFrame -frame "1" - didFinishLoadForFrame -about:blank - didFinishLoading -frame "0" - didHandleOnloadEventsForFrame -frame "0" - didFinishLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - didFinishLoading -frame "1" - didStartProvisionalLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-form.html"> -frame "1" - didCancelClientRedirectForFrame -frame "1" - didCommitLoadForFrame -frame "1" - didFinishDocumentLoadForFrame -frame "1" - didHandleOnloadEventsForFrame -frame "1" - didFinishLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - didFinishLoading -frame "1" - didStartProvisionalLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-result.php"> -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-result.php?redirected=true"> -frame "1" - didCommitLoadForFrame -frame "1" - didFinishDocumentLoadForFrame -frame "2" - didStartProvisionalLoadForFrame -about:blank - willSendRequest <WebRequest URL "about:blank"> -frame "2" - didCommitLoadForFrame -frame "2" - didFinishDocumentLoadForFrame -frame "2" - didHandleOnloadEventsForFrame -frame "2" - didFinishLoadForFrame -about:blank - didFinishLoading -frame "1" - didHandleOnloadEventsForFrame -frame "1" - didFinishLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - didFinishLoading -frame "2" - didStartProvisionalLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-form.html"> -frame "2" - didCancelClientRedirectForFrame -frame "2" - didCommitLoadForFrame -frame "2" - didFinishDocumentLoadForFrame -frame "2" - didHandleOnloadEventsForFrame -frame "2" - didFinishLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - didFinishLoading -frame "2" - didStartProvisionalLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-result.php"> -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-result.php?redirected=true"> -frame "2" - didCommitLoadForFrame -frame "2" - didFinishDocumentLoadForFrame -frame "3" - didStartProvisionalLoadForFrame -about:blank - willSendRequest <WebRequest URL "about:blank"> -frame "3" - didCommitLoadForFrame -frame "3" - didFinishDocumentLoadForFrame -frame "3" - didHandleOnloadEventsForFrame -frame "3" - didFinishLoadForFrame -about:blank - didFinishLoading -frame "2" - didHandleOnloadEventsForFrame -frame "2" - didFinishLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - didFinishLoading -frame "3" - didStartProvisionalLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-form.html"> -frame "3" - didCancelClientRedirectForFrame -frame "3" - didCommitLoadForFrame -frame "3" - didFinishDocumentLoadForFrame -frame "3" - didHandleOnloadEventsForFrame -frame "3" - didFinishLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-form.html - didFinishLoading -frame "3" - didStartProvisionalLoadForFrame -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-result.php"> -http://127.0.0.1:8000/loading/resources/redirect-methods-result.php - willSendRequest <WebRequest URL "http://127.0.0.1:8000/loading/resources/redirect-methods-result.php?redirected=true"> -frame "3" - didCommitLoadForFrame -frame "3" - didFinishDocumentLoadForFrame -frame "3" - didHandleOnloadEventsForFrame -frame "3" - didFinishLoadForFrame -This test checks to see what HTTP method is used to fetch the final resource in the case where the first request results in a redirect. -301, 302, 303, and 307 http redirects are all tested. diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/misc/favicon-loads-with-images-disabled-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/misc/favicon-loads-with-images-disabled-expected.txt deleted file mode 100644 index f6e4947..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/misc/favicon-loads-with-images-disabled-expected.txt +++ /dev/null @@ -1,5 +0,0 @@ -<unknown> - didFinishLoading -http://127.0.0.1:8000/misc/favicon-loads-with-images-disabled.html - willSendRequest <WebRequest URL "http://127.0.0.1:8000/misc/favicon-loads-with-images-disabled.html"> -Radar 6973106 and https://bugs.webkit.org/show_bug.cgi?id=27896 - Favicons still load when automatic image loading is disabled. -This test uses DRT's resource load delegate callback mode to see if the favicon is loaded even when image loading is off. - diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/misc/window-dot-stop-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/misc/window-dot-stop-expected.txt deleted file mode 100644 index bba1b5d..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/misc/window-dot-stop-expected.txt +++ /dev/null @@ -1,6 +0,0 @@ -http://127.0.0.1:8000/incremental/slow-utf8-text.pl - willSendRequest <WebRequest URL "http://127.0.0.1:8000/incremental/slow-utf8-text.pl"> -http://127.0.0.1:8000/incremental/slow-utf8-text.pl - didFailLoadingWithError <WebError code -3, failing URL "http://127.0.0.1:8000/incremental/slow-utf8-text.pl"> -<unknown> - didFailLoadingWithError <WebError code -3, failing URL "http://127.0.0.1:8000/misc/window-dot-stop.html"> -This tests for the successful use of window.stop() - - diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-expected.txt deleted file mode 100644 index c9fa8e3..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-expected.txt +++ /dev/null @@ -1,10 +0,0 @@ -http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny.cgi - willSendRequest <WebRequest URL "http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny.cgi"> -<unknown> - didFinishLoading -There should be no content in the iframe below - - - --------- -Frame: '<!--framePath //<!--frame0-->-->' --------- - diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-expected.txt deleted file mode 100644 index 491fed8..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-expected.txt +++ /dev/null @@ -1,12 +0,0 @@ -http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe.html - willSendRequest <WebRequest URL "http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe.html"> -<unknown> - didFinishLoading -http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe.html - didFailLoadingWithError <WebError code -3, failing URL "http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe.html"> -about:blank - willSendRequest <WebRequest URL "about:blank"> -There should be no content in the iframe below - - - --------- -Frame: '<!--framePath //<!--frame0-->-->' --------- - diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body-expected.txt deleted file mode 100644 index e73ce5f..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-in-body-expected.txt +++ /dev/null @@ -1,12 +0,0 @@ -http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-in-body.html - willSendRequest <WebRequest URL "http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-in-body.html"> -<unknown> - didFinishLoading -http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-in-body.html - didFailLoadingWithError <WebError code -3, failing URL "http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-in-body.html"> -about:blank - willSendRequest <WebRequest URL "about:blank"> -There should be no content in the iframe below - - - --------- -Frame: '<!--framePath //<!--frame0-->-->' --------- - diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-allow-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-allow-expected.txt deleted file mode 100644 index 56bd4cb..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-allow-expected.txt +++ /dev/null @@ -1,10 +0,0 @@ -http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-allow.html - willSendRequest <WebRequest URL "http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-allow.html"> -<unknown> - didFinishLoading -There should be content in the iframe below - - - --------- -Frame: '<!--framePath //<!--frame0-->-->' --------- -PASS: This should show up as the parent is in the same origin. diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny-expected.txt deleted file mode 100644 index a6c9685..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-deny-meta-tag-parent-same-origin-deny-expected.txt +++ /dev/null @@ -1,12 +0,0 @@ -http://localhost:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-deny.html - willSendRequest <WebRequest URL "http://localhost:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-deny.html"> -<unknown> - didFinishLoading -http://localhost:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-deny.html - didFailLoadingWithError <WebError code -3, failing URL "http://localhost:8000/security/XFrameOptions/resources/x-frame-options-deny-meta-tag-subframe-parent-same-origin-deny.html"> -about:blank - willSendRequest <WebRequest URL "about:blank"> -There should be no content in the iframe below - - - --------- -Frame: '<!--framePath //<!--frame0-->-->' --------- - diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-allow-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-allow-expected.txt deleted file mode 100644 index 43575f4..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-allow-expected.txt +++ /dev/null @@ -1,10 +0,0 @@ -http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-parent-same-origin-allow.cgi - willSendRequest <WebRequest URL "http://127.0.0.1:8000/security/XFrameOptions/resources/x-frame-options-parent-same-origin-allow.cgi"> -<unknown> - didFinishLoading -There should be content in the iframe below - - - --------- -Frame: '<!--framePath //<!--frame0-->-->' --------- -PASS: This should show up as the parent is in the same origin. diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-deny-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-deny-expected.txt deleted file mode 100644 index bccc14c..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/security/XFrameOptions/x-frame-options-parent-same-origin-deny-expected.txt +++ /dev/null @@ -1,10 +0,0 @@ -http://localhost:8000/security/XFrameOptions/resources/x-frame-options-parent-same-origin-allow.cgi - willSendRequest <WebRequest URL "http://localhost:8000/security/XFrameOptions/resources/x-frame-options-parent-same-origin-allow.cgi"> -<unknown> - didFinishLoading -There should be no content in the iframe below - - - --------- -Frame: '<!--framePath //<!--frame0-->-->' --------- - diff --git a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/xmlhttprequest/abort-should-cancel-load-expected.txt b/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/xmlhttprequest/abort-should-cancel-load-expected.txt deleted file mode 100644 index c11e4df..0000000 --- a/webkit/data/layout_tests/platform/chromium-win/LayoutTests/http/tests/xmlhttprequest/abort-should-cancel-load-expected.txt +++ /dev/null @@ -1,3 +0,0 @@ -http://127.0.0.1:8000/xmlhttprequest/resources/endlessxml.php - willSendRequest <WebRequest URL "http://127.0.0.1:8000/xmlhttprequest/resources/endlessxml.php"> -http://127.0.0.1:8000/xmlhttprequest/resources/endlessxml.php - didFailLoadingWithError <WebError code -3, failing URL "http://127.0.0.1:8000/xmlhttprequest/resources/endlessxml.php"> -This tests that calling abort() on an XHR object stops the load, causing the relevant resource load delegates to be sent. diff --git a/webkit/glue/webframeloaderclient_impl.cc b/webkit/glue/webframeloaderclient_impl.cc index 0997a43..2bc9d2c 100644 --- a/webkit/glue/webframeloaderclient_impl.cc +++ b/webkit/glue/webframeloaderclient_impl.cc @@ -222,7 +222,7 @@ static ResourceRequest::TargetType DetermineTargetTypeFromLoader( void WebFrameLoaderClient::dispatchWillSendRequest( DocumentLoader* loader, unsigned long identifier, ResourceRequest& request, - const ResourceResponse& redirectResponse) { + const ResourceResponse& redirect_response) { if (loader) { // We want to distinguish between a request for a document to be loaded into @@ -230,16 +230,6 @@ void WebFrameLoaderClient::dispatchWillSendRequest( request.setTargetType(DetermineTargetTypeFromLoader(loader)); } - // Inherit the first party for cookies from the request's frame. However, if - // the request is for a main frame, the current document's - // firstPartyForCookies is the old document, so we leave firstPartyForCookies - // empty to indicate that the request is a first-party request. - if (request.targetType() != ResourceRequest::TargetIsMainFrame && - webframe_->frame()->document()) { - request.setFirstPartyForCookies( - webframe_->frame()->document()->firstPartyForCookies()); - } - // FrameLoader::loadEmptyDocumentSynchronously() creates an empty document // with no URL. We don't like that, so we'll rename it to about:blank. if (request.url().isEmpty()) @@ -251,7 +241,8 @@ void WebFrameLoaderClient::dispatchWillSendRequest( WebViewDelegate* d = webframe_->GetWebViewImpl()->delegate(); if (d) { WrappedResourceRequest webreq(request); - d->WillSendRequest(webframe_, identifier, &webreq); + WrappedResourceResponse webresp(redirect_response); + d->WillSendRequest(webframe_, identifier, &webreq, webresp); } } @@ -452,6 +443,10 @@ void WebFrameLoaderClient::dispatchDidReceiveServerRedirectForProvisionalLoad() return; } + // The server redirect may have been blocked. + if (ds->request().isNull()) + return; + // A provisional load should have started already, which should have put an // entry in our redirect chain. DCHECK(ds->HasRedirectChain()); diff --git a/webkit/glue/weburlloader_impl.cc b/webkit/glue/weburlloader_impl.cc index 3041049..706e957 100644 --- a/webkit/glue/weburlloader_impl.cc +++ b/webkit/glue/weburlloader_impl.cc @@ -221,7 +221,7 @@ class WebURLLoaderImpl::Context : public base::RefCounted<Context>, void HandleDataURL(); WebURLLoaderImpl* loader_; - GURL url_; + WebURLRequest request_; WebURLLoaderClient* client_; scoped_ptr<ResourceLoaderBridge> bridge_; scoped_ptr<MultipartResponseDelegate> multipart_delegate_; @@ -258,11 +258,13 @@ void WebURLLoaderImpl::Context::Start( ResourceLoaderBridge::SyncLoadResponse* sync_load_response) { DCHECK(!bridge_.get()); - url_ = request.url(); - if (url_.SchemeIs("data")) { + request_ = request; // Save the request. + + GURL url = request.url(); + if (url.SchemeIs("data")) { if (sync_load_response) { // This is a sync load. Do the work now. - sync_load_response->url = url_; + sync_load_response->url = url; std::string data; GetInfoFromDataURL(sync_load_response->url, sync_load_response, &sync_load_response->data, @@ -316,7 +318,7 @@ void WebURLLoaderImpl::Context::Start( // creating the GURLs. bridge_.reset(ResourceLoaderBridge::Create( method, - url_, + url, request.firstPartyForCookies(), referrer_url, frame_origin, @@ -380,18 +382,20 @@ bool WebURLLoaderImpl::Context::OnReceivedRedirect( WebURLResponse response; response.initialize(); - PopulateURLResponse(url_, info, &response); + PopulateURLResponse(request_.url(), info, &response); // TODO(darin): We lack sufficient information to construct the actual - // request that resulted from the redirect, so we just report a GET - // navigation to the new location. + // request that resulted from the redirect. WebURLRequest new_request(new_url); + new_request.setFirstPartyForCookies(request_.firstPartyForCookies()); + if (response.httpStatusCode() == 307) + new_request.setHTTPMethod(request_.httpMethod()); - url_ = new_url; + request_ = new_request; client_->willSendRequest(loader_, new_request, response); // Only follow the redirect if WebKit left the URL unmodified. - if (url_ == new_request.url()) + if (new_url == GURL(new_request.url())) return true; // We assume that WebKit only changes the URL to suppress a redirect, and we @@ -408,7 +412,7 @@ void WebURLLoaderImpl::Context::OnReceivedResponse( WebURLResponse response; response.initialize(); - PopulateURLResponse(url_, info, &response); + PopulateURLResponse(request_.url(), info, &response); response.setIsContentFiltered(content_filtered); expected_content_length_ = response.expectedContentLength(); @@ -474,7 +478,7 @@ void WebURLLoaderImpl::Context::OnCompletedRequest( WebURLError error; error.domain = WebString::fromUTF8(net::kErrorDomain); error.reason = error_code; - error.unreachableURL = url_; + error.unreachableURL = request_.url(); client_->didFail(loader_, error); } else { client_->didFinishLoading(loader_); @@ -488,7 +492,7 @@ void WebURLLoaderImpl::Context::OnCompletedRequest( } std::string WebURLLoaderImpl::Context::GetURLForDebugging() { - return url_.spec(); + return request_.url().spec(); } void WebURLLoaderImpl::Context::HandleDataURL() { @@ -496,7 +500,7 @@ void WebURLLoaderImpl::Context::HandleDataURL() { URLRequestStatus status; std::string data; - if (GetInfoFromDataURL(url_, &info, &data, &status)) { + if (GetInfoFromDataURL(request_.url(), &info, &data, &status)) { OnReceivedResponse(info, false); if (!data.empty()) OnReceivedData(data.data(), data.size()); diff --git a/webkit/glue/webview_delegate.h b/webkit/glue/webview_delegate.h index 0b4b7fe..593bfea 100644 --- a/webkit/glue/webview_delegate.h +++ b/webkit/glue/webview_delegate.h @@ -497,10 +497,13 @@ class WebViewDelegate : virtual public WebKit::WebWidgetClient { // Notifies the delegate that a request is about to be sent out, giving the // delegate the opportunity to modify the request. Note that request is // writable here, and changes to the URL, for example, will change the request - // to be made. - virtual void WillSendRequest(WebFrame* webframe, - uint32 identifier, - WebKit::WebURLRequest* request) { + // made. If this request is the result of a redirect, then redirect_response + // will be non-null and contain the response that triggered the redirect. + virtual void WillSendRequest( + WebFrame* webframe, + uint32 identifier, + WebKit::WebURLRequest* request, + const WebKit::WebURLResponse& redirect_response) { } virtual void DidReceiveResponse(WebFrame* webframe, diff --git a/webkit/tools/layout_tests/test_expectations.txt b/webkit/tools/layout_tests/test_expectations.txt index 75fb9b0..0be1c8c 100644 --- a/webkit/tools/layout_tests/test_expectations.txt +++ b/webkit/tools/layout_tests/test_expectations.txt @@ -3030,7 +3030,6 @@ BUG17942 LINUX : LayoutTests/transforms/2d/compound-2d-transforms.html = CRASH P BUG17942 LINUX : LayoutTests/fast/overflow/008.html = CRASH PASS BUG17942 WIN : LayoutTests/svg/dom/SVGScriptElement/script-load-and-error-events.svg = FAIL PASS // New tests with this merge: -BUG17942 : LayoutTests/http/tests/misc/will-send-request-returns-null-on-redirect.html = FAIL BUG18116 : LayoutTests/fast/dom/constructed-objects-prototypes.html = FAIL BUG18116 : LayoutTests/fast/dom/prototype-inheritance-2.html = FAIL diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc index ba0382e..f3754ce 100644 --- a/webkit/tools/test_shell/layout_test_controller.cc +++ b/webkit/tools/test_shell/layout_test_controller.cc @@ -117,6 +117,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) { BindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled); BindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDelegate); BindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelegate); + BindMethod("setWillSendRequestReturnsNullOnRedirect", &LayoutTestController::setWillSendRequestReturnsNullOnRedirect); // The following are stubs. BindMethod("dumpAsWebArchive", &LayoutTestController::dumpAsWebArchive); @@ -587,6 +588,14 @@ void LayoutTestController::waitForPolicyDelegate( result->SetNull(); } +void LayoutTestController::setWillSendRequestReturnsNullOnRedirect( + const CppArgumentList& args, CppVariant* result) { + if (args.size() > 0 && args[0].isBool()) + shell_->delegate()->set_block_redirects(args[0].value.boolValue); + + result->SetNull(); +} + void LayoutTestController::pathToLocalResource( const CppArgumentList& args, CppVariant* result) { result->SetNull(); diff --git a/webkit/tools/test_shell/layout_test_controller.h b/webkit/tools/test_shell/layout_test_controller.h index d35356a..151e6fe 100644 --- a/webkit/tools/test_shell/layout_test_controller.h +++ b/webkit/tools/test_shell/layout_test_controller.h @@ -113,6 +113,10 @@ class LayoutTestController : public CppBoundClass { // Delays completion of the test until the policy delegate runs. void waitForPolicyDelegate(const CppArgumentList& args, CppVariant* result); + // Causes WillSendRequest to block redirects. + void setWillSendRequestReturnsNullOnRedirect(const CppArgumentList& args, + CppVariant* result); + // Converts a URL starting with file:///tmp/ to the local mapping. void pathToLocalResource(const CppArgumentList& args, CppVariant* result); diff --git a/webkit/tools/test_shell/test_webview_delegate.cc b/webkit/tools/test_shell/test_webview_delegate.cc index ebd25db..d01c39e 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -28,6 +28,7 @@ #include "webkit/api/public/WebURL.h" #include "webkit/api/public/WebURLError.h" #include "webkit/api/public/WebURLRequest.h" +#include "webkit/api/public/WebURLResponse.h" #include "webkit/glue/glue_serialize.h" #include "webkit/glue/media/buffered_data_source.h" #include "webkit/glue/media/media_resource_loader_bridge_factory.h" @@ -65,6 +66,7 @@ using WebKit::WebString; using WebKit::WebURL; using WebKit::WebURLError; using WebKit::WebURLRequest; +using WebKit::WebURLResponse; using WebKit::WebWidget; using WebKit::WebWorker; using WebKit::WebWorkerClient; @@ -119,6 +121,26 @@ const char* WebNavigationTypeToString(WebNavigationType type) { return kIllegalString; } +std::string GetResponseDescription(const WebURLResponse& response) { + if (response.isNull()) + return "(null)"; + + return StringPrintf("<NSURLResponse %s, http status code %d>", + GURL(response.url()).possibly_invalid_spec().c_str(), + response.httpStatusCode()); +} + +int ToNSErrorCode(const WebURLError& error) { + if (UTF16ToUTF8(error.domain) == net::kErrorDomain) { + switch (error.reason) { + case net::ERR_ABORTED: + return -999; + } + } + DLOG(WARNING) << "Add an error code mapping!"; + return error.reason; +} + } // namespace // WebViewDelegate ----------------------------------------------------------- @@ -229,19 +251,34 @@ std::string TestWebViewDelegate::GetResourceDescription(uint32 identifier) { return it != resource_identifier_map_.end() ? it->second : "<unknown>"; } -void TestWebViewDelegate::WillSendRequest(WebFrame* webframe, - uint32 identifier, - WebURLRequest* request) { +void TestWebViewDelegate::WillSendRequest( + WebFrame* webframe, + uint32 identifier, + WebURLRequest* request, + const WebURLResponse& redirect_response) { GURL url = request->url(); std::string request_url = url.possibly_invalid_spec(); - std::string host = url.host(); if (shell_->ShouldDumpResourceLoadCallbacks()) { - printf("%s - willSendRequest <WebRequest URL \"%s\">\n", + GURL main_document_url = request->firstPartyForCookies(); + printf("%s - willSendRequest <NSURLRequest URL %s, main document URL %s," + " http method %s> redirectResponse %s\n", GetResourceDescription(identifier).c_str(), - request_url.c_str()); + request_url.c_str(), + main_document_url.possibly_invalid_spec().c_str(), + UTF16ToUTF8(request->httpMethod()).c_str(), + GetResponseDescription(redirect_response).c_str()); + } + + if (!redirect_response.isNull() && block_redirects_) { + printf("Returning null for this redirect\n"); + + // To block the request, we set its URL to an empty one. + request->setURL(WebURL()); + return; } + std::string host = url.host(); if (TestShell::layout_test_mode() && !host.empty() && (url.SchemeIs("http") || url.SchemeIs("https")) && host != "127.0.0.1" && @@ -260,6 +297,17 @@ void TestWebViewDelegate::WillSendRequest(WebFrame* webframe, request->setURL(GURL(TestShell::RewriteLocalUrl(request_url))); } +void TestWebViewDelegate::DidReceiveResponse( + WebFrame* webframe, + uint32 identifier, + const WebURLResponse& response) { + if (shell_->ShouldDumpResourceLoadCallbacks()) { + printf("%s - didReceiveResponse %s\n", + GetResourceDescription(identifier).c_str(), + GetResponseDescription(response).c_str()); + } +} + void TestWebViewDelegate::DidFinishLoading(WebFrame* webframe, uint32 identifier) { TRACE_EVENT_END("url.load", identifier, ""); @@ -275,10 +323,10 @@ void TestWebViewDelegate::DidFailLoadingWithError(WebFrame* webframe, uint32 identifier, const WebURLError& error) { if (shell_->ShouldDumpResourceLoadCallbacks()) { - printf("%s - didFailLoadingWithError <WebError code %d," - " failing URL \"%s\">\n", + printf("%s - didFailLoadingWithError: <NSError domain NSURLErrorDomain," + " code %d, failing URL \"%s\">\n", GetResourceDescription(identifier).c_str(), - error.reason, + ToNSErrorCode(error), error.unreachableURL.spec().data()); } @@ -311,7 +359,7 @@ void TestWebViewDelegate::DidStartProvisionalLoadForFrame( UpdateAddressBar(webview); } -void TestWebViewDelegate::DidReceiveServerRedirectForProvisionalLoadForFrame( +void TestWebViewDelegate::DidReceiveProvisionalLoadServerRedirect( WebView* webview, WebFrame* frame) { if (shell_->ShouldDumpFrameLoadCallbacks()) { @@ -453,13 +501,14 @@ void TestWebViewDelegate::DidReceiveIconForFrame(WebView* webview, void TestWebViewDelegate::WillPerformClientRedirect(WebView* webview, WebFrame* frame, - const std::wstring& dest_url, + const GURL& src_url, + const GURL& dest_url, unsigned int delay_seconds, unsigned int fire_date) { if (shell_->ShouldDumpFrameLoadCallbacks()) { - // FIXME: prettyprint the url? - printf("%S - willPerformClientRedirectToURL: %S\n", - GetFrameDescription(frame).c_str(), dest_url.c_str()); + printf("%S - willPerformClientRedirectToURL: %s \n", + GetFrameDescription(frame).c_str(), + dest_url.possibly_invalid_spec().c_str()); } } diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index dfaac4e..183bc4f 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -68,16 +68,16 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, top_loading_frame_(NULL), page_id_(-1), last_page_id_updated_(-1), - smart_insert_delete_enabled_(true) +#if defined(OS_LINUX) + cursor_type_(GDK_X_CURSOR), +#endif + smart_insert_delete_enabled_(true), #if defined(OS_WIN) - , select_trailing_whitespace_enabled_(true) + select_trailing_whitespace_enabled_(true), #else - , select_trailing_whitespace_enabled_(false) + select_trailing_whitespace_enabled_(false), #endif -#if defined(OS_LINUX) - , cursor_type_(GDK_X_CURSOR) -#endif - { + block_redirects_(false) { } virtual ~TestWebViewDelegate(); @@ -149,7 +149,7 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, WebView* webview, WebFrame* frame, NavigationGesture gesture); - virtual void DidReceiveServerRedirectForProvisionalLoadForFrame( + virtual void DidReceiveProvisionalLoadServerRedirect( WebView* webview, WebFrame* frame); virtual void DidFailProvisionalLoadWithError( WebView* webview, @@ -171,7 +171,8 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, virtual void WillPerformClientRedirect(WebView* webview, WebFrame* frame, - const std::wstring& dest_url, + const GURL& src_url, + const GURL& dest_url, unsigned int delay_seconds, unsigned int fire_date); virtual void DidCancelClientRedirect(WebView* webview, @@ -187,7 +188,11 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, const WebKit::WebURLRequest& request); virtual void WillSendRequest(WebFrame* webframe, uint32 identifier, - WebKit::WebURLRequest* request); + WebKit::WebURLRequest* request, + const WebKit::WebURLResponse& redirect_response); + virtual void DidReceiveResponse(WebFrame* webframe, + uint32 identifier, + const WebKit::WebURLResponse& response); virtual void DidFinishLoading(WebFrame* webframe, uint32 identifier); virtual void DidFailLoadingWithError(WebFrame* webframe, uint32 identifier, @@ -280,6 +285,13 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, void SetCustomPolicyDelegate(bool is_custom, bool is_permissive); void WaitForPolicyDelegate(); + void set_block_redirects(bool block_redirects) { + block_redirects_ = block_redirects; + } + bool block_redirects() const { + return block_redirects_; + } + protected: // Called the title of the page changes. // Can be used to update the title of the window. @@ -343,12 +355,6 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, ResourceMap resource_identifier_map_; std::string GetResourceDescription(uint32 identifier); - // true if we want to enable smart insert/delete. - bool smart_insert_delete_enabled_; - - // true if we want to enable selection of trailing whitespaces - bool select_trailing_whitespace_enabled_; - CapturedContextMenuEvents captured_context_menu_events_; WebCursor current_cursor_; @@ -371,6 +377,15 @@ class TestWebViewDelegate : public base::RefCounted<TestWebViewDelegate>, WebKit::WebRect popup_bounds_; #endif + // true if we want to enable smart insert/delete. + bool smart_insert_delete_enabled_; + + // true if we want to enable selection of trailing whitespaces + bool select_trailing_whitespace_enabled_; + + // true if we should block any redirects + bool block_redirects_; + DISALLOW_COPY_AND_ASSIGN(TestWebViewDelegate); }; |