diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 01:13:10 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-06-16 01:13:10 +0000 |
commit | 9db82ed38efa994b881f9f4f84d374f9381abb54 (patch) | |
tree | 68327bb6cdffd39479446199335502dfc77fce61 /chrome_frame | |
parent | dce31544272dddb42a8aee2f95201c871ccddf15 (diff) | |
download | chromium_src-9db82ed38efa994b881f9f4f84d374f9381abb54.zip chromium_src-9db82ed38efa994b881f9f4f84d374f9381abb54.tar.gz chromium_src-9db82ed38efa994b881f9f4f84d374f9381abb54.tar.bz2 |
ChromeFrame should allow conditional HTTP headers like if_match, if_modified_since, etc to pass through the host network
stack. Filtering out these issues causes POST requests issued by buzz to fail.
Fixes bug http://b/issue?id=2321282
Bug=2321282
Test=Covered by ChromeFrame unit test.
Review URL: http://codereview.chromium.org/2846005
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@49880 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame')
4 files changed, 93 insertions, 2 deletions
diff --git a/chrome_frame/test/data/chrome_frame_tester_helpers.js b/chrome_frame/test/data/chrome_frame_tester_helpers.js index a6cc9c2..d0394ef 100644 --- a/chrome_frame/test/data/chrome_frame_tester_helpers.js +++ b/chrome_frame/test/data/chrome_frame_tester_helpers.js @@ -160,3 +160,18 @@ function TestIfRunningInChrome() { } return is_chrome; } + +// Returns the base document url. +function GetBaseUrlPath() { + var url = window.location.protocol + "//" + window.location.host + "/"; + return url; +} + +// Appends arguments passed in to the base document url and returns the same. +function AppendArgumentsToBaseUrl() { + var url = GetBaseUrlPath(); + for (arg_index = 0; arg_index < arguments.length; arg_index++) { + url += arguments[arg_index]; + } + return url; +} diff --git a/chrome_frame/test/data/xmlhttprequest_authorization_header_test.html b/chrome_frame/test/data/xmlhttprequest_authorization_header_test.html index 3c23ddf..9d084bf 100644 --- a/chrome_frame/test/data/xmlhttprequest_authorization_header_test.html +++ b/chrome_frame/test/data/xmlhttprequest_authorization_header_test.html @@ -1,7 +1,7 @@ <html> <head> <meta http-equiv="x-ua-compatible" content="chrome=1" /> - <title>ChromeFrame keyevent test</title> + <title>ChromeFrame XHR Authorization header test</title> <script type="text/javascript" src="chrome_frame_tester_helpers.js"></script> @@ -22,7 +22,10 @@ onFailure(test_name, 1, "Failed to get XHR object"); } - xhr.open("GET", "http://localhost:1337/echoheader?Authorization", false); + var request_uri = AppendArgumentsToBaseUrl("echoheader?", + "Authorization"); + + xhr.open("GET", request_uri, false); xhr.setRequestHeader('Authorization', 'Basic'); try { diff --git a/chrome_frame/test/data/xmlhttprequest_conditional_header_test.html b/chrome_frame/test/data/xmlhttprequest_conditional_header_test.html new file mode 100644 index 0000000..f05fca7 --- /dev/null +++ b/chrome_frame/test/data/xmlhttprequest_conditional_header_test.html @@ -0,0 +1,58 @@ +<html> + <head> + <meta http-equiv="x-ua-compatible" content="chrome=1" /> + <title>ChromeFrame conditional header test</title> + <script type="text/javascript" + src="chrome_frame_tester_helpers.js"></script> + + <script type="text/javascript"> + function ValidateUserAgent() { + if (isRunningInMSIE()) { + onFailure("FullTab_XMLHttpRequestConditionalHeaderTest", 1, + "Failed"); + } + + SendXHRRequest("if_match", "*"); + SendXHRRequest("if_modified_since", "*"); + SendXHRRequest("if-none-match", "*"); + SendXHRRequest("if-range", "*"); + SendXHRRequest("if-unmodified-since", "*"); + onSuccess("FullTab_XMLHttpRequestConditionalHeaderTest", 1); + } + + function SendXHRRequest(conditional_header, value) { + var test_name = "FullTab_XMLHttpRequestConditionalHeaderTest"; + var xhr = getXHRObject(); + if (!xhr) { + onFailure(test_name, 1, "Failed to get XHR object"); + } + + var request_uri = AppendArgumentsToBaseUrl("echoheader?", + conditional_header); + xhr.open("GET", request_uri, false); + xhr.setRequestHeader(conditional_header, value); + + try { + xhr.send(null); + var pos = xhr.responseText.indexOf(value); + if (pos >= 0) { + appendStatus("Received header: " + xhr.responseText); + } else { + onFailure( + test_name, 1, + "Failed to find header " + conditional_header + " in response."); + } + } catch (e) { + appendStatus("XHR send failed. Error: " + e.description); + onFailure(test_name, 1, "Failed to send XHR request"); + } + } + </script> + </head> + + <body onload="setTimeout(ValidateUserAgent, 100);"> + ChromeFrame full tab mode XMLHttpRequest conditional header test. + Verifies that conditional headers set by XML HTTP requests make it past + the host network stack. + </body> +</html> diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc index 003c179..b7a5a22 100644 --- a/chrome_frame/test/test_with_web_server.cc +++ b/chrome_frame/test/test_with_web_server.cc @@ -901,3 +901,18 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SetCookieTest) { chrome_frame_test::CloseAllIEWindows(); ASSERT_TRUE(CheckResultFile(L"FullTab_SetCookieTest", "OK")); } + +const wchar_t kXHRConditionalHeaderTestUrl[] = + L"files/xmlhttprequest_conditional_header_test.html"; + +TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_XHRConditionalHeaderTest) { + chrome_frame_test::TimedMsgLoop loop; + ASSERT_TRUE(LaunchBrowser(IE, kXHRConditionalHeaderTestUrl)); + + loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + + chrome_frame_test::CloseAllIEWindows(); + ASSERT_TRUE(CheckResultFile(L"FullTab_XMLHttpRequestConditionalHeaderTest", + "OK")); +} + |