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

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: comments 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 3cc86dbb062026ab1ab2bd24a8fcefc0e065e2d8..8ad043e2e95dcb0feab82a897d1e8d27206bb9e9 100644
--- a/chrome/browser/policy/policy_browsertest.cc
+++ b/chrome/browser/policy/policy_browsertest.cc
@@ -389,6 +389,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 {
@@ -1118,6 +1129,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