diff options
author | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-02 19:13:00 +0000 |
---|---|---|
committer | ananta@chromium.org <ananta@chromium.org@0039d316-1c4b-4281-b951-d872f2087c98> | 2010-03-02 19:13:00 +0000 |
commit | 70daf0b18defd88e97f5f9ebcc9486c22898b66b (patch) | |
tree | 71e5c7cd9c7733ecafd589e8be81a67c67b2070a /chrome_frame/test | |
parent | 47b950579d39dc79127c1dc69f44c33c8ad269b0 (diff) | |
download | chromium_src-70daf0b18defd88e97f5f9ebcc9486c22898b66b.zip chromium_src-70daf0b18defd88e97f5f9ebcc9486c22898b66b.tar.gz chromium_src-70daf0b18defd88e97f5f9ebcc9486c22898b66b.tar.bz2 |
ChromeFrame should honor the host browser's cookie policy. To achieve this we always read the cookies from
the host browser when the renderer requests them. This also cleans up the mess with the host network stack
code parsing cookies from the host looking for persistent cookies.
Fixes bug http://code.google.com/p/chromium/issues/detail?id=34151
Bug=34151
Test=Covered by existing host network stack tests and chrome frame cookie tests.
Review URL: http://codereview.chromium.org/661290
git-svn-id: svn://svn.chromium.org/chrome/trunk/src@40402 0039d316-1c4b-4281-b951-d872f2087c98
Diffstat (limited to 'chrome_frame/test')
-rw-r--r-- | chrome_frame/test/automation_client_mock.h | 2 | ||||
-rw-r--r-- | chrome_frame/test/html_util_unittests.cc | 42 | ||||
-rw-r--r-- | chrome_frame/test/test_mock_with_web_server.cc | 52 | ||||
-rw-r--r-- | chrome_frame/test/url_request_test.cc | 15 |
4 files changed, 33 insertions, 78 deletions
diff --git a/chrome_frame/test/automation_client_mock.h b/chrome_frame/test/automation_client_mock.h index da51759..b81a582 100644 --- a/chrome_frame/test/automation_client_mock.h +++ b/chrome_frame/test/automation_client_mock.h @@ -65,7 +65,7 @@ struct MockCFDelegate : public ChromeFrameDelegateImpl { void ReplyStarted(int request_id, const char* headers) { request_delegate_->OnResponseStarted(request_id, "text/html", headers, - 0, base::Time::Now(), EmptyString(), EmptyString(), 0); + 0, base::Time::Now(), EmptyString(), 0); } void ReplyData(int request_id, const std::string* data) { diff --git a/chrome_frame/test/html_util_unittests.cc b/chrome_frame/test/html_util_unittests.cc index b993129..7248b80 100644 --- a/chrome_frame/test/html_util_unittests.cc +++ b/chrome_frame/test/html_util_unittests.cc @@ -362,45 +362,3 @@ 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)); -} - -TEST(HttpCookieTest, SetCookiePathToRootIfNotPresentTest) { - struct TestCase { - std::string input; - std::string expected; - } test_cases[] = { - { "", "" }, - { "Cookie=value", "Cookie=value; path=/" }, - { "Cookie=value;", "Cookie=value; path=/" }, - { "Cookie=value; ", "Cookie=value; path=/" }, - { " Cookie=value; ", "Cookie=value; path=/" }, - { "Cookie=", "Cookie=; path=/" }, - { "Cookie=foo; path=/bar", "Cookie=foo; path=/bar" }, - }; - - for (int i = 0; i < arraysize(test_cases); ++i) { - std::string& cookie(test_cases[i].input); - URLRequestAutomationJob::SetCookiePathToRootIfNotPresent(&cookie); - EXPECT_EQ(cookie, test_cases[i].expected); - } -} diff --git a/chrome_frame/test/test_mock_with_web_server.cc b/chrome_frame/test/test_mock_with_web_server.cc index d4a045e..c376638 100644 --- a/chrome_frame/test/test_mock_with_web_server.cc +++ b/chrome_frame/test/test_mock_with_web_server.cc @@ -345,6 +345,10 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { CloseIeAtEndOfScope last_resort_close_ie; chrome_frame_test::TimedMsgLoop loop; ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; + + EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) + .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); + ::testing::InSequence sequence; // Everything in sequence // When the onhttpequiv patch is enabled, we will get two @@ -359,9 +363,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { _, _, _, _, _)) .WillOnce(testing::Return(S_OK)); - EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) - .WillOnce(testing::Return()); - EXPECT_CALL(mock, OnNavigateComplete2(_, _)) .WillOnce(testing::Return()); @@ -371,9 +372,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { _, _, _, _, _)) .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); - EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) - .Times(testing::AnyNumber()).WillOnce(testing::Return()); - EXPECT_CALL(mock, OnNavigateComplete2(_, _)) .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); @@ -391,9 +389,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { _, _, _, _, _)) .WillOnce(testing::Return(S_OK)); - EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) - .Times(testing::AnyNumber()).WillOnce(testing::Return()); - EXPECT_CALL(mock, OnNavigateComplete2(_, _)) .WillOnce(testing::Return()); @@ -403,9 +398,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { _, _, _, _, _)) .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); - EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) - .Times(testing::AnyNumber()).WillOnce(testing::Return()); - EXPECT_CALL(mock, OnNavigateComplete2(_, _)) .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); @@ -424,9 +416,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { _, _, _, _, _)) .WillOnce(testing::Return(S_OK)); - EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) - .Times(testing::AnyNumber()).WillOnce(testing::Return()); - EXPECT_CALL(mock, OnNavigateComplete2(_, _)) .WillOnce(testing::Return()); @@ -436,9 +425,6 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { _, _, _, _, _)) .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); - EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) - .Times(testing::AnyNumber()).WillOnce(testing::Return()); - EXPECT_CALL(mock, OnNavigateComplete2(_, _)) .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); @@ -459,6 +445,15 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { EXPECT_CALL(mock, OnNavigateComplete2(_, _)) .WillOnce(testing::Return()); + EXPECT_CALL(mock, + OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, + testing::StrCaseEq(kSubFrameUrl2)), + _, _, _, _, _)) + .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); + + EXPECT_CALL(mock, OnNavigateComplete2(_, _)) + .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); + EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl2))) .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( CreateFunctor(ReceivePointer(mock.web_browser2_), @@ -474,6 +469,15 @@ TEST_F(ChromeFrameTestWithWebServer, FullTabModeIE_BackForward) { EXPECT_CALL(mock, OnNavigateComplete2(_, _)) .WillOnce(testing::Return()); + EXPECT_CALL(mock, + OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, + testing::StrCaseEq(kSubFrameUrl1)), + _, _, _, _, _)) + .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); + + EXPECT_CALL(mock, OnNavigateComplete2(_, _)) + .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); + EXPECT_CALL(mock, OnLoad(testing::StrEq(kSubFrameUrl1))) .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs( CreateFunctor(&mock, @@ -927,20 +931,19 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_ContextMenuBackForward) chrome_frame_test::TimedMsgLoop loop; ComStackObjectWithUninitialize<MockWebBrowserEventSink> mock; + EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) + .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); + ::testing::InSequence sequence; // Everything in sequence EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, testing::StrCaseEq(kSubFrameUrl1)), _, _, _, _, _)) .WillOnce(testing::Return(S_OK)); - EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) - .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); EXPECT_CALL(mock, OnNavigateComplete2(_, _)).WillOnce(testing::Return()); EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, testing::StrCaseEq(kSubFrameUrl1)), _, _, _, _, _)) .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); - EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) - .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); EXPECT_CALL(mock, OnNavigateComplete2(_, _)) .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); @@ -955,15 +958,11 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_ContextMenuBackForward) testing::StrCaseEq(kSubFrameUrl2)), _, _, _, _, _)) .WillOnce(testing::Return(S_OK)); - EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) - .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); EXPECT_CALL(mock, OnNavigateComplete2(_, _)).WillOnce(testing::Return()); EXPECT_CALL(mock, OnBeforeNavigate2(_, testing::Field(&VARIANT::bstrVal, testing::StrCaseEq(kSubFrameUrl2)), _, _, _, _, _)) .Times(testing::AnyNumber()).WillRepeatedly(testing::Return(S_OK)); - EXPECT_CALL(mock, OnFileDownload(VARIANT_TRUE, _)) - .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); EXPECT_CALL(mock, OnNavigateComplete2(_, _)) .Times(testing::AnyNumber()).WillRepeatedly(testing::Return()); @@ -1038,6 +1037,7 @@ TEST_F(ChromeFrameTestWithWebServer, FLAKY_FullTabModeIE_ContextMenuBackForward) CreateFunctor(&mock, &MockWebBrowserEventSink::CloseWebBrowser)))); EXPECT_CALL(mock, OnQuit()).WillOnce(QUIT_LOOP(loop)); + HRESULT hr = mock.LaunchIEAndNavigate(kSubFrameUrl1); ASSERT_HRESULT_SUCCEEDED(hr); if (hr == S_FALSE) diff --git a/chrome_frame/test/url_request_test.cc b/chrome_frame/test/url_request_test.cc index aad95a9..03428e5 100644 --- a/chrome_frame/test/url_request_test.cc +++ b/chrome_frame/test/url_request_test.cc @@ -18,9 +18,8 @@ const int kChromeFrameLongNavigationTimeoutInSeconds = 10; class MockUrlDelegate : public PluginUrlRequestDelegate { public: - MOCK_METHOD8(OnResponseStarted, void(int request_id, const char* mime_type, - const char* headers, int size, - base::Time last_modified, const std::string& peristent_cookies, + MOCK_METHOD7(OnResponseStarted, void(int request_id, const char* mime_type, + const char* headers, int size, base::Time last_modified, const std::string& redirect_url, int redirect_status)); MOCK_METHOD3(OnReadComplete, void(int request_id, const void* buffer, int len)); @@ -65,8 +64,7 @@ TEST(UrlmonUrlRequestTest, Simple1) { testing::InSequence s; EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, - testing::_, testing::_, testing::_, - testing::_)) + testing::_, testing::_, testing::_)) .Times(1) .WillOnce(testing::IgnoreResult(testing::InvokeWithoutArgs(CreateFunctor( &request, &UrlmonUrlRequest::Read, 512)))); @@ -133,8 +131,7 @@ TEST(UrlmonUrlRequestTest, ZeroLengthResponse) { // Expect headers EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, - testing::_, testing::_, testing::_, - testing::_)) + testing::_, testing::_, testing::_)) .Times(1) .WillOnce(QUIT_LOOP(loop)); @@ -168,7 +165,7 @@ TEST(UrlmonUrlRequestManagerTest, Simple1) { server.Resolve(L"files/chrome_frame_window_open.html").spec(), "get" }; EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, - testing::_, testing::_, testing::_, testing::_)) + testing::_, testing::_, testing::_)) .Times(1) .WillOnce(testing::InvokeWithoutArgs(CreateFunctor(mgr.get(), &PluginUrlRequestManager::ReadUrlRequest, 0, 1, 512))); @@ -199,7 +196,7 @@ TEST(UrlmonUrlRequestManagerTest, Abort1) { server.Resolve(L"files/chrome_frame_window_open.html").spec(), "get" }; EXPECT_CALL(mock, OnResponseStarted(1, testing::_, testing::_, testing::_, - testing::_, testing::_, testing::_, testing::_)) + testing::_, testing::_, testing::_)) .Times(1) .WillOnce(testing::DoAll( testing::InvokeWithoutArgs(CreateFunctor(mgr.get(), |