Chromium Code Reviews| OLD | NEW |
|---|---|
| 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 279 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 290 bool result = false; | 290 bool result = false; |
| 291 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 291 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 292 contents, | 292 contents, |
| 293 "var canvas = document.createElement('canvas');" | 293 "var canvas = document.createElement('canvas');" |
| 294 "var context = canvas.getContext('experimental-webgl');" | 294 "var context = canvas.getContext('experimental-webgl');" |
| 295 "domAutomationController.send(context != null);", | 295 "domAutomationController.send(context != null);", |
| 296 &result)); | 296 &result)); |
| 297 return result; | 297 return result; |
| 298 } | 298 } |
| 299 | 299 |
| 300 #if defined(OS_CHROMEOS) | |
| 301 // Checks if redeeming cros offers is allowed in the given WebContents. | |
| 302 bool CheckAllowRedeemCrosOffers(content::WebContents* contents) { | |
| 303 bool result = false; | |
| 304 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | |
| 305 contents, | |
| 306 "chrome.echoPrivate.allowRedeemOffers(" | |
| 307 " function(allow) {" | |
| 308 " domAutomationController.send(allow);" | |
| 309 " });", | |
| 310 &result)); | |
| 311 return result; | |
| 312 } | |
|
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
| |
| 313 #endif | |
| 314 | |
| 300 bool IsJavascriptEnabled(content::WebContents* contents) { | 315 bool IsJavascriptEnabled(content::WebContents* contents) { |
| 301 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( | 316 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( |
| 302 contents->GetRenderViewHost(), "123"); | 317 contents->GetRenderViewHost(), "123"); |
| 303 int result = 0; | 318 int result = 0; |
| 304 if (!value->GetAsInteger(&result)) | 319 if (!value->GetAsInteger(&result)) |
| 305 EXPECT_EQ(base::Value::TYPE_NULL, value->GetType()); | 320 EXPECT_EQ(base::Value::TYPE_NULL, value->GetType()); |
| 306 return result == 123; | 321 return result == 123; |
| 307 } | 322 } |
| 308 | 323 |
| 309 void CopyPluginListAndQuit(std::vector<webkit::WebPluginInfo>* out, | 324 void CopyPluginListAndQuit(std::vector<webkit::WebPluginInfo>* out, |
| (...skipping 997 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1307 | 1322 |
| 1308 // Enable via policy and verify that incognito windows can be opened. | 1323 // Enable via policy and verify that incognito windows can be opened. |
| 1309 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, | 1324 policies.Set(key::kIncognitoEnabled, POLICY_LEVEL_MANDATORY, |
| 1310 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); | 1325 POLICY_SCOPE_USER, base::Value::CreateBooleanValue(true)); |
| 1311 UpdateProviderPolicy(policies); | 1326 UpdateProviderPolicy(policies); |
| 1312 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); | 1327 EXPECT_TRUE(chrome::ExecuteCommand(browser(), IDC_NEW_INCOGNITO_WINDOW)); |
| 1313 EXPECT_EQ(2u, BrowserList::size()); | 1328 EXPECT_EQ(2u, BrowserList::size()); |
| 1314 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); | 1329 EXPECT_TRUE(BrowserList::IsOffTheRecordSessionActive()); |
| 1315 } | 1330 } |
| 1316 | 1331 |
| 1332 IN_PROC_BROWSER_TEST_F(PolicyTest, AllowRedeemChromeOsRegistrationOffers) { | |
| 1333 content::WebContents* contents = | |
| 1334 browser()->tab_strip_model()->GetActiveWebContents(); | |
| 1335 EXPECT_TRUE(CheckAllowRedeemCrosOffers(contents)); | |
| 1336 | |
| 1337 PolicyMap policies; | |
| 1338 policies.Set(key::kDeviceAllowRedeemChromeOsRegistrationOffers, | |
| 1339 POLICY_LEVEL_MANDATORY, | |
| 1340 POLICY_SCOPE_MACHINE, | |
| 1341 base::Value::CreateBooleanValue(false)); | |
| 1342 | |
| 1343 UpdateProviderPolicy(policies); | |
| 1344 EXPECT_FALSE(CheckAllowRedeemCrosOffers(contents)); | |
| 1345 | |
| 1346 policies.Set(key::kDeviceAllowRedeemChromeOsRegistrationOffers, | |
| 1347 POLICY_LEVEL_MANDATORY, | |
| 1348 POLICY_SCOPE_MACHINE, | |
| 1349 base::Value::CreateBooleanValue(true)); | |
| 1350 | |
| 1351 UpdateProviderPolicy(policies); | |
| 1352 EXPECT_TRUE(CheckAllowRedeemCrosOffers(contents)); | |
| 1353 } | |
| 1354 | |
| 1317 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { | 1355 IN_PROC_BROWSER_TEST_F(PolicyTest, Javascript) { |
| 1318 // Verifies that Javascript can be disabled. | 1356 // Verifies that Javascript can be disabled. |
| 1319 content::WebContents* contents = | 1357 content::WebContents* contents = |
| 1320 browser()->tab_strip_model()->GetActiveWebContents(); | 1358 browser()->tab_strip_model()->GetActiveWebContents(); |
| 1321 EXPECT_TRUE(IsJavascriptEnabled(contents)); | 1359 EXPECT_TRUE(IsJavascriptEnabled(contents)); |
| 1322 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); | 1360 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS)); |
| 1323 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); | 1361 EXPECT_TRUE(chrome::IsCommandEnabled(browser(), IDC_DEV_TOOLS_CONSOLE)); |
| 1324 | 1362 |
| 1325 // Disable Javascript via policy. | 1363 // Disable Javascript via policy. |
| 1326 PolicyMap policies; | 1364 PolicyMap policies; |
| (...skipping 545 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1872 this)); | 1910 this)); |
| 1873 | 1911 |
| 1874 MessageLoop::current()->Run(); | 1912 MessageLoop::current()->Run(); |
| 1875 } | 1913 } |
| 1876 | 1914 |
| 1877 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, | 1915 INSTANTIATE_TEST_CASE_P(MediaStreamDevicesControllerBrowserTestInstance, |
| 1878 MediaStreamDevicesControllerBrowserTest, | 1916 MediaStreamDevicesControllerBrowserTest, |
| 1879 testing::Bool()); | 1917 testing::Bool()); |
| 1880 | 1918 |
| 1881 } // namespace policy | 1919 } // namespace policy |
| OLD | NEW |