diff options
author | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-06 05:34:22 +0000 |
---|---|---|
committer | darin@chromium.org <darin@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2009-08-06 05:34:22 +0000 |
commit | a1353855e56d0154af127b9cb6df95287a4d5be5 (patch) | |
tree | 47cef5603a8aef575b50a141a2ae1761ec73dcfc /webkit/tools/test_shell | |
parent | 1ae2665cfca4f42e4e2b364d39739c04e77d0499 (diff) | |
download | chromium_src-a1353855e56d0154af127b9cb6df95287a4d5be5.zip chromium_src-a1353855e56d0154af127b9cb6df95287a4d5be5.tar.gz chromium_src-a1353855e56d0154af127b9cb6df95287a4d5be5.tar.bz2 |
Fix a bunch of layout tests related to dumpResourceLoadCallbacks.
There are several changes included:
1- Fixed up some of the signatures of virtual methods on TestWebViewDelegate so that they actually get called.
2- Fudged the output of some of the events so that they match the WebKit Mac results. This means outputing NSError instead of WebError, etc.
3- Modified WebURLLoaderImpl to send a more meaningful redirect request. This allows some tests to observe that we are for example going to be issuing a POST request in response to a 307 redirect of a POST request.
4- Modified WebViewDelegate::WillSendRequest to take a redirect_response parameter so that the TestWebViewDelegate can log information about that.
5- Deleted a number of custom baselines that are now unnecessary! :-)
6- Removed some code from WebFrameLoaderClientImpl::dispatchWillSendRequest that was causing our setting for firstPartyForCookies to differ from Safari.
This CL depends on WebKit r46820.
R=dglazkov,abarth
BUG=none
TEST=none
Review URL: http://codereview.chromium.org/164033
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@22590 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'webkit/tools/test_shell')
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.cc | 9 | ||||
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.h | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 77 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 47 |
4 files changed, 107 insertions, 30 deletions
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); }; |