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

Unified Diff: chrome/browser/policy/policy_browsertest.cc

Issue 11859029: Add a policy to hide the Web Store on new tabs. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: rebase Created 7 years, 10 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 side-by-side diff with in-line comments
Download patch
Index: chrome/browser/policy/policy_browsertest.cc
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc
index 57206ff96aa7a0c507ffe39476bb4acdd8ac8925..04c68adb43f457a30bd2306e47ff07439dcfa414 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -389,6 +389,18 @@ void FlushBlacklistPolicy() {
content::RunAllPendingInMessageLoop(BrowserThread::IO);
}
+bool ContainsVisibleElement(content::WebContents* contents,
+ const std::string& id) {
+ bool result;
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
+ contents,
+ "var elem = document.getElementById('" + id + "');"
+ "domAutomationController.send("
+ " !!elem && !elem.classList.contains('invisible'));",
+ &result));
+ return result;
+}
+
#if defined(OS_CHROMEOS)
// Volume observer mock used by the audio policy tests.
class TestVolumeObserver : public chromeos::AudioHandler::VolumeObserver {
@@ -1118,6 +1130,37 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, DeveloperToolsDisabled) {
EXPECT_FALSE(DevToolsWindow::GetDockedInstanceForInspectedTab(contents));
}
+IN_PROC_BROWSER_TEST_F(PolicyTest, WebStoreIconHidden) {
+ // Verifies that the web store icons can be hidden from the new tab page.
+
+ // Open new tab page and look for the web store icons.
+ ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
+ content::WebContents* contents =
+ browser()->tab_strip_model()->GetActiveWebContents();
+
+#if !defined(OS_CHROMEOS)
+ // Look for web store's app ID in the apps page.
+ EXPECT_TRUE(ContainsVisibleElement(contents,
+ "ahfgeienlihckogmohjhadlkjgocpleb"));
+#endif
+
+ // The next NTP has no footer.
+ if (ContainsVisibleElement(contents, "footer"))
+ EXPECT_TRUE(ContainsVisibleElement(contents, "chrome-web-store-link"));
+
+ // Turn off the web store icons.
+ PolicyMap policies;
+ policies.Set(key::kHideWebStoreIcon, POLICY_LEVEL_MANDATORY,
+ POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true));
+ UpdateProviderPolicy(policies);
+
+ // The web store icons should now be hidden.
+ ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUINewTabURL));
+ EXPECT_FALSE(ContainsVisibleElement(contents,
+ "ahfgeienlihckogmohjhadlkjgocpleb"));
+ EXPECT_FALSE(ContainsVisibleElement(contents, "chrome-web-store-link"));
+}
+
// This policy isn't available on Chrome OS.
#if !defined(OS_CHROMEOS)
IN_PROC_BROWSER_TEST_F(PolicyTest, DownloadDirectory) {
« no previous file with comments | « chrome/browser/policy/configuration_policy_pref_store_unittest.cc ('k') | chrome/browser/resources/ntp4/new_tab.js » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698