• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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"
9 #include "chrome/browser/ui/browser.h"
10 #include "chrome/browser/ui/browser_dialogs.h"
11 #include "chrome/browser/ui/tabs/tab_strip_model.h"
12 #include "chrome/common/url_constants.h"
13 #include "chrome/test/base/in_process_browser_test.h"
14 #include "chrome/test/base/ui_test_utils.h"
15 #include "net/test/embedded_test_server/embedded_test_server.h"
16 
17 typedef InProcessBrowserTest CollectedCookiesTest;
18 
19 // If this crashes on Windows, use http://crbug.com/79331
IN_PROC_BROWSER_TEST_F(CollectedCookiesTest,DoubleDisplay)20 IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, DoubleDisplay) {
21   ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
22 
23   // Disable cookies.
24   CookieSettings::Factory::GetForProfile(browser()->profile())->
25       SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
26 
27   // Load a page with cookies.
28   ui_test_utils::NavigateToURL(
29       browser(), embedded_test_server()->GetURL("/cookie1.html"));
30 
31   // Click on the info link twice.
32   content::WebContents* web_contents =
33       browser()->tab_strip_model()->GetActiveWebContents();
34   chrome::ShowCollectedCookiesDialog(web_contents);
35   chrome::ShowCollectedCookiesDialog(web_contents);
36 }
37 
38 // If this crashes on Windows, use http://crbug.com/79331
IN_PROC_BROWSER_TEST_F(CollectedCookiesTest,NavigateAway)39 IN_PROC_BROWSER_TEST_F(CollectedCookiesTest, NavigateAway) {
40   ASSERT_TRUE(embedded_test_server()->InitializeAndWaitUntilReady());
41 
42   // Disable cookies.
43   CookieSettings::Factory::GetForProfile(browser()->profile())->
44       SetDefaultCookieSetting(CONTENT_SETTING_BLOCK);
45 
46   // Load a page with cookies.
47   ui_test_utils::NavigateToURL(
48       browser(), embedded_test_server()->GetURL("/cookie1.html"));
49 
50   // Click on the info link.
51   content::WebContents* web_contents =
52       browser()->tab_strip_model()->GetActiveWebContents();
53   chrome::ShowCollectedCookiesDialog(web_contents);
54 
55   // Navigate to another page.
56   ui_test_utils::NavigateToURL(
57       browser(), embedded_test_server()->GetURL("/cookie2.html"));
58 }
59