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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 325443002: Move about://-related constants from //content to //url (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: Android ifx Created 6 years, 6 months 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. 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 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 <algorithm> 5 #include <algorithm>
6 #include <string> 6 #include <string>
7 #include <vector> 7 #include <vector>
8 8
9 #include "base/bind.h" 9 #include "base/bind.h"
10 #include "base/bind_helpers.h" 10 #include "base/bind_helpers.h"
(...skipping 922 matching lines...) Expand 10 before | Expand all | Expand 10 after
933 LocationBar* location_bar = browser()->window()->GetLocationBar(); 933 LocationBar* location_bar = browser()->window()->GetLocationBar();
934 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "stuff to search for"); 934 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "stuff to search for");
935 OmniboxEditModel* model = location_bar->GetOmniboxView()->model(); 935 OmniboxEditModel* model = location_bar->GetOmniboxView()->model();
936 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid()); 936 EXPECT_TRUE(model->CurrentMatch(NULL).destination_url.is_valid());
937 content::WebContents* web_contents = 937 content::WebContents* web_contents =
938 browser()->tab_strip_model()->GetActiveWebContents(); 938 browser()->tab_strip_model()->GetActiveWebContents();
939 GURL expected("http://search.example/search?q=stuff+to+search+for"); 939 GURL expected("http://search.example/search?q=stuff+to+search+for");
940 EXPECT_EQ(expected, web_contents->GetURL()); 940 EXPECT_EQ(expected, web_contents->GetURL());
941 941
942 // Verify that searching from the omnibox can be disabled. 942 // Verify that searching from the omnibox can be disabled.
943 ui_test_utils::NavigateToURL(browser(), GURL(content::kAboutBlankURL)); 943 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
944 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY, 944 policies.Set(key::kDefaultSearchProviderEnabled, POLICY_LEVEL_MANDATORY,
945 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 945 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL);
946 EXPECT_TRUE(service->GetDefaultSearchProvider()); 946 EXPECT_TRUE(service->GetDefaultSearchProvider());
947 UpdateProviderPolicy(policies); 947 UpdateProviderPolicy(policies);
948 EXPECT_FALSE(service->GetDefaultSearchProvider()); 948 EXPECT_FALSE(service->GetDefaultSearchProvider());
949 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work"); 949 ui_test_utils::SendToOmniboxAndSubmit(location_bar, "should not work");
950 // This means that submitting won't trigger any action. 950 // This means that submitting won't trigger any action.
951 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid()); 951 EXPECT_FALSE(model->CurrentMatch(NULL).destination_url.is_valid());
952 EXPECT_EQ(GURL(content::kAboutBlankURL), web_contents->GetURL()); 952 EXPECT_EQ(GURL(url::kAboutBlankURL), web_contents->GetURL());
953 } 953 }
954 954
955 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) { 955 IN_PROC_BROWSER_TEST_F(PolicyTest, PolicyPreprocessing) {
956 // Add an individual proxy policy value. 956 // Add an individual proxy policy value.
957 PolicyMap policies; 957 PolicyMap policies;
958 policies.Set(key::kProxyServerMode, 958 policies.Set(key::kProxyServerMode,
959 POLICY_LEVEL_MANDATORY, 959 POLICY_LEVEL_MANDATORY,
960 POLICY_SCOPE_USER, 960 POLICY_SCOPE_USER,
961 base::Value::CreateIntegerValue(3), 961 base::Value::CreateIntegerValue(3),
962 NULL); 962 NULL);
(...skipping 189 matching lines...) Expand 10 before | Expand all | Expand 10 after
1152 EXPECT_TRUE( 1152 EXPECT_TRUE(
1153 browser()->toolbar_model()->WouldPerformSearchTermReplacement(false)); 1153 browser()->toolbar_model()->WouldPerformSearchTermReplacement(false));
1154 EXPECT_EQ(base::ASCIIToUTF16("foobar"), omnibox_view->GetText()); 1154 EXPECT_EQ(base::ASCIIToUTF16("foobar"), omnibox_view->GetText());
1155 } 1155 }
1156 1156
1157 IN_PROC_BROWSER_TEST_F(PolicyTest, Disable3DAPIs) { 1157 IN_PROC_BROWSER_TEST_F(PolicyTest, Disable3DAPIs) {
1158 // This test assumes Gpu access. 1158 // This test assumes Gpu access.
1159 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL)) 1159 if (!content::GpuDataManager::GetInstance()->GpuAccessAllowed(NULL))
1160 return; 1160 return;
1161 1161
1162 ui_test_utils::NavigateToURL(browser(), GURL(content::kAboutBlankURL)); 1162 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1163 // WebGL is enabled by default. 1163 // WebGL is enabled by default.
1164 content::WebContents* contents = 1164 content::WebContents* contents =
1165 browser()->tab_strip_model()->GetActiveWebContents(); 1165 browser()->tab_strip_model()->GetActiveWebContents();
1166 EXPECT_TRUE(IsWebGLEnabled(contents)); 1166 EXPECT_TRUE(IsWebGLEnabled(contents));
1167 // Disable with a policy. 1167 // Disable with a policy.
1168 PolicyMap policies; 1168 PolicyMap policies;
1169 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY, 1169 policies.Set(key::kDisable3DAPIs, POLICY_LEVEL_MANDATORY,
1170 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1170 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL);
1171 UpdateProviderPolicy(policies); 1171 UpdateProviderPolicy(policies);
1172 // Crash and reload the tab to get a new renderer. 1172 // Crash and reload the tab to get a new renderer.
(...skipping 571 matching lines...) Expand 10 before | Expand all | Expand 10 after
1744 // Verifies that the homepage can be configured with policies. 1744 // Verifies that the homepage can be configured with policies.
1745 // Set a default, and check that the home button navigates there. 1745 // Set a default, and check that the home button navigates there.
1746 browser()->profile()->GetPrefs()->SetString( 1746 browser()->profile()->GetPrefs()->SetString(
1747 prefs::kHomePage, chrome::kChromeUIPolicyURL); 1747 prefs::kHomePage, chrome::kChromeUIPolicyURL);
1748 browser()->profile()->GetPrefs()->SetBoolean( 1748 browser()->profile()->GetPrefs()->SetBoolean(
1749 prefs::kHomePageIsNewTabPage, false); 1749 prefs::kHomePageIsNewTabPage, false);
1750 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), 1750 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL),
1751 browser()->profile()->GetHomePage()); 1751 browser()->profile()->GetHomePage());
1752 content::WebContents* contents = 1752 content::WebContents* contents =
1753 browser()->tab_strip_model()->GetActiveWebContents(); 1753 browser()->tab_strip_model()->GetActiveWebContents();
1754 EXPECT_EQ(GURL(content::kAboutBlankURL), contents->GetURL()); 1754 EXPECT_EQ(GURL(url::kAboutBlankURL), contents->GetURL());
1755 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME)); 1755 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_HOME));
1756 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL()); 1756 EXPECT_EQ(GURL(chrome::kChromeUIPolicyURL), contents->GetURL());
1757 1757
1758 // Now override with policy. 1758 // Now override with policy.
1759 PolicyMap policies; 1759 PolicyMap policies;
1760 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY, 1760 policies.Set(key::kHomepageLocation, POLICY_LEVEL_MANDATORY,
1761 POLICY_SCOPE_USER, 1761 POLICY_SCOPE_USER,
1762 base::Value::CreateStringValue(chrome::kChromeUICreditsURL), 1762 base::Value::CreateStringValue(chrome::kChromeUICreditsURL),
1763 NULL); 1763 NULL);
1764 UpdateProviderPolicy(policies); 1764 UpdateProviderPolicy(policies);
(...skipping 44 matching lines...) Expand 10 before | Expand all | Expand 10 after
1809 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); 1809 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS));
1810 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); 1810 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE));
1811 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); 1811 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES));
1812 1812
1813 // Disable Javascript via policy. 1813 // Disable Javascript via policy.
1814 PolicyMap policies; 1814 PolicyMap policies;
1815 policies.Set(key::kJavascriptEnabled, POLICY_LEVEL_MANDATORY, 1815 policies.Set(key::kJavascriptEnabled, POLICY_LEVEL_MANDATORY,
1816 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL); 1816 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(false), NULL);
1817 UpdateProviderPolicy(policies); 1817 UpdateProviderPolicy(policies);
1818 // Reload the page. 1818 // Reload the page.
1819 ui_test_utils::NavigateToURL(browser(), GURL(content::kAboutBlankURL)); 1819 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1820 EXPECT_FALSE(IsJavascriptEnabled(contents)); 1820 EXPECT_FALSE(IsJavascriptEnabled(contents));
1821 // Developer tools still work when javascript is disabled. 1821 // Developer tools still work when javascript is disabled.
1822 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); 1822 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS));
1823 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); 1823 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE));
1824 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES)); 1824 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_DEVICES));
1825 // Javascript is always enabled for the internal pages. 1825 // Javascript is always enabled for the internal pages.
1826 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL)); 1826 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIAboutURL));
1827 EXPECT_TRUE(IsJavascriptEnabled(contents)); 1827 EXPECT_TRUE(IsJavascriptEnabled(contents));
1828 1828
1829 // The javascript content setting policy overrides the javascript policy. 1829 // The javascript content setting policy overrides the javascript policy.
1830 ui_test_utils::NavigateToURL(browser(), GURL(content::kAboutBlankURL)); 1830 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1831 EXPECT_FALSE(IsJavascriptEnabled(contents)); 1831 EXPECT_FALSE(IsJavascriptEnabled(contents));
1832 policies.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY, 1832 policies.Set(key::kDefaultJavaScriptSetting, POLICY_LEVEL_MANDATORY,
1833 POLICY_SCOPE_USER, 1833 POLICY_SCOPE_USER,
1834 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW), NULL); 1834 base::Value::CreateIntegerValue(CONTENT_SETTING_ALLOW), NULL);
1835 UpdateProviderPolicy(policies); 1835 UpdateProviderPolicy(policies);
1836 ui_test_utils::NavigateToURL(browser(), GURL(content::kAboutBlankURL)); 1836 ui_test_utils::NavigateToURL(browser(), GURL(url::kAboutBlankURL));
1837 EXPECT_TRUE(IsJavascriptEnabled(contents)); 1837 EXPECT_TRUE(IsJavascriptEnabled(contents));
1838 } 1838 }
1839 1839
1840 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) { 1840 IN_PROC_BROWSER_TEST_F(PolicyTest, SavingBrowserHistoryDisabled) {
1841 // Verifies that browsing history is not saved. 1841 // Verifies that browsing history is not saved.
1842 PolicyMap policies; 1842 PolicyMap policies;
1843 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY, 1843 policies.Set(key::kSavingBrowserHistoryDisabled, POLICY_LEVEL_MANDATORY,
1844 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL); 1844 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true), NULL);
1845 UpdateProviderPolicy(policies); 1845 UpdateProviderPolicy(policies);
1846 GURL url = ui_test_utils::GetTestUrl( 1846 GURL url = ui_test_utils::GetTestUrl(
(...skipping 787 matching lines...) Expand 10 before | Expand all | Expand 10 after
2634 } 2634 }
2635 }; 2635 };
2636 2636
2637 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) { 2637 IN_PROC_BROWSER_TEST_F(PolicyStatisticsCollectorTest, Startup) {
2638 // Verifies that policy usage histograms are collected at startup. 2638 // Verifies that policy usage histograms are collected at startup.
2639 2639
2640 // BrowserPolicyConnector::Init() has already been called. Make sure the 2640 // BrowserPolicyConnector::Init() has already been called. Make sure the
2641 // CompleteInitialization() task has executed as well. 2641 // CompleteInitialization() task has executed as well.
2642 content::RunAllPendingInMessageLoop(); 2642 content::RunAllPendingInMessageLoop();
2643 2643
2644 GURL kAboutHistograms = GURL(std::string(content::kAboutScheme) + 2644 GURL kAboutHistograms = GURL(std::string(url::kAboutScheme) +
2645 std::string(url::kStandardSchemeSeparator) + 2645 std::string(url::kStandardSchemeSeparator) +
2646 std::string(content::kChromeUIHistogramHost)); 2646 std::string(content::kChromeUIHistogramHost));
2647 ui_test_utils::NavigateToURL(browser(), kAboutHistograms); 2647 ui_test_utils::NavigateToURL(browser(), kAboutHistograms);
2648 content::WebContents* contents = 2648 content::WebContents* contents =
2649 browser()->tab_strip_model()->GetActiveWebContents(); 2649 browser()->tab_strip_model()->GetActiveWebContents();
2650 std::string text; 2650 std::string text;
2651 ASSERT_TRUE(content::ExecuteScriptAndExtractString( 2651 ASSERT_TRUE(content::ExecuteScriptAndExtractString(
2652 contents, 2652 contents,
2653 "var nodes = document.querySelectorAll('body > pre');" 2653 "var nodes = document.querySelectorAll('body > pre');"
2654 "var result = '';" 2654 "var result = '';"
(...skipping 316 matching lines...) Expand 10 before | Expand all | Expand 10 after
2971 PrefService* prefs = browser()->profile()->GetPrefs(); 2971 PrefService* prefs = browser()->profile()->GetPrefs();
2972 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed( 2972 EXPECT_TRUE(extensions::NativeMessageProcessHost::IsHostAllowed(
2973 prefs, "host.name")); 2973 prefs, "host.name"));
2974 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed( 2974 EXPECT_FALSE(extensions::NativeMessageProcessHost::IsHostAllowed(
2975 prefs, "other.host.name")); 2975 prefs, "other.host.name"));
2976 } 2976 }
2977 2977
2978 #endif // !defined(CHROME_OS) 2978 #endif // !defined(CHROME_OS)
2979 2979
2980 } // namespace policy 2980 } // namespace policy
OLDNEW
« no previous file with comments | « chrome/browser/history/in_memory_url_index.cc ('k') | chrome/browser/prerender/prerender_browsertest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698