[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 1 | // Copyright (c) 2012 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/content_settings/cookie_settings.h" | ||||
[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 9 | #include "chrome/browser/ui/browser.h" |
[email protected] | 1f0b50b | 2012-06-22 20:37:16 | [diff] [blame] | 10 | #include "chrome/browser/ui/browser_dialogs.h" |
[email protected] | cc87237 | 2013-01-28 21:57:07 | [diff] [blame] | 11 | #include "chrome/browser/ui/tabs/tab_strip_model.h" |
[email protected] | 4f3b446 | 2013-07-27 19:20:18 | [diff] [blame] | 12 | #include "chrome/common/net/url_fixer_upper.h" |
[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 13 | #include "chrome/common/url_constants.h" |
14 | #include "chrome/test/base/in_process_browser_test.h" | ||||
15 | #include "chrome/test/base/ui_test_utils.h" | ||||
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 16 | #include "net/test/embedded_test_server/embedded_test_server.h" |
[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 17 | |
18 | typedef InProcessBrowserTest CollectedCookiesTest; | ||||
19 | |||||
20 | // If this crashes on Windows, use http://crbug.com/79331 | ||||
21 | IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, DoubleDisplay) { | ||||
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 22 | ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 23 | |
24 | // Disable cookies. | ||||
25 | CookieSettings::Factory::GetForProfile(browser()->profile())-> | ||||
26 | SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); | ||||
27 | |||||
28 | // Load a page with cookies. | ||||
29 | ui_test_utils::NavigateToURL( | ||||
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 30 | browser(), embedded_test_server()->GetURL("/cookie1.html")); |
[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 31 | |
32 | // Click on the info link twice. | ||||
[email protected] | cc87237 | 2013-01-28 21:57:07 | [diff] [blame] | 33 | content::WebContents* web_contents = |
34 | browser()->tab_strip_model()->GetActiveWebContents(); | ||||
[email protected] | b95f184 | 2012-10-19 22:34:15 | [diff] [blame] | 35 | chrome::ShowCollectedCookiesDialog(web_contents); |
36 | chrome::ShowCollectedCookiesDialog(web_contents); | ||||
[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 37 | } |
38 | |||||
39 | // If this crashes on Windows, use http://crbug.com/79331 | ||||
40 | IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, NavigateAway) { | ||||
[email protected] | 32aabdf | 2013-10-02 10:10:04 | [diff] [blame] | 41 | ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady()); |
[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 42 | |
43 | // Disable cookies. | ||||
44 | CookieSettings::Factory::GetForProfile(browser()->profile())-> | ||||
45 | SetDefaultCookieSetting(CONTENT_SETTING_BLOCK); | ||||
46 | |||||
47 | // Load a page with cookies. | ||||
48 | ui_test_utils::NavigateToURL( | ||||
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 49 | browser(), embedded_test_server()->GetURL("/cookie1.html")); |
[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 50 | |
51 | // Click on the info link. | ||||
[email protected] | cc87237 | 2013-01-28 21:57:07 | [diff] [blame] | 52 | content::WebContents* web_contents = |
53 | browser()->tab_strip_model()->GetActiveWebContents(); | ||||
[email protected] | b95f184 | 2012-10-19 22:34:15 | [diff] [blame] | 54 | chrome::ShowCollectedCookiesDialog(web_contents); |
[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 55 | |
56 | // Navigate to another page. | ||||
57 | ui_test_utils::NavigateToURL( | ||||
[email protected] | c1dffe8 | 2013-06-26 20:59:05 | [diff] [blame] | 58 | browser(), embedded_test_server()->GetURL("/cookie2.html")); |
[email protected] | 0ea5b7c1c | 2012-05-15 15:52:33 | [diff] [blame] | 59 | } |