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

Side by Side Diff: chrome/browser/extensions/content_verifier_browsertest.cc

Issue 2896853005: Fix ContentVerifierTest.FailOnDone and ContentVerifierTest.FailOnRead on Windows 10. (Closed)
Patch Set: add comment Created 3 years, 7 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 | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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 <list> 5 #include <list>
6 #include <set> 6 #include <set>
7 #include <string> 7 #include <string>
8 8
9 #include "base/bind_helpers.h" 9 #include "base/bind_helpers.h"
10 #include "base/callback_helpers.h" 10 #include "base/callback_helpers.h"
11 #include "base/macros.h" 11 #include "base/macros.h"
12 #include "base/memory/ptr_util.h" 12 #include "base/memory/ptr_util.h"
13 #include "base/run_loop.h" 13 #include "base/run_loop.h"
14 #include "base/scoped_observer.h" 14 #include "base/scoped_observer.h"
15 #include "base/strings/string_split.h" 15 #include "base/strings/string_split.h"
16 #include "base/threading/thread_restrictions.h" 16 #include "base/threading/thread_restrictions.h"
17 #include "base/threading/thread_task_runner_handle.h" 17 #include "base/threading/thread_task_runner_handle.h"
18 #include "chrome/browser/extensions/browsertest_util.h" 18 #include "chrome/browser/extensions/browsertest_util.h"
19 #include "chrome/browser/extensions/chrome_content_verifier_delegate.h" 19 #include "chrome/browser/extensions/chrome_content_verifier_delegate.h"
20 #include "chrome/browser/extensions/extension_browsertest.h" 20 #include "chrome/browser/extensions/extension_browsertest.h"
21 #include "chrome/browser/extensions/extension_management_test_util.h" 21 #include "chrome/browser/extensions/extension_management_test_util.h"
22 #include "chrome/browser/extensions/extension_service.h" 22 #include "chrome/browser/extensions/extension_service.h"
23 #include "chrome/browser/extensions/policy_extension_reinstaller.h" 23 #include "chrome/browser/extensions/policy_extension_reinstaller.h"
24 #include "chrome/common/chrome_switches.h" 24 #include "chrome/common/chrome_switches.h"
25 #include "chrome/test/base/ui_test_utils.h"
25 #include "components/policy/core/browser/browser_policy_connector.h" 26 #include "components/policy/core/browser/browser_policy_connector.h"
26 #include "components/policy/core/common/mock_configuration_policy_provider.h" 27 #include "components/policy/core/common/mock_configuration_policy_provider.h"
27 #include "content/public/common/browser_side_navigation_policy.h" 28 #include "content/public/common/browser_side_navigation_policy.h"
28 #include "content/public/test/test_utils.h" 29 #include "content/public/test/test_utils.h"
29 #include "extensions/browser/content_verifier.h" 30 #include "extensions/browser/content_verifier.h"
30 #include "extensions/browser/content_verify_job.h" 31 #include "extensions/browser/content_verify_job.h"
31 #include "extensions/browser/crx_file_info.h" 32 #include "extensions/browser/crx_file_info.h"
32 #include "extensions/browser/extension_prefs.h" 33 #include "extensions/browser/extension_prefs.h"
33 #include "extensions/browser/extension_registry.h" 34 #include "extensions/browser/extension_registry.h"
34 #include "extensions/browser/extension_registry_observer.h" 35 #include "extensions/browser/extension_registry_observer.h"
35 #include "extensions/browser/external_install_info.h" 36 #include "extensions/browser/external_install_info.h"
36 #include "extensions/browser/external_provider_interface.h" 37 #include "extensions/browser/external_provider_interface.h"
37 #include "extensions/browser/management_policy.h" 38 #include "extensions/browser/management_policy.h"
38 #include "extensions/browser/updater/extension_downloader.h" 39 #include "extensions/browser/updater/extension_downloader.h"
39 #include "extensions/browser/updater/extension_downloader_test_delegate.h" 40 #include "extensions/browser/updater/extension_downloader_test_delegate.h"
40 #include "extensions/browser/updater/manifest_fetch_data.h" 41 #include "extensions/browser/updater/manifest_fetch_data.h"
41 #include "extensions/common/extension_urls.h" 42 #include "extensions/common/extension_urls.h"
42 43
43 #if defined(OS_WIN)
44 #include "base/win/windows_version.h"
45 #endif
46
47 namespace extensions { 44 namespace extensions {
48 45
49 namespace { 46 namespace {
50 47
51 // Helper for observing extension registry events. 48 // Helper for observing extension registry events.
52 class RegistryObserver : public ExtensionRegistryObserver { 49 class RegistryObserver : public ExtensionRegistryObserver {
53 public: 50 public:
54 explicit RegistryObserver(ExtensionRegistry* registry) : observer_(this) { 51 explicit RegistryObserver(ExtensionRegistry* registry) : observer_(this) {
55 observer_.Add(registry); 52 observer_.Add(registry);
56 } 53 }
(...skipping 428 matching lines...) Expand 10 before | Expand all | Expand 10 after
485 delegate_.set_id(id); 482 delegate_.set_id(id);
486 483
487 // |unload_observer| needs to destroy before the ExtensionRegistry gets 484 // |unload_observer| needs to destroy before the ExtensionRegistry gets
488 // deleted, which happens before TearDownOnMainThread is called. 485 // deleted, which happens before TearDownOnMainThread is called.
489 RegistryObserver unload_observer(ExtensionRegistry::Get(profile())); 486 RegistryObserver unload_observer(ExtensionRegistry::Get(profile()));
490 const Extension* extension = InstallExtensionFromWebstore( 487 const Extension* extension = InstallExtensionFromWebstore(
491 test_data_dir_.AppendASCII("content_verifier/v1.crx"), 1); 488 test_data_dir_.AppendASCII("content_verifier/v1.crx"), 1);
492 ASSERT_TRUE(extension); 489 ASSERT_TRUE(extension);
493 ASSERT_EQ(id, extension->id()); 490 ASSERT_EQ(id, extension->id());
494 page_url_ = extension->GetResourceURL("page.html"); 491 page_url_ = extension->GetResourceURL("page.html");
495 492 // Wait for 0 navigations to complete because with PlzNavigate it's racy
496 // This call passes false for |check_navigation_success|, because checking 493 // when the didstop IPC arrives relative to the tab being closed. The
497 // for navigation success needs the WebContents to still exist after the 494 // wait call below is what the tests care about.
498 // navigation, whereas this navigation triggers an unload which destroys 495 ui_test_utils::NavigateToURLWithDispositionBlockUntilNavigationsComplete(
499 // the WebContents. 496 browser(), page_url_, 0, WindowOpenDisposition::NEW_FOREGROUND_TAB,
500 AddTabAtIndexToBrowser(browser(), 1, page_url_, ui::PAGE_TRANSITION_LINK, 497 ui_test_utils::BROWSER_TEST_NONE);
501 false);
502 498
503 EXPECT_TRUE(unload_observer.WaitForUnload(id)); 499 EXPECT_TRUE(unload_observer.WaitForUnload(id));
504 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile()); 500 ExtensionPrefs* prefs = ExtensionPrefs::Get(profile());
505 int reasons = prefs->GetDisableReasons(id); 501 int reasons = prefs->GetDisableReasons(id);
506 EXPECT_TRUE(reasons & Extension::DISABLE_CORRUPTED); 502 EXPECT_TRUE(reasons & Extension::DISABLE_CORRUPTED);
507 } 503 }
508 504
509 void TestContentScriptExtension(const std::string& crx_relpath, 505 void TestContentScriptExtension(const std::string& crx_relpath,
510 const std::string& id, 506 const std::string& id,
511 const std::string& script_relpath) { 507 const std::string& script_relpath) {
(...skipping 41 matching lines...) Expand 10 before | Expand all | Expand 10 after
553 EnableExtension(id); 549 EnableExtension(id);
554 EXPECT_TRUE(job_observer.WaitForExpectedJobs()); 550 EXPECT_TRUE(job_observer.WaitForExpectedJobs());
555 } 551 }
556 552
557 protected: 553 protected:
558 JobDelegate delegate_; 554 JobDelegate delegate_;
559 GURL page_url_; 555 GURL page_url_;
560 }; 556 };
561 557
562 IN_PROC_BROWSER_TEST_F(ContentVerifierTest, FailOnRead) { 558 IN_PROC_BROWSER_TEST_F(ContentVerifierTest, FailOnRead) {
563 #if defined(OS_WIN)
564 if (content::IsBrowserSideNavigationEnabled() &&
565 base::win::GetVersion() >= base::win::VERSION_WIN10) {
566 // http://crbug.com/699437
567 return;
568 }
569 #endif
570 EXPECT_EQ(0, delegate_.bytes_read_failed()); 559 EXPECT_EQ(0, delegate_.bytes_read_failed());
571 delegate_.fail_next_read(); 560 delegate_.fail_next_read();
572 OpenPageAndWaitForUnload(); 561 OpenPageAndWaitForUnload();
573 EXPECT_EQ(1, delegate_.bytes_read_failed()); 562 EXPECT_EQ(1, delegate_.bytes_read_failed());
574 } 563 }
575 564
576 IN_PROC_BROWSER_TEST_F(ContentVerifierTest, FailOnDone) { 565 IN_PROC_BROWSER_TEST_F(ContentVerifierTest, FailOnDone) {
577 #if defined(OS_WIN)
578 if (content::IsBrowserSideNavigationEnabled() &&
579 base::win::GetVersion() >= base::win::VERSION_WIN10) {
580 // http://crbug.com/699437
581 return;
582 }
583 #endif
584 EXPECT_EQ(0, delegate_.done_reading_failed()); 566 EXPECT_EQ(0, delegate_.done_reading_failed());
585 delegate_.fail_next_done(); 567 delegate_.fail_next_done();
586 OpenPageAndWaitForUnload(); 568 OpenPageAndWaitForUnload();
587 EXPECT_EQ(1, delegate_.done_reading_failed()); 569 EXPECT_EQ(1, delegate_.done_reading_failed());
588 } 570 }
589 571
590 IN_PROC_BROWSER_TEST_F(ContentVerifierTest, DotSlashPaths) { 572 IN_PROC_BROWSER_TEST_F(ContentVerifierTest, DotSlashPaths) {
591 JobObserver job_observer; 573 JobObserver job_observer;
592 std::string id = "hoipipabpcoomfapcecilckodldhmpgl"; 574 std::string id = "hoipipabpcoomfapcecilckodldhmpgl";
593 575
(...skipping 309 matching lines...) Expand 10 before | Expand all | Expand 10 after
903 // Remove the override and set ExtensionService to update again. The extension 885 // Remove the override and set ExtensionService to update again. The extension
904 // should be now installed. 886 // should be now installed.
905 PolicyExtensionReinstaller::set_policy_reinstall_action_for_test(nullptr); 887 PolicyExtensionReinstaller::set_policy_reinstall_action_for_test(nullptr);
906 service->set_external_updates_disabled_for_test(false); 888 service->set_external_updates_disabled_for_test(false);
907 delay_tracker.Proceed(); 889 delay_tracker.Proceed();
908 890
909 EXPECT_TRUE(registry_observer.WaitForInstall(id_)); 891 EXPECT_TRUE(registry_observer.WaitForInstall(id_));
910 } 892 }
911 893
912 } // namespace extensions 894 } // namespace extensions
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698