Index: chrome/browser/policy/policy_browsertest.cc |
diff --git a/chrome/browser/policy/policy_browsertest.cc b/chrome/browser/policy/policy_browsertest.cc |
index b455aacdb744a3900df031421414f102ee9391d9..468e9c42f5ee0b3057424d1126ec5b98ab9ccd39 100644 |
--- a/chrome/browser/policy/policy_browsertest.cc |
+++ b/chrome/browser/policy/policy_browsertest.cc |
@@ -297,6 +297,21 @@ bool IsWebGLEnabled(content::WebContents* contents) { |
return result; |
} |
+#if defined(OS_CHROMEOS) |
+// Checks if redeeming cros offers is allowed in the given WebContents. |
+bool CheckAllowRedeemCrosOffers(content::WebContents* contents) { |
+ bool result = false; |
+ EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
+ contents, |
+ "chrome.echoPrivate.allowRedeemOffers(" |
+ " function(allow) {" |
+ " domAutomationController.send(allow);" |
+ " });", |
+ &result)); |
+ return result; |
+} |
oscarpan
2013/02/05 05:39:22
Apparently my test failed. It complained "Cannot c
Mattias Nissler (ping if slow)
2013/02/05 13:06:53
Have you made sure the extension is actually loade
oscarpan
2013/02/06 04:34:54
There are some tricky parts. First our extension i
|
+#endif |
+ |
bool IsJavascriptEnabled(content::WebContents* contents) { |
scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( |
contents->GetRenderViewHost(), "123"); |
@@ -1314,6 +1329,29 @@ IN_PROC_BROWSER_TEST_F(PolicyTest, IncognitoEnabled) { |
EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); |
} |
+IN_PROC_BROWSER_TEST_F(PolicyTest, AllowRedeemChromeOsRegistrationOffers) { |
+ content::WebContents* contents = |
+ browser()->tab_strip_model()->GetActiveWebContents(); |
+ EXPECT_TRUE(CheckAllowRedeemCrosOffers(contents)); |
+ |
+ PolicyMap policies; |
+ policies.Set(key::kDeviceAllowRedeemChromeOsRegistrationOffers, |
+ POLICY_LEVEL_MANDATORY, |
+ POLICY_SCOPE_MACHINE, |
+ base::Value::CreateBooleanValue(false)); |
+ |
+ UpdateProviderPolicy(policies); |
+ EXPECT_FALSE(CheckAllowRedeemCrosOffers(contents)); |
+ |
+ policies.Set(key::kDeviceAllowRedeemChromeOsRegistrationOffers, |
+ POLICY_LEVEL_MANDATORY, |
+ POLICY_SCOPE_MACHINE, |
+ base::Value::CreateBooleanValue(true)); |
+ |
+ UpdateProviderPolicy(policies); |
+ EXPECT_TRUE(CheckAllowRedeemCrosOffers(contents)); |
+} |
+ |
IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { |
// Verifies that Javascript can be disabled. |
content::WebContents* contents = |