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

Side by Side Diff: chrome/browser/policy/policy_browsertest.cc

Issue 520703002: Fixed flakyness of PolicyTest.FileURLBlacklist. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove DrMemory exclude Created 6 years, 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | tools/valgrind/gtest_exclude/browser_tests.gtest-drmemory.txt » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
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"
11 #include "base/callback.h" 11 #include "base/callback.h"
12 #include "base/command_line.h" 12 #include "base/command_line.h"
13 #include "base/files/file_enumerator.h" 13 #include "base/files/file_enumerator.h"
14 #include "base/files/file_path.h" 14 #include "base/files/file_path.h"
15 #include "base/files/file_util.h" 15 #include "base/files/file_util.h"
16 #include "base/files/scoped_temp_dir.h" 16 #include "base/files/scoped_temp_dir.h"
17 #include "base/memory/ref_counted.h" 17 #include "base/memory/ref_counted.h"
18 #include "base/path_service.h" 18 #include "base/path_service.h"
19 #include "base/prefs/pref_service.h" 19 #include "base/prefs/pref_service.h"
20 #include "base/run_loop.h" 20 #include "base/run_loop.h"
21 #include "base/strings/string16.h" 21 #include "base/strings/string16.h"
22 #include "base/strings/string_util.h" 22 #include "base/strings/string_util.h"
23 #include "base/strings/stringprintf.h" 23 #include "base/strings/stringprintf.h"
24 #include "base/strings/utf_string_conversions.h" 24 #include "base/strings/utf_string_conversions.h"
25 #include "base/test/test_file_util.h" 25 #include "base/test/test_file_util.h"
26 #include "base/threading/sequenced_worker_pool.h"
26 #include "base/time/time.h" 27 #include "base/time/time.h"
27 #include "base/values.h" 28 #include "base/values.h"
28 #include "chrome/app/chrome_command_ids.h" 29 #include "chrome/app/chrome_command_ids.h"
29 #include "chrome/browser/autocomplete/autocomplete_controller.h" 30 #include "chrome/browser/autocomplete/autocomplete_controller.h"
30 #include "chrome/browser/background/background_contents_service.h" 31 #include "chrome/browser/background/background_contents_service.h"
31 #include "chrome/browser/browser_process.h" 32 #include "chrome/browser/browser_process.h"
32 #include "chrome/browser/chrome_notification_types.h" 33 #include "chrome/browser/chrome_notification_types.h"
33 #include "chrome/browser/content_settings/tab_specific_content_settings.h" 34 #include "chrome/browser/content_settings/tab_specific_content_settings.h"
34 #include "chrome/browser/devtools/devtools_window_testing.h" 35 #include "chrome/browser/devtools/devtools_window_testing.h"
35 #include "chrome/browser/download/download_prefs.h" 36 #include "chrome/browser/download/download_prefs.h"
(...skipping 250 matching lines...) Expand 10 before | Expand all | Expand 10 after
286 }; 287 };
287 288
288 // Verifies that the given url |spec| can be opened. This assumes that |spec| 289 // Verifies that the given url |spec| can be opened. This assumes that |spec|
289 // points at empty.html in the test data dir. 290 // points at empty.html in the test data dir.
290 void CheckCanOpenURL(Browser* browser, const char* spec) { 291 void CheckCanOpenURL(Browser* browser, const char* spec) {
291 GURL url(spec); 292 GURL url(spec);
292 ui_test_utils::NavigateToURL(browser, url); 293 ui_test_utils::NavigateToURL(browser, url);
293 content::WebContents* contents = 294 content::WebContents* contents =
294 browser->tab_strip_model()->GetActiveWebContents(); 295 browser->tab_strip_model()->GetActiveWebContents();
295 EXPECT_EQ(url, contents->GetURL()); 296 EXPECT_EQ(url, contents->GetURL());
296 base::string16 title = base::UTF8ToUTF16(url.spec() + " was blocked"); 297 base::string16 spec16 = base::UTF8ToUTF16(url.spec());
298 base::string16 title =
299 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_BLOCKED, spec16);
297 EXPECT_NE(title, contents->GetTitle()); 300 EXPECT_NE(title, contents->GetTitle());
298 } 301 }
299 302
300 // Verifies that access to the given url |spec| is blocked. 303 // Verifies that access to the given url |spec| is blocked.
301 void CheckURLIsBlocked(Browser* browser, const char* spec) { 304 void CheckURLIsBlocked(Browser* browser, const char* spec) {
302 GURL url(spec); 305 GURL url(spec);
303 ui_test_utils::NavigateToURL(browser, url); 306 ui_test_utils::NavigateToURL(browser, url);
304 content::WebContents* contents = 307 content::WebContents* contents =
305 browser->tab_strip_model()->GetActiveWebContents(); 308 browser->tab_strip_model()->GetActiveWebContents();
306 EXPECT_EQ(url, contents->GetURL()); 309 EXPECT_EQ(url, contents->GetURL());
307 base::string16 title = base::UTF8ToUTF16(url.spec() + " was blocked"); 310 base::string16 spec16 = base::UTF8ToUTF16(url.spec());
311 base::string16 title =
312 l10n_util::GetStringFUTF16(IDS_ERRORPAGES_TITLE_BLOCKED, spec16);
308 EXPECT_EQ(title, contents->GetTitle()); 313 EXPECT_EQ(title, contents->GetTitle());
309 314
310 // Verify that the expected error page is being displayed. 315 // Verify that the expected error page is being displayed.
311 bool result = false; 316 bool result = false;
312 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 317 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
313 contents, 318 contents,
314 "var textContent = document.body.textContent;" 319 "var textContent = document.body.textContent;"
315 "var hasError = textContent.indexOf('ERR_BLOCKED_BY_ADMINISTRATOR') >= 0;" 320 "var hasError = textContent.indexOf('ERR_BLOCKED_BY_ADMINISTRATOR') >= 0;"
316 "domAutomationController.send(hasError);", 321 "domAutomationController.send(hasError);",
317 &result)); 322 &result));
(...skipping 127 matching lines...) Expand 10 before | Expand all | Expand 10 after
445 BrowserThread::IO, FROM_HERE, 450 BrowserThread::IO, FROM_HERE,
446 base::Bind(CountPluginsOnIOThread), 451 base::Bind(CountPluginsOnIOThread),
447 base::Bind(CopyValueAndQuit<int>, &count)); 452 base::Bind(CopyValueAndQuit<int>, &count));
448 content::RunMessageLoop(); 453 content::RunMessageLoop();
449 EXPECT_GE(count, 0); 454 EXPECT_GE(count, 0);
450 return count; 455 return count;
451 } 456 }
452 457
453 void FlushBlacklistPolicy() { 458 void FlushBlacklistPolicy() {
454 // Updates of the URLBlacklist are done on IO, after building the blacklist 459 // Updates of the URLBlacklist are done on IO, after building the blacklist
455 // on FILE, which is initiated from IO. 460 // on the blocking pool, which is initiated from IO.
456 content::RunAllPendingInMessageLoop(BrowserThread::IO); 461 content::RunAllPendingInMessageLoop(BrowserThread::IO);
457 content::RunAllPendingInMessageLoop(BrowserThread::FILE); 462 BrowserThread::GetBlockingPool()->FlushForTesting();
458 content::RunAllPendingInMessageLoop(BrowserThread::IO); 463 content::RunAllPendingInMessageLoop(BrowserThread::IO);
459 } 464 }
460 465
461 bool ContainsVisibleElement(content::WebContents* contents, 466 bool ContainsVisibleElement(content::WebContents* contents,
462 const std::string& id) { 467 const std::string& id) {
463 bool result; 468 bool result;
464 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 469 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
465 contents, 470 contents,
466 "var elem = document.getElementById('" + id + "');" 471 "var elem = document.getElementById('" + id + "');"
467 "domAutomationController.send(!!elem && !elem.hidden);", 472 "domAutomationController.send(!!elem && !elem.hidden);",
(...skipping 2742 matching lines...) Expand 10 before | Expand all | Expand 10 after
3210 EXPECT_TRUE(content::ExecuteScriptAndExtractBool( 3215 EXPECT_TRUE(content::ExecuteScriptAndExtractBool(
3211 browser2->tab_strip_model()->GetActiveWebContents(), 3216 browser2->tab_strip_model()->GetActiveWebContents(),
3212 "domAutomationController.send(window.showModalDialog !== undefined);", 3217 "domAutomationController.send(window.showModalDialog !== undefined);",
3213 &result)); 3218 &result));
3214 EXPECT_TRUE(result); 3219 EXPECT_TRUE(result);
3215 } 3220 }
3216 3221
3217 #endif // !defined(CHROME_OS) 3222 #endif // !defined(CHROME_OS)
3218 3223
3219 } // namespace policy 3224 } // namespace policy
OLDNEW
« no previous file with comments | « no previous file | tools/valgrind/gtest_exclude/browser_tests.gtest-drmemory.txt » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698