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

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: Use 'invisible' CSS class name Created 7 years, 11 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 ed75176850c5e3306f5b1c0eb02f7239f967e0e1..bf73e1917c09e1f208a653bf202f9679453ffbdb 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -379,6 +379,17 @@ 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.hidden);",
+ &result));
+ return result;
+}
+
#if defined(OS_CHROMEOS)
// Volume observer mock used by the audio policy tests.
class TestVolumeObserver : public chromeos::AudioHandler::VolumeObserver {
@@ -1090,6 +1101,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 = chrome::GetActiveWebContents(browser());
+
+#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));
+ contents = chrome::GetActiveWebContents(browser());
+ 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) {

Powered by Google App Engine
This is Rietveld 408576698