Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(71)

Side by Side Diff: chrome/browser/prefs/pref_functional_browsertest.cc

Issue 1378123003: Adding SSL ETS Tests (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@ets
Patch Set: Rebase. Created 5 years, 1 month ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
1 // Copyright 2013 The Chromium Authors. All rights reserved. 1 // Copyright 2013 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 "base/strings/utf_string_conversions.h" 7 #include "base/strings/utf_string_conversions.h"
8 #include "chrome/browser/download/download_prefs.h" 8 #include "chrome/browser/download/download_prefs.h"
9 #include "chrome/browser/net/prediction_options.h" 9 #include "chrome/browser/net/prediction_options.h"
10 #include "chrome/browser/ui/browser.h" 10 #include "chrome/browser/ui/browser.h"
(...skipping 30 matching lines...) Expand all
41 content::DownloadTestObserver* downloads_observer = 41 content::DownloadTestObserver* downloads_observer =
42 new content::DownloadTestObserverTerminal( 42 new content::DownloadTestObserverTerminal(
43 download_manager, 43 download_manager,
44 num_downloads, 44 num_downloads,
45 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); 45 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL);
46 return make_scoped_ptr(downloads_observer); 46 return make_scoped_ptr(downloads_observer);
47 } 47 }
48 }; 48 };
49 49
50 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestDownloadDirPref) { 50 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestDownloadDirPref) {
51 ASSERT_TRUE(test_server()->Start()); 51 ASSERT_TRUE(embedded_test_server()->Start());
52 base::ScopedTempDir new_download_dir; 52 base::ScopedTempDir new_download_dir;
53 ASSERT_TRUE(new_download_dir.CreateUniqueTempDir()); 53 ASSERT_TRUE(new_download_dir.CreateUniqueTempDir());
54 54
55 base::FilePath downloaded_pkg = 55 base::FilePath downloaded_pkg =
56 new_download_dir.path().AppendASCII("a_zip_file.zip"); 56 new_download_dir.path().AppendASCII("a_zip_file.zip");
57 57
58 // Set pref to download in new_download_dir. 58 // Set pref to download in new_download_dir.
59 browser()->profile()->GetPrefs()->SetFilePath( 59 browser()->profile()->GetPrefs()->SetFilePath(
60 prefs::kDownloadDefaultDirectory, new_download_dir.path()); 60 prefs::kDownloadDefaultDirectory, new_download_dir.path());
61 61
62 // Create a downloads observer. 62 // Create a downloads observer.
63 scoped_ptr<content::DownloadTestObserver> downloads_observer( 63 scoped_ptr<content::DownloadTestObserver> downloads_observer(
64 CreateWaiter(browser(), 1)); 64 CreateWaiter(browser(), 1));
65 ui_test_utils::NavigateToURL( 65 ui_test_utils::NavigateToURL(
66 browser(), 66 browser(), embedded_test_server()->GetURL("/downloads/a_zip_file.zip"));
67 test_server()->GetURL("files/downloads/a_zip_file.zip"));
68 // Waits for the download to complete. 67 // Waits for the download to complete.
69 downloads_observer->WaitForFinished(); 68 downloads_observer->WaitForFinished();
70 EXPECT_TRUE(base::PathExists(downloaded_pkg)); 69 EXPECT_TRUE(base::PathExists(downloaded_pkg));
71 } 70 }
72 71
73 // Verify image content settings show or hide images. 72 // Verify image content settings show or hide images.
74 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestImageContentSettings) { 73 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestImageContentSettings) {
75 ASSERT_TRUE(test_server()->Start()); 74 ASSERT_TRUE(embedded_test_server()->Start());
76 75
77 ui_test_utils::NavigateToURL( 76 ui_test_utils::NavigateToURL(
78 browser(), 77 browser(), embedded_test_server()->GetURL("/settings/image_page.html"));
79 test_server()->GetURL("files/settings/image_page.html"));
80 78
81 bool result = false; 79 bool result = false;
82 std::string script = 80 std::string script =
83 "for (i=0; i < document.images.length; i++) {" 81 "for (i=0; i < document.images.length; i++) {"
84 " if ((document.images[i].naturalWidth != 0) &&" 82 " if ((document.images[i].naturalWidth != 0) &&"
85 " (document.images[i].naturalHeight != 0)) {" 83 " (document.images[i].naturalHeight != 0)) {"
86 " window.domAutomationController.send(true);" 84 " window.domAutomationController.send(true);"
87 " }" 85 " }"
88 "}" 86 "}"
89 "window.domAutomationController.send(false);"; 87 "window.domAutomationController.send(false);";
90 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 88 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
91 browser()->tab_strip_model()->GetActiveWebContents(), 89 browser()->tab_strip_model()->GetActiveWebContents(),
92 script, 90 script,
93 &result)); 91 &result));
94 EXPECT_TRUE(result); 92 EXPECT_TRUE(result);
95 93
96 browser()->profile()->GetPrefs()->SetInteger( 94 browser()->profile()->GetPrefs()->SetInteger(
97 content_settings::WebsiteSettingsRegistry::GetInstance() 95 content_settings::WebsiteSettingsRegistry::GetInstance()
98 ->Get(CONTENT_SETTINGS_TYPE_IMAGES) 96 ->Get(CONTENT_SETTINGS_TYPE_IMAGES)
99 ->default_value_pref_name(), 97 ->default_value_pref_name(),
100 CONTENT_SETTING_BLOCK); 98 CONTENT_SETTING_BLOCK);
101 99
102 ui_test_utils::NavigateToURL( 100 ui_test_utils::NavigateToURL(
103 browser(), 101 browser(), embedded_test_server()->GetURL("/settings/image_page.html"));
104 test_server()->GetURL("files/settings/image_page.html"));
105 102
106 result = false; 103 result = false;
107 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 104 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
108 browser()->tab_strip_model()->GetActiveWebContents(), 105 browser()->tab_strip_model()->GetActiveWebContents(),
109 script, 106 script,
110 &result)); 107 &result));
111 EXPECT_FALSE(result); 108 EXPECT_FALSE(result);
112 } 109 }
113 110
114 // Verify that enabling/disabling Javascript in prefs works. 111 // Verify that enabling/disabling Javascript in prefs works.
115 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestJavascriptEnableDisable) { 112 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestJavascriptEnableDisable) {
116 ASSERT_TRUE(test_server()->Start()); 113 ASSERT_TRUE(embedded_test_server()->Start());
117 114
118 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( 115 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
119 prefs::kWebKitJavascriptEnabled)); 116 prefs::kWebKitJavascriptEnabled));
120 ui_test_utils::NavigateToURL( 117 ui_test_utils::NavigateToURL(
121 browser(), 118 browser(), embedded_test_server()->GetURL("/javaScriptTitle.html"));
122 test_server()->GetURL("files/javaScriptTitle.html"));
123 EXPECT_EQ(base::ASCIIToUTF16("Title from script javascript enabled"), 119 EXPECT_EQ(base::ASCIIToUTF16("Title from script javascript enabled"),
124 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); 120 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle());
125 browser()->profile()->GetPrefs()->SetBoolean(prefs::kWebKitJavascriptEnabled, 121 browser()->profile()->GetPrefs()->SetBoolean(prefs::kWebKitJavascriptEnabled,
126 false); 122 false);
127 ui_test_utils::NavigateToURL( 123 ui_test_utils::NavigateToURL(
128 browser(), 124 browser(), embedded_test_server()->GetURL("/javaScriptTitle.html"));
129 test_server()->GetURL("files/javaScriptTitle.html"));
130 EXPECT_EQ(base::ASCIIToUTF16("This is html title"), 125 EXPECT_EQ(base::ASCIIToUTF16("This is html title"),
131 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); 126 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle());
132 } 127 }
133 128
134 // Verify restore for bookmark bar visibility. 129 // Verify restore for bookmark bar visibility.
135 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, 130 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest,
136 TestSessionRestoreShowBookmarkBar) { 131 TestSessionRestoreShowBookmarkBar) {
137 EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean( 132 EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean(
138 bookmarks::prefs::kShowBookmarkBar)); 133 bookmarks::prefs::kShowBookmarkBar));
139 browser()->profile()->GetPrefs()->SetBoolean( 134 browser()->profile()->GetPrefs()->SetBoolean(
140 bookmarks::prefs::kShowBookmarkBar, true); 135 bookmarks::prefs::kShowBookmarkBar, true);
141 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( 136 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
142 bookmarks::prefs::kShowBookmarkBar)); 137 bookmarks::prefs::kShowBookmarkBar));
143 138
144 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( 139 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean(
145 bookmarks::prefs::kShowBookmarkBar)); 140 bookmarks::prefs::kShowBookmarkBar));
146 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state()); 141 EXPECT_EQ(BookmarkBar::SHOW, browser()->bookmark_bar_state());
147 } 142 }
148 143
149 // Verify images are not blocked in incognito mode. 144 // Verify images are not blocked in incognito mode.
150 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestImagesNotBlockedInIncognito) { 145 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestImagesNotBlockedInIncognito) {
151 ASSERT_TRUE(test_server()->Start()); 146 ASSERT_TRUE(embedded_test_server()->Start());
152 GURL url = test_server()->GetURL("files/settings/image_page.html"); 147 GURL url = embedded_test_server()->GetURL("/settings/image_page.html");
153 Browser* incognito_browser = CreateIncognitoBrowser(); 148 Browser* incognito_browser = CreateIncognitoBrowser();
154 ui_test_utils::NavigateToURL(incognito_browser, url); 149 ui_test_utils::NavigateToURL(incognito_browser, url);
155 150
156 bool result = false; 151 bool result = false;
157 std::string script = 152 std::string script =
158 "for (i=0; i < document.images.length; i++) {" 153 "for (i=0; i < document.images.length; i++) {"
159 " if ((document.images[i].naturalWidth != 0) &&" 154 " if ((document.images[i].naturalWidth != 0) &&"
160 " (document.images[i].naturalHeight != 0)) {" 155 " (document.images[i].naturalHeight != 0)) {"
161 " window.domAutomationController.send(true);" 156 " window.domAutomationController.send(true);"
162 " }" 157 " }"
(...skipping 71 matching lines...) Expand 10 before | Expand all | Expand 10 after
234 prefs->GetInteger(prefs::kNetworkPredictionOptions)); 229 prefs->GetInteger(prefs::kNetworkPredictionOptions));
235 EXPECT_FALSE(prefs->GetBoolean(prefs::kSafeBrowsingEnabled)); 230 EXPECT_FALSE(prefs->GetBoolean(prefs::kSafeBrowsingEnabled));
236 EXPECT_FALSE(prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)); 231 EXPECT_FALSE(prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled));
237 EXPECT_FALSE(prefs->GetBoolean(prefs::kSearchSuggestEnabled)); 232 EXPECT_FALSE(prefs->GetBoolean(prefs::kSearchSuggestEnabled));
238 } 233 }
239 234
240 // Verify that we have some Local State prefs. 235 // Verify that we have some Local State prefs.
241 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestHaveLocalStatePrefs) { 236 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestHaveLocalStatePrefs) {
242 EXPECT_TRUE(g_browser_process->local_state()->GetPreferenceValues().get()); 237 EXPECT_TRUE(g_browser_process->local_state()->GetPreferenceValues().get());
243 } 238 }
244
OLDNEW
« no previous file with comments | « chrome/browser/prefetch/prefetch_browsertest.cc ('k') | chrome/browser/prerender/prerender_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698