| OLD | NEW |
| 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 #include <string> | 5 #include <string> |
| 6 | 6 |
| 7 #include "chrome/app/chrome_command_ids.h" | 7 #include "chrome/app/chrome_command_ids.h" |
| 8 #include "chrome/browser/net/url_fixer_upper.h" | 8 #include "chrome/browser/net/url_fixer_upper.h" |
| 9 #include "chrome/common/url_constants.h" | 9 #include "chrome/common/url_constants.h" |
| 10 #include "chrome/test/automation/automation_proxy.h" | 10 #include "chrome/test/automation/automation_proxy.h" |
| 11 #include "chrome/test/automation/browser_proxy.h" | 11 #include "chrome/test/automation/browser_proxy.h" |
| 12 #include "chrome/test/automation/tab_proxy.h" | 12 #include "chrome/test/automation/tab_proxy.h" |
| 13 #include "chrome/test/ui/ui_test.h" | 13 #include "chrome/test/ui/ui_test.h" |
| 14 #include "net/test/test_server.h" | 14 #include "net/test/test_server.h" |
| 15 | 15 |
| 16 namespace { | 16 namespace { |
| 17 | 17 |
| 18 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); | 18 const FilePath::CharType kDocRoot[] = FILE_PATH_LITERAL("chrome/test/data"); |
| 19 | 19 |
| 20 } // namespace | 20 } // namespace |
| 21 | 21 |
| 22 typedef UITest CollectedCookiesTest; | 22 typedef UITest CollectedCookiesTest; |
| 23 | 23 |
| 24 TEST_F(CollectedCookiesTest, DoubleDisplay) { | 24 // Crashing on Windows, see http://crbug.com/79331 |
| 25 #if defined(OS_WIN) |
| 26 #define MAYBE_DoubleDisplay DISABLED_DoubleDisplay |
| 27 #else |
| 28 #define MAYBE_DoubleDisplay DoubleDisplay |
| 29 #endif |
| 30 TEST_F(CollectedCookiesTest, MAYBE_DoubleDisplay) { |
| 25 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 31 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
| 26 ASSERT_TRUE(test_server.Start()); | 32 ASSERT_TRUE(test_server.Start()); |
| 27 | 33 |
| 28 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 34 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 29 ASSERT_TRUE(browser.get()); | 35 ASSERT_TRUE(browser.get()); |
| 30 | 36 |
| 31 scoped_refptr<TabProxy> tab(browser->GetTab(0)); | 37 scoped_refptr<TabProxy> tab(browser->GetTab(0)); |
| 32 ASSERT_TRUE(tab.get()); | 38 ASSERT_TRUE(tab.get()); |
| 33 | 39 |
| 34 // Disable cookies. | 40 // Disable cookies. |
| 35 ASSERT_TRUE(browser->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, | 41 ASSERT_TRUE(browser->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, |
| 36 CONTENT_SETTING_BLOCK)); | 42 CONTENT_SETTING_BLOCK)); |
| 37 | 43 |
| 38 // Load a page with cookies. | 44 // Load a page with cookies. |
| 39 ASSERT_TRUE(tab->NavigateToURL(test_server.GetURL("files/cookie1.html"))); | 45 ASSERT_TRUE(tab->NavigateToURL(test_server.GetURL("files/cookie1.html"))); |
| 40 | 46 |
| 41 // Click on the info link twice. | 47 // Click on the info link twice. |
| 42 ASSERT_TRUE(tab->ShowCollectedCookiesDialog()); | 48 ASSERT_TRUE(tab->ShowCollectedCookiesDialog()); |
| 43 ASSERT_TRUE(tab->ShowCollectedCookiesDialog()); | 49 ASSERT_TRUE(tab->ShowCollectedCookiesDialog()); |
| 44 } | 50 } |
| 45 | 51 |
| 46 TEST_F(CollectedCookiesTest, NavigateAway) { | 52 // Crashing on Windows, see http://crbug.com/79331 |
| 53 #if defined(OS_WIN) |
| 54 #define MAYBE_NavigateAway DISABLED_NavigateAway |
| 55 #else |
| 56 #define MAYBE_NavigateAway NavigateAway |
| 57 #endif |
| 58 TEST_F(CollectedCookiesTest, MAYBE_NavigateAway) { |
| 47 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); | 59 net::TestServer test_server(net::TestServer::TYPE_HTTP, FilePath(kDocRoot)); |
| 48 ASSERT_TRUE(test_server.Start()); | 60 ASSERT_TRUE(test_server.Start()); |
| 49 | 61 |
| 50 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); | 62 scoped_refptr<BrowserProxy> browser(automation()->GetBrowserWindow(0)); |
| 51 ASSERT_TRUE(browser.get()); | 63 ASSERT_TRUE(browser.get()); |
| 52 | 64 |
| 53 scoped_refptr<TabProxy> tab(browser->GetTab(0)); | 65 scoped_refptr<TabProxy> tab(browser->GetTab(0)); |
| 54 ASSERT_TRUE(tab.get()); | 66 ASSERT_TRUE(tab.get()); |
| 55 | 67 |
| 56 // Disable cookies. | 68 // Disable cookies. |
| 57 ASSERT_TRUE(browser->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, | 69 ASSERT_TRUE(browser->SetDefaultContentSetting(CONTENT_SETTINGS_TYPE_COOKIES, |
| 58 CONTENT_SETTING_BLOCK)); | 70 CONTENT_SETTING_BLOCK)); |
| 59 | 71 |
| 60 // Load a page with cookies. | 72 // Load a page with cookies. |
| 61 ASSERT_TRUE(tab->NavigateToURL(test_server.GetURL("files/cookie1.html"))); | 73 ASSERT_TRUE(tab->NavigateToURL(test_server.GetURL("files/cookie1.html"))); |
| 62 | 74 |
| 63 // Click on the info link. | 75 // Click on the info link. |
| 64 ASSERT_TRUE(tab->ShowCollectedCookiesDialog()); | 76 ASSERT_TRUE(tab->ShowCollectedCookiesDialog()); |
| 65 | 77 |
| 66 // Navigate to another page. | 78 // Navigate to another page. |
| 67 ASSERT_TRUE(tab->NavigateToURL(test_server.GetURL("files/cookie2.html"))); | 79 ASSERT_TRUE(tab->NavigateToURL(test_server.GetURL("files/cookie2.html"))); |
| 68 } | 80 } |
| OLD | NEW |