summaryrefslogtreecommitdiffstats
path: root/chrome_frame/test
diff options
context:
space:
mode:
authorananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 23:43:50 +0000
committerananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98>2010-05-05 23:43:50 +0000
commit079786397d052c14a2b1886dfb494c4bd4a9335c (patch)
tree14069b5cf462e23f2406a5cbb48fd2a36985d5da /chrome_frame/test
parent027f4d4575f330822d17f09b25eebe31ace131c5 (diff)
downloadchromium_src-079786397d052c14a2b1886dfb494c4bd4a9335c.zip
chromium_src-079786397d052c14a2b1886dfb494c4bd4a9335c.tar.gz
chromium_src-079786397d052c14a2b1886dfb494c4bd4a9335c.tar.bz2
Cookies would not get set correctly in ChromeFrame in full tab mode. The code to set cookies in IE incorrectly parses the cookies into name
value pairs. In this scenario we end up with an empty name string which causes cookies to not get set correctly. It appears that an empty name string is not treated on the same lines as NULL. In any case we should not be doing any parsing and should just set the cookie as is. This fixes bug http://code.google.com/p/chromium/issues/detail?id=42818. Added a unit test to validate this case. Bug=42818 Review URL: http://codereview.chromium.org/1917005 git-svn-id: svn://svn.chromium.org/chrome/trunk/src@46523 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test')
-rw-r--r--chrome_frame/test/data/fulltab_set_cookie_test.html67
-rw-r--r--chrome_frame/test/data/fulltab_set_cookie_test.html.mock-http-headers3
-rw-r--r--chrome_frame/test/test_with_web_server.cc13
3 files changed, 83 insertions, 0 deletions
diff --git a/chrome_frame/test/data/fulltab_set_cookie_test.html b/chrome_frame/test/data/fulltab_set_cookie_test.html
new file mode 100644
index 0000000..aa4bf40
--- /dev/null
+++ b/chrome_frame/test/data/fulltab_set_cookie_test.html
@@ -0,0 +1,67 @@
+<html>
+ <head>
+ <meta http-equiv="x-ua-compatible" content="chrome=1" />
+ <title>FullTab mode set cookie test</title>
+ </head>
+
+ <script type="text/javascript"
+ src="chrome_frame_tester_helpers.js"></script>
+
+ <script type="text/javascript">
+ function onLoad() {
+ if (!isRunningInChrome()) {
+ onFailure("FullTab_SetCookieTest", 1, "Not running in Chrome");
+ return;
+ }
+
+ // The path of the cookie in this test is set to "/." so it should be
+ // available for all files on the domain but should be set only once.
+ // First validate that the document cookie contains the substring
+ // "CF_FullTabDummyCookie=1".
+ // 1. Then create a cookie CF_FullTabSetCookie1=1 and verify it it got
+ // set correctly..
+ // 2. Now create a second cookie CF_FullTabSetCookie2=1 and not validate
+ // whether both cookies can be found.
+ var original_cookies = document.cookie;
+ var cookie_found = /CF_FullTabDummyCookie=1/.test(document.cookie);
+ if (cookie_found) {
+ createCookie("CF_FullTabSetCookie1", 1, 1);
+ cookie_found = /CF_FullTabSetCookie1=1/.test(document.cookie);
+ if (!cookie_found) {
+ onFailure("FullTab_SetCookieTest", 1, "Failed to set first cookie");
+ } else {
+ createCookie("CF_FullTabSetCookie2", 1, 1);
+ cookie_found = /CF_FullTabSetCookie2=1/.test(document.cookie);
+ if (!cookie_found) {
+ onFailure("FullTab_SetCookieTest", 1,
+ "Failed to find second cookie");
+ } else {
+ cookie_found = /CF_FullTabSetCookie1=1/.test(document.cookie);
+ if (!cookie_found) {
+ onFailure("FullTab_SetCookieTest", 1,
+ "Failed to find first cookie");
+ }
+ }
+ }
+ } else {
+ onFailure("FullTab_SetCookieTest", 1, "Expected cookies not set");
+ }
+
+ eraseCookie("CF_FullTabDummyCookie");
+ eraseCookie("CF_FullTabSetCookie1");
+ eraseCookie("CF_FullTabSetCookie2");
+
+ if (!readCookie("CF_FullTabDummyCookie") &&
+ !readCookie("CF_FullTabSetCookie1") &&
+ !readCookie("CF_FullTabSetCookie2")) {
+ onSuccess("FullTab_SetCookieTest", 1);
+ } else {
+ onFailure("FullTab_SetCookieTest", 1, "Failed to delete cookies");
+ }
+ }
+ </script>
+
+ <body onload="onLoad();">
+ This tests whether cookies get set correctly in full tab mode
+ </body>
+</html>
diff --git a/chrome_frame/test/data/fulltab_set_cookie_test.html.mock-http-headers b/chrome_frame/test/data/fulltab_set_cookie_test.html.mock-http-headers
new file mode 100644
index 0000000..871fa9f
--- /dev/null
+++ b/chrome_frame/test/data/fulltab_set_cookie_test.html.mock-http-headers
@@ -0,0 +1,3 @@
+HTTP/1.0 200 OK
+Content-type: text/html
+Set-Cookie: CF_FullTabDummyCookie=1;path=/
diff --git a/chrome_frame/test/test_with_web_server.cc b/chrome_frame/test/test_with_web_server.cc
index 2d98161..815ad86 100644
--- a/chrome_frame/test/test_with_web_server.cc
+++ b/chrome_frame/test/test_with_web_server.cc
@@ -887,3 +887,16 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_TestMultipleGet) {
}
}
+const wchar_t kSetCookieTest[] =
+ L"files/fulltab_set_cookie_test.html";
+
+TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_SetCookieTest) {
+ chrome_frame_test::TimedMsgLoop loop;
+ ASSERT_TRUE(LaunchBrowser(IE, kSetCookieTest));
+
+ loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds);
+
+ chrome_frame_test::CloseAllIEWindows();
+ ASSERT_TRUE(CheckResultFile(L"FullTab_SetCookieTest", "OK"));
+}
+