Chromium Code Reviews| OLD | NEW |
|---|---|
| 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/path_service.h" | 7 #include "base/path_service.h" |
| 8 #include "base/strings/utf_string_conversions.h" | 8 #include "base/strings/utf_string_conversions.h" |
| 9 #include "chrome/browser/download/download_prefs.h" | 9 #include "chrome/browser/download/download_prefs.h" |
| 10 #include "chrome/browser/prefs/pref_service_syncable.h" | 10 #include "chrome/browser/prefs/pref_service_syncable.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 58 scoped_ptr<content::DownloadTestObserver> downloads_observer( | 58 scoped_ptr<content::DownloadTestObserver> downloads_observer( |
| 59 CreateWaiter(browser(), 1)); | 59 CreateWaiter(browser(), 1)); |
| 60 ui_test_utils::NavigateToURL( | 60 ui_test_utils::NavigateToURL( |
| 61 browser(), | 61 browser(), |
| 62 test_server()->GetURL("files/downloads/a_zip_file.zip")); | 62 test_server()->GetURL("files/downloads/a_zip_file.zip")); |
| 63 // Waits for the download to complete. | 63 // Waits for the download to complete. |
| 64 downloads_observer->WaitForFinished(); | 64 downloads_observer->WaitForFinished(); |
| 65 EXPECT_TRUE(base::PathExists(downloaded_pkg)); | 65 EXPECT_TRUE(base::PathExists(downloaded_pkg)); |
| 66 } | 66 } |
| 67 | 67 |
| 68 // Verify image content settings show or hide images. | 68 // Verify that image content settings show or hide images. |
| 69 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestImageContentSettings) { | 69 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestImageContentSettings) { |
| 70 ASSERT_TRUE(test_server()->Start()); | 70 ASSERT_TRUE(test_server()->Start()); |
| 71 | 71 |
| 72 ui_test_utils::NavigateToURL( | 72 ui_test_utils::NavigateToURL( |
| 73 browser(), | 73 browser(), |
| 74 test_server()->GetURL("files/settings/image_page.html")); | 74 test_server()->GetURL("files/settings/image_page.html")); |
| 75 | 75 |
| 76 bool result = false; | 76 bool result = false; |
| 77 std::string script = | 77 std::string script = |
| 78 "for (i=0; i < document.images.length; i++) {" | 78 "for (var i = 0; i < document.images.length; ++i) {" |
| 79 " if ((document.images[i].naturalWidth != 0) &&" | 79 " if ((document.images[i].naturalWidth != 0) &&" |
| 80 " (document.images[i].naturalHeight != 0)) {" | 80 " (document.images[i].naturalHeight != 0)) {" |
| 81 " window.domAutomationController.send(true);" | 81 " window.domAutomationController.send(true);" |
| 82 " }" | 82 " }" |
| 83 "}" | 83 "}" |
| 84 "window.domAutomationController.send(false);"; | 84 "window.domAutomationController.send(false);"; |
| 85 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 85 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 86 browser()->tab_strip_model()->GetActiveWebContents(), | 86 browser()->tab_strip_model()->GetActiveWebContents(), |
| 87 script, | 87 script, |
| 88 &result)); | 88 &result)); |
| 89 EXPECT_TRUE(result); | 89 EXPECT_TRUE(result); |
| 90 | 90 |
| 91 base::DictionaryValue value; | 91 base::DictionaryValue value; |
| 92 value.SetInteger("images", 2); | 92 value.SetInteger("images", CONTENT_SETTING_BLOCK); |
| 93 browser()->profile()->GetPrefs()->Set(prefs::kDefaultContentSettings, | 93 browser()->profile()->GetPrefs()->Set(prefs::kDefaultContentSettings, value); |
| 94 value); | |
| 95 | 94 |
| 96 ui_test_utils::NavigateToURL( | 95 ui_test_utils::NavigateToURL( |
| 97 browser(), | 96 browser(), |
| 98 test_server()->GetURL("files/settings/image_page.html")); | 97 test_server()->GetURL("files/settings/image_page.html")); |
| 99 | 98 |
| 100 result = false; | 99 result = false; |
| 101 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 100 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 102 browser()->tab_strip_model()->GetActiveWebContents(), | 101 browser()->tab_strip_model()->GetActiveWebContents(), |
| 103 script, | 102 script, |
| 104 &result)); | 103 &result)); |
| (...skipping 13 matching lines...) Expand all Loading... | |
| 118 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); | 117 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); |
| 119 browser()->profile()->GetPrefs()->SetBoolean(prefs::kWebKitJavascriptEnabled, | 118 browser()->profile()->GetPrefs()->SetBoolean(prefs::kWebKitJavascriptEnabled, |
| 120 false); | 119 false); |
| 121 ui_test_utils::NavigateToURL( | 120 ui_test_utils::NavigateToURL( |
| 122 browser(), | 121 browser(), |
| 123 test_server()->GetURL("files/javaScriptTitle.html")); | 122 test_server()->GetURL("files/javaScriptTitle.html")); |
| 124 EXPECT_EQ(base::ASCIIToUTF16("This is html title"), | 123 EXPECT_EQ(base::ASCIIToUTF16("This is html title"), |
| 125 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); | 124 browser()->tab_strip_model()->GetActiveWebContents()->GetTitle()); |
| 126 } | 125 } |
| 127 | 126 |
| 127 // Verify that media content settings allow or block <video> content. | |
| 128 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestMediaContentSettings) { | |
| 129 ASSERT_TRUE(test_server()->Start()); | |
| 130 | |
| 131 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( | |
|
Bernhard Bauer
2014/07/01 09:12:50
I would probably use ASSERT_TRUE, because if Javas
| |
| 132 prefs::kWebKitJavascriptEnabled)); | |
| 133 ui_test_utils::NavigateToURL( | |
| 134 browser(), | |
| 135 test_server()->GetURL("files/settings/video_page.html")); | |
| 136 | |
| 137 bool result = false; | |
| 138 std::string script = | |
| 139 "(function() {" | |
| 140 " var checkVideo = function() {" | |
| 141 " window.domAutomationController.send(" | |
| 142 " document.querySelector('video').readyState > 0);" | |
| 143 " };" | |
| 144 " if (document.readyState == 'complete') {" | |
| 145 " checkVideo();" | |
| 146 " } else {" | |
| 147 " document.body.addEventListener('load', checkVideo);" | |
| 148 " }" | |
| 149 "})();"; | |
| 150 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | |
| 151 browser()->tab_strip_model()->GetActiveWebContents(), | |
| 152 script, | |
| 153 &result)); | |
| 154 EXPECT_TRUE(result); | |
| 155 | |
| 156 base::DictionaryValue value; | |
| 157 value.SetInteger("media", CONTENT_SETTING_BLOCK); | |
| 158 browser()->profile()->GetPrefs()->Set(prefs::kDefaultContentSettings, value); | |
| 159 | |
| 160 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( | |
| 161 prefs::kWebKitJavascriptEnabled)); | |
| 162 ui_test_utils::NavigateToURL( | |
| 163 browser(), | |
| 164 test_server()->GetURL("files/settings/video_page.html")); | |
| 165 | |
| 166 result = false; | |
| 167 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | |
| 168 browser()->tab_strip_model()->GetActiveWebContents(), | |
| 169 script, | |
| 170 &result)); | |
| 171 EXPECT_FALSE(result); | |
| 172 } | |
| 173 | |
| 128 // Verify DNS prefetching pref. | 174 // Verify DNS prefetching pref. |
| 129 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestNetworkPredictionEnabledPref) { | 175 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestNetworkPredictionEnabledPref) { |
| 130 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( | 176 EXPECT_TRUE(browser()->profile()->GetPrefs()->GetBoolean( |
| 131 prefs::kNetworkPredictionEnabled)); | 177 prefs::kNetworkPredictionEnabled)); |
| 132 browser()->profile()->GetPrefs()->SetBoolean(prefs::kNetworkPredictionEnabled, | 178 browser()->profile()->GetPrefs()->SetBoolean(prefs::kNetworkPredictionEnabled, |
| 133 false); | 179 false); |
| 134 EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean( | 180 EXPECT_FALSE(browser()->profile()->GetPrefs()->GetBoolean( |
| 135 prefs::kNetworkPredictionEnabled)); | 181 prefs::kNetworkPredictionEnabled)); |
| 136 } | 182 } |
| 137 | 183 |
| (...skipping 97 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 235 EXPECT_FALSE(prefs->GetBoolean(prefs::kSafeBrowsingEnabled)); | 281 EXPECT_FALSE(prefs->GetBoolean(prefs::kSafeBrowsingEnabled)); |
| 236 EXPECT_FALSE(prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)); | 282 EXPECT_FALSE(prefs->GetBoolean(prefs::kAlternateErrorPagesEnabled)); |
| 237 EXPECT_FALSE(prefs->GetBoolean(prefs::kSearchSuggestEnabled)); | 283 EXPECT_FALSE(prefs->GetBoolean(prefs::kSearchSuggestEnabled)); |
| 238 } | 284 } |
| 239 | 285 |
| 240 // Verify that we have some Local State prefs. | 286 // Verify that we have some Local State prefs. |
| 241 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestHaveLocalStatePrefs) { | 287 IN_PROC_BROWSER_TEST_F(PrefsFunctionalTest, TestHaveLocalStatePrefs) { |
| 242 EXPECT_TRUE(g_browser_process->local_state()->GetPreferenceValues().get()); | 288 EXPECT_TRUE(g_browser_process->local_state()->GetPreferenceValues().get()); |
| 243 } | 289 } |
| 244 | 290 |
| OLD | NEW |