diff options
Diffstat (limited to 'chrome_frame/test')
4 files changed, 92 insertions, 3 deletions
diff --git a/chrome_frame/test/chrome_frame_unittests.cc b/chrome_frame/test/chrome_frame_unittests.cc index bfd863b..9497162 100644 --- a/chrome_frame/test/chrome_frame_unittests.cc +++ b/chrome_frame/test/chrome_frame_unittests.cc @@ -1745,9 +1745,8 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_ChromeFrameXHRAuthHeaderTest) { chrome_frame_test::TimedMsgLoop loop; - ASSERT_TRUE( - LaunchBrowser(IE, - kChromeFrameFullTabModeXMLHttpRequestAuthHeaderTestUrl)); + ASSERT_TRUE(LaunchBrowser( + IE, kChromeFrameFullTabModeXMLHttpRequestAuthHeaderTestUrl)); loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); @@ -1755,3 +1754,19 @@ TEST_F(ChromeFrameTestWithWebServer, ASSERT_TRUE( CheckResultFile(L"FullTab_XMLHttpRequestAuthorizationHeaderTest", "OK")); } + +const wchar_t kChromeFrameFullTabModeDeleteCookieTest[] = + L"files/fulltab_delete_cookie_test.html"; + +TEST_F(ChromeFrameTestWithWebServer, + FullTabModeIE_ChromeFrameDeleteCookieTest) { + chrome_frame_test::TimedMsgLoop loop; + + ASSERT_TRUE(LaunchBrowser(IE, kChromeFrameFullTabModeDeleteCookieTest)); + + loop.RunFor(kChromeFrameLongNavigationTimeoutInSeconds); + + chrome_frame_test::CloseAllIEWindows(); + ASSERT_TRUE(CheckResultFile(L"FullTab_DeleteCookieTest", "OK")); +} + diff --git a/chrome_frame/test/data/fulltab_delete_cookie_test.html b/chrome_frame/test/data/fulltab_delete_cookie_test.html new file mode 100644 index 0000000..62c5df0 --- /dev/null +++ b/chrome_frame/test/data/fulltab_delete_cookie_test.html @@ -0,0 +1,47 @@ +<html> + <head> + <meta http-equiv="x-ua-compatible" content="chrome=1" /> + <title>FullTab mode cookie deletion test</title> + </head> + + <script type="text/javascript" + src="chrome_frame_tester_helpers.js"></script> + + <script type="text/javascript"> + function onLoad() { + if (!isRunningInChrome()) { + onFailure("FullTab_DeleteCookieTest", 1, "Not running in Chrome"); + return; + } + + // The path of the cookie in this test is set to "/." As a result it + // is set twice, once for the original URL and once for the + // chrome_frame_tester_helpers.js script. We attempt to delete + // the cookie twice and validate that the end result is null. + // First validate that the document cookie contains the substring + // CF_FullTabDeleteCookie=1; CF_FullTabDeleteCookie=1 + // Then erase the first cookie and validate that it no longer contains + // this string. + var cookie_found = + /CF_FullTabDeleteCookie=1; CF_FullTabDeleteCookie=1/.test( + document.cookie); + if (cookie_found) { + eraseCookie("CF_FullTabDeleteCookie"); + cookie_found = + /CF_FullTabDeleteCookie=1; CF_FullTabDeleteCookie=1/.test( + document.cookie); + if (!cookie_found) { + onSuccess("FullTab_DeleteCookieTest", 1); + } else { + onFailure("FullTab_DeleteCookieTest", 1, "Delete cookie failed"); + } + } else { + onFailure("FullTab_DeleteCookieTest", 1, "Expected cookies not set"); + } + } + </script> + + <body onload="onLoad();"> + This tests whether cookies get deleted correctly in full tab mode + </body> +</html> diff --git a/chrome_frame/test/data/fulltab_delete_cookie_test.html.mock-http-headers b/chrome_frame/test/data/fulltab_delete_cookie_test.html.mock-http-headers new file mode 100644 index 0000000..53edac0 --- /dev/null +++ b/chrome_frame/test/data/fulltab_delete_cookie_test.html.mock-http-headers @@ -0,0 +1,3 @@ +HTTP/1.0 200 OK +Content-type: text/html +Set-Cookie: CF_FullTabDeleteCookie=1;path=/ diff --git a/chrome_frame/test/html_util_unittests.cc b/chrome_frame/test/html_util_unittests.cc index 969e680..7884638 100644 --- a/chrome_frame/test/html_util_unittests.cc +++ b/chrome_frame/test/html_util_unittests.cc @@ -5,6 +5,8 @@ #include <windows.h> #include <atlsecurity.h> #include <shellapi.h> +#include <string> +#include <vector> #include "base/basictypes.h" #include "base/file_util.h" @@ -22,6 +24,7 @@ #include "chrome_frame/chrome_frame_delegate.h" #include "chrome_frame/html_utils.h" #include "testing/gtest/include/gtest/gtest.h" +#include "chrome/browser/automation/url_request_automation_job.h" const char kChromeFrameUserAgent[] = "chromeframe"; @@ -360,4 +363,25 @@ TEST(HttpUtils, HasFrameBustingHeader) { "X-Frame-Options: ALLOWall\r\n")); } +TEST(HttpCookieTest, IdentifyDuplicateCookieTest) { + std::vector<std::string> header_cookies; + header_cookies.push_back("BLAHHH; Path=/;"); + + EXPECT_FALSE(URLRequestAutomationJob::IsCookiePresentInCookieHeader( + "BLAHHH=1", header_cookies)); + + header_cookies.clear(); + + header_cookies.push_back("BLAHHH=1; Path=/;"); + + EXPECT_TRUE(URLRequestAutomationJob::IsCookiePresentInCookieHeader( + "BLAHHH=1", header_cookies)); + + header_cookies.clear(); + + header_cookies.push_back("BLAH=1; Path=/blah;"); + + EXPECT_FALSE(URLRequestAutomationJob::IsCookiePresentInCookieHeader( + "BLAH", header_cookies)); +} |