diff options
author | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 17:47:10 +0000 |
---|---|---|
committer | jochen@chromium.org <jochen@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-11 17:47:10 +0000 |
commit | 99c773d9f8244e0d339bbc07accf2e866b5051cc (patch) | |
tree | bb0998432bc4b3537ac066110c615be13d57d749 | |
parent | a4b7bef339f61cb9da5e7985a27b65fab03b1ec3 (diff) | |
download | chromium_src-99c773d9f8244e0d339bbc07accf2e866b5051cc.zip chromium_src-99c773d9f8244e0d339bbc07accf2e866b5051cc.tar.gz chromium_src-99c773d9f8244e0d339bbc07accf2e866b5051cc.tar.bz2 |
Add setWillSendRequestClearHeader to LayoutTestController.
See https://bugs.webkit.org/show_bug.cgi?id=35920 for the webkit side.
TEST=http/tests/security/no-referrer.html
BUG=none
Review URL: http://codereview.chromium.org/884001
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@41286 0039d316-1c4b-4281-b951-d872f2087c98
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.cc | 13 | ||||
-rw-r--r-- | webkit/tools/test_shell/layout_test_controller.h | 6 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.cc | 4 | ||||
-rw-r--r-- | webkit/tools/test_shell/test_webview_delegate.h | 13 |
4 files changed, 33 insertions, 3 deletions
diff --git a/webkit/tools/test_shell/layout_test_controller.cc b/webkit/tools/test_shell/layout_test_controller.cc index 3a5de05..9b355ed 100644 --- a/webkit/tools/test_shell/layout_test_controller.cc +++ b/webkit/tools/test_shell/layout_test_controller.cc @@ -1,4 +1,4 @@ -// Copyright (c) 2009 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -121,6 +121,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) : BindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled); BindMethod("setCustomPolicyDelegate", &LayoutTestController::setCustomPolicyDelegate); BindMethod("waitForPolicyDelegate", &LayoutTestController::waitForPolicyDelegate); + BindMethod("setWillSendRequestClearHeader", &LayoutTestController::setWillSendRequestClearHeader); BindMethod("setWillSendRequestReturnsNullOnRedirect", &LayoutTestController::setWillSendRequestReturnsNullOnRedirect); BindMethod("setWillSendRequestReturnsNull", &LayoutTestController::setWillSendRequestReturnsNull); BindMethod("whiteListAccessFromOrigin", &LayoutTestController::whiteListAccessFromOrigin); @@ -655,6 +656,16 @@ void LayoutTestController::waitForPolicyDelegate( result->SetNull(); } +void LayoutTestController::setWillSendRequestClearHeader( + const CppArgumentList& args, CppVariant* result) { + if (args.size() > 0 && args[0].isString()) { + std::string header = args[0].ToString(); + if (!header.empty()) + shell_->delegate()->set_clear_header(header); + } + result->SetNull(); +} + void LayoutTestController::setWillSendRequestReturnsNullOnRedirect( const CppArgumentList& args, CppVariant* result) { if (args.size() > 0 && args[0].isBool()) diff --git a/webkit/tools/test_shell/layout_test_controller.h b/webkit/tools/test_shell/layout_test_controller.h index 6bf09bd..373db0a 100644 --- a/webkit/tools/test_shell/layout_test_controller.h +++ b/webkit/tools/test_shell/layout_test_controller.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -124,6 +124,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 clear certain headers. + void setWillSendRequestClearHeader(const CppArgumentList& args, + CppVariant* result); + // Causes WillSendRequest to block redirects. void setWillSendRequestReturnsNullOnRedirect(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 afe6cd5..17c976b 100644 --- a/webkit/tools/test_shell/test_webview_delegate.cc +++ b/webkit/tools/test_shell/test_webview_delegate.cc @@ -941,6 +941,10 @@ void TestWebViewDelegate::willSendRequest( return; } + for (std::set<std::string>::const_iterator header = clear_headers_.begin(); + header != clear_headers_.end(); ++header) + request.clearHTTPHeaderField(WebString::fromUTF8(*header)); + TRACE_EVENT_BEGIN("url.load", identifier, request_url); // Set the new substituted URL. request.setURL(GURL(TestShell::RewriteLocalUrl(request_url))); diff --git a/webkit/tools/test_shell/test_webview_delegate.h b/webkit/tools/test_shell/test_webview_delegate.h index 4bd36f5..8b12590 100644 --- a/webkit/tools/test_shell/test_webview_delegate.h +++ b/webkit/tools/test_shell/test_webview_delegate.h @@ -1,4 +1,4 @@ -// Copyright (c) 2006-2008 The Chromium Authors. All rights reserved. +// Copyright (c) 2010 The Chromium Authors. All rights reserved. // Use of this source code is governed by a BSD-style license that can be // found in the LICENSE file. @@ -16,6 +16,7 @@ #endif #include <map> +#include <set> #include <string> #if defined(TOOLKIT_USES_GTK) @@ -264,6 +265,13 @@ class TestWebViewDelegate : public WebKit::WebViewClient, void SetCustomPolicyDelegate(bool is_custom, bool is_permissive); void WaitForPolicyDelegate(); + void set_clear_header(const std::string& header) { + clear_headers_.insert(header); + } + const std::set<std::string>& clear_headers() { + return clear_headers_; + } + void set_block_redirects(bool block_redirects) { block_redirects_ = block_redirects; } @@ -392,6 +400,9 @@ class TestWebViewDelegate : public WebKit::WebViewClient, // true if we want to enable selection of trailing whitespaces bool select_trailing_whitespace_enabled_; + // Set of headers to clear in willSendRequest. + std::set<std::string> clear_headers_; + // true if we should block any redirects bool block_redirects_; |