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 285 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 296 bool result = false; | 296 bool result = false; |
| 297 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 297 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 298 contents, | 298 contents, |
| 299 "var textContent = document.body.textContent;" | 299 "var textContent = document.body.textContent;" |
| 300 "var hasError = textContent.indexOf('ERR_BLOCKED_BY_ADMINISTRATOR') >= 0;" | 300 "var hasError = textContent.indexOf('ERR_BLOCKED_BY_ADMINISTRATOR') >= 0;" |
| 301 "domAutomationController.send(hasError);", | 301 "domAutomationController.send(hasError);", |
| 302 &result)); | 302 &result)); |
| 303 EXPECT_TRUE(result); | 303 EXPECT_TRUE(result); |
| 304 } | 304 } |
| 305 | 305 |
| 306 #if !defined(OS_CHROMEOS) | |
| 306 // Downloads a file named |file| and expects it to be saved to |dir|, which | 307 // Downloads a file named |file| and expects it to be saved to |dir|, which |
| 307 // must be empty. | 308 // must be empty. |
| 308 void DownloadAndVerifyFile( | 309 void DownloadAndVerifyFile( |
| 309 Browser* browser, const base::FilePath& dir, const base::FilePath& file) { | 310 Browser* browser, const base::FilePath& dir, const base::FilePath& file) { |
| 310 content::DownloadManager* download_manager = | 311 content::DownloadManager* download_manager = |
| 311 content::BrowserContext::GetDownloadManager(browser->profile()); | 312 content::BrowserContext::GetDownloadManager(browser->profile()); |
| 312 content::DownloadTestObserverTerminal observer( | 313 content::DownloadTestObserverTerminal observer( |
| 313 download_manager, 1, | 314 download_manager, 1, |
| 314 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); | 315 content::DownloadTestObserver::ON_DANGEROUS_DOWNLOAD_FAIL); |
| 315 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); | 316 GURL url(URLRequestMockHTTPJob::GetMockUrl(file)); |
| 316 base::FilePath downloaded = dir.Append(file); | 317 base::FilePath downloaded = dir.Append(file); |
| 317 EXPECT_FALSE(base::PathExists(downloaded)); | 318 EXPECT_FALSE(base::PathExists(downloaded)); |
| 318 ui_test_utils::NavigateToURLWithDisposition( | 319 ui_test_utils::NavigateToURLWithDisposition( |
| 319 browser, url, CURRENT_TAB, | 320 browser, url, CURRENT_TAB, |
| 320 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); | 321 ui_test_utils::BROWSER_TEST_WAIT_FOR_NAVIGATION); |
| 321 observer.WaitForFinished(); | 322 observer.WaitForFinished(); |
| 322 EXPECT_EQ( | 323 EXPECT_EQ( |
| 323 1u, observer.NumDownloadsSeenInState(content::DownloadItem::COMPLETE)); | 324 1u, observer.NumDownloadsSeenInState(content::DownloadItem::COMPLETE)); |
| 324 EXPECT_TRUE(base::PathExists(downloaded)); | 325 EXPECT_TRUE(base::PathExists(downloaded)); |
| 325 base::FileEnumerator enumerator(dir, false, base::FileEnumerator::FILES); | 326 base::FileEnumerator enumerator(dir, false, base::FileEnumerator::FILES); |
| 326 EXPECT_EQ(file, enumerator.Next().BaseName()); | 327 EXPECT_EQ(file, enumerator.Next().BaseName()); |
| 327 EXPECT_EQ(base::FilePath(), enumerator.Next()); | 328 EXPECT_EQ(base::FilePath(), enumerator.Next()); |
| 328 } | 329 } |
| 330 #endif | |
| 329 | 331 |
| 330 #if defined(OS_CHROMEOS) | 332 #if defined(OS_CHROMEOS) |
|
Nico
2013/11/10 05:07:09
Maybe make the previous 3 lines an #else?
hans
2013/11/11 19:29:51
Done.
| |
| 331 int CountScreenshots() { | 333 int CountScreenshots() { |
| 332 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( | 334 DownloadPrefs* download_prefs = DownloadPrefs::FromBrowserContext( |
| 333 ash::Shell::GetInstance()->delegate()->GetCurrentBrowserContext()); | 335 ash::Shell::GetInstance()->delegate()->GetCurrentBrowserContext()); |
| 334 base::FileEnumerator enumerator(download_prefs->DownloadPath(), | 336 base::FileEnumerator enumerator(download_prefs->DownloadPath(), |
| 335 false, base::FileEnumerator::FILES, | 337 false, base::FileEnumerator::FILES, |
| 336 "Screenshot*"); | 338 "Screenshot*"); |
| 337 int count = 0; | 339 int count = 0; |
| 338 while (!enumerator.Next().empty()) | 340 while (!enumerator.Next().empty()) |
| 339 count++; | 341 count++; |
| 340 return count; | 342 return count; |
| 341 } | 343 } |
| 342 #endif | 344 #endif |
| 343 | 345 |
| 344 // Checks if WebGL is enabled in the given WebContents. | 346 // Checks if WebGL is enabled in the given WebContents. |
| 347 #if defined(OS_MACOSX) | |
| 345 bool IsWebGLEnabled(content::WebContents* contents) { | 348 bool IsWebGLEnabled(content::WebContents* contents) { |
| 346 bool result = false; | 349 bool result = false; |
| 347 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( | 350 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( |
| 348 contents, | 351 contents, |
| 349 "var canvas = document.createElement('canvas');" | 352 "var canvas = document.createElement('canvas');" |
| 350 "var context = canvas.getContext('experimental-webgl');" | 353 "var context = canvas.getContext('experimental-webgl');" |
| 351 "domAutomationController.send(context != null);", | 354 "domAutomationController.send(context != null);", |
| 352 &result)); | 355 &result)); |
| 353 return result; | 356 return result; |
| 354 } | 357 } |
| 358 #endif // defined(OS_MACOSX) | |
| 355 | 359 |
| 356 bool IsJavascriptEnabled(content::WebContents* contents) { | 360 bool IsJavascriptEnabled(content::WebContents* contents) { |
| 357 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( | 361 scoped_ptr<base::Value> value = content::ExecuteScriptAndGetValue( |
| 358 contents->GetRenderViewHost(), "123"); | 362 contents->GetRenderViewHost(), "123"); |
| 359 int result = 0; | 363 int result = 0; |
| 360 if (!value->GetAsInteger(&result)) | 364 if (!value->GetAsInteger(&result)) |
| 361 EXPECT_EQ(base::Value::TYPE_NULL, value->GetType()); | 365 EXPECT_EQ(base::Value::TYPE_NULL, value->GetType()); |
| 362 return result == 123; | 366 return result == 123; |
| 363 } | 367 } |
| 364 | 368 |
| (...skipping 2467 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 2832 chrome_variations::VariationsService::GetVariationsServerURL( | 2836 chrome_variations::VariationsService::GetVariationsServerURL( |
| 2833 g_browser_process->local_state()); | 2837 g_browser_process->local_state()); |
| 2834 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); | 2838 EXPECT_TRUE(StartsWithASCII(url.spec(), default_variations_url, true)); |
| 2835 std::string value; | 2839 std::string value; |
| 2836 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); | 2840 EXPECT_TRUE(net::GetValueForKeyInQuery(url, "restrict", &value)); |
| 2837 EXPECT_EQ("restricted", value); | 2841 EXPECT_EQ("restricted", value); |
| 2838 } | 2842 } |
| 2839 #endif | 2843 #endif |
| 2840 | 2844 |
| 2841 } // namespace policy | 2845 } // namespace policy |
| OLD | NEW |