Index: chrome/browser/policy/policy_browsertest.cc |
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc |
index 494fe79afd276ac25d0e72cba039d717eb1581db..b8fc4f83f15da5e346e6b3fdad5d383981b5b7d8 100644 |
--- a/chrome/browser/policy/policy_browsertest.cc |
+++ b/chrome/browser/policy/policy_browsertest.cc |
@@ -647,6 +647,55 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DefaultSearchProvider) { |
EXPECT_EQ(GURL(chrome::kAboutBlankURL), web_contents->GetURL()); |
} |
+IN_PROC_BROWSER_TEST_F(PolicyTest, SafeSearch) { |
Joao da Silva
2012/10/19 10:00:38
ForceSafeSeach
Sergiu
2012/10/19 12:00:18
Done.
|
+ // Verifies that requests to Google Search engine with the SafeSearch |
+ // enabled set the safe=active&ssui=on parameters at the end of the query. |
+ TemplateURLService* service = TemplateURLServiceFactory::GetForProfile( |
+ browser()->profile()); |
+ ui_test_utils::WaitForTemplateURLServiceToLoad(service); |
+ |
+ // First check that nothing happens. |
+ chrome::FocusLocationBar(browser()); |
+ LocationBar* location_bar = browser()->window()->GetLocationBar(); |
+ ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/"); |
+ OmniboxEditModel* model = location_bar->GetLocationEntry()->model(); |
+ EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid()); |
+ content::WebContents* web_contents = chrome::GetActiveWebContents(browser()); |
+ GURL expected_without("http://google.com/"); |
+ EXPECT_EQ(expected_without, web_contents->GetURL()); |
+ |
+ PrefService* prefs = browser()->profile()->GetPrefs(); |
+ EXPECT_FALSE(prefs->IsManagedPreference(prefs::kForceSafeSearch)); |
+ EXPECT_FALSE(prefs->GetBoolean(prefs::kForceSafeSearch)); |
+ |
+ // Override the default SafeSearch setting using policies. |
+ PolicyMap policies; |
+ policies.Set(key::kForceSafeSearch, POLICY_LEVEL_MANDATORY, |
+ POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); |
+ provider_.UpdateChromePolicy(policies); |
+ |
+ EXPECT_TRUE(prefs->IsManagedPreference(prefs::kForceSafeSearch)); |
+ EXPECT_TRUE(prefs->GetBoolean(prefs::kForceSafeSearch)); |
+ |
+ content::WindowedNotificationObserver observer( |
+ content::NOTIFICATION_LOAD_COMPLETED_MAIN_FRAME, |
+ content::NotificationService::AllSources()); |
+ |
+ // Verify that searching from google.com works. |
+ chrome::FocusLocationBar(browser()); |
+ location_bar = browser()->window()->GetLocationBar(); |
+ ui_test_utils::SendToOmniboxAndSubmit(location_bar, "http://google.com/"); |
+ observer.Wait(); |
+ model = location_bar->GetLocationEntry()->model(); |
+ EXPECT_TRUE(model->CurrentMatch().destination_url.is_valid()); |
+ web_contents = chrome::GetActiveWebContents(browser()); |
+ std::string expected_url("http://google.com/?"); |
+ expected_url += std::string(chrome::kSafeSearchSafeParameter) + "&" + |
+ chrome::kSafeSearchSsuiParameter; |
+ GURL expected_with_parameters(expected_url); |
+ EXPECT_EQ(expected_with_parameters, web_contents->GetURL()); |
+} |
+ |
IN_PROC_BROWSER_TEST_F(PolicyTest, ReplaceSearchTerms) { |
CommandLine::ForCurrentProcess()->AppendSwitch( |
switches::kEnableInstantExtendedAPI); |