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