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

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

Issue 466012: Don't ping for extension blacklist when no extensions are installed.... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 11 years 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 | Annotate | Revision Log
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_updater.cc » ('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) 2009 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2009 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 "base/ref_counted.h" 5 #include "base/ref_counted.h"
6 #include "chrome/browser/browser.h" 6 #include "chrome/browser/browser.h"
7 #include "chrome/browser/browser_list.h" 7 #include "chrome/browser/browser_list.h"
8 #include "chrome/browser/renderer_host/render_view_host.h" 8 #include "chrome/browser/renderer_host/render_view_host.h"
9 #include "chrome/browser/extensions/autoupdate_interceptor.h" 9 #include "chrome/browser/extensions/autoupdate_interceptor.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 10 #include "chrome/browser/extensions/extension_browsertest.h"
(...skipping 601 matching lines...) Expand 10 before | Expand all | Expand 10 after
612 service->EnableExtension(service->disabled_extensions()->at(0)->id()); 612 service->EnableExtension(service->disabled_extensions()->at(0)->id());
613 EXPECT_EQ(0, contents->infobar_delegate_count()); 613 EXPECT_EQ(0, contents->infobar_delegate_count());
614 EXPECT_EQ(1u, service->extensions()->size()); 614 EXPECT_EQ(1u, service->extensions()->size());
615 EXPECT_EQ(0u, service->disabled_extensions()->size()); 615 EXPECT_EQ(0u, service->disabled_extensions()->size());
616 } 616 }
617 #endif 617 #endif
618 618
619 // Tests that we can uninstall a disabled extension. 619 // Tests that we can uninstall a disabled extension.
620 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, UninstallDisabled) { 620 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, UninstallDisabled) {
621 // Install and upgrade, so that we have a disabled extension. 621 // Install and upgrade, so that we have a disabled extension.
622 ExtensionsService* service = browser()->profile()->GetExtensionsService();
623 ASSERT_FALSE(service->HasInstalledExtensions());
622 ASSERT_TRUE(InstallExtension( 624 ASSERT_TRUE(InstallExtension(
623 test_data_dir_.AppendASCII("permissions-low-v1.crx"), 1)); 625 test_data_dir_.AppendASCII("permissions-low-v1.crx"), 1));
626 ASSERT_TRUE(service->HasInstalledExtensions());
624 ASSERT_TRUE(UpdateExtension("pgdpcfcocojkjfbgpiianjngphoopgmo", 627 ASSERT_TRUE(UpdateExtension("pgdpcfcocojkjfbgpiianjngphoopgmo",
625 test_data_dir_.AppendASCII("permissions-high-v2.crx"), -1)); 628 test_data_dir_.AppendASCII("permissions-high-v2.crx"), -1));
626 629
627 ExtensionsService* service = browser()->profile()->GetExtensionsService();
628 EXPECT_EQ(0u, service->extensions()->size()); 630 EXPECT_EQ(0u, service->extensions()->size());
629 ASSERT_EQ(1u, service->disabled_extensions()->size()); 631 ASSERT_EQ(1u, service->disabled_extensions()->size());
632 ASSERT_TRUE(service->HasInstalledExtensions());
630 633
631 // Now try uninstalling it. 634 // Now try uninstalling it.
632 UninstallExtension(service->disabled_extensions()->at(0)->id()); 635 UninstallExtension(service->disabled_extensions()->at(0)->id());
633 EXPECT_EQ(0u, service->extensions()->size()); 636 EXPECT_EQ(0u, service->extensions()->size());
634 EXPECT_EQ(0u, service->disabled_extensions()->size()); 637 EXPECT_EQ(0u, service->disabled_extensions()->size());
638 ASSERT_FALSE(service->HasInstalledExtensions());
635 } 639 }
636 640
637 // Tests that disabling and re-enabling an extension works. 641 // Tests that disabling and re-enabling an extension works.
638 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DisableEnable) { 642 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DisableEnable) {
639 ExtensionsService* service = browser()->profile()->GetExtensionsService(); 643 ExtensionsService* service = browser()->profile()->GetExtensionsService();
640 ExtensionProcessManager* manager = 644 ExtensionProcessManager* manager =
641 browser()->profile()->GetExtensionProcessManager(); 645 browser()->profile()->GetExtensionProcessManager();
642 646
643 // Load an extension, expect the toolstrip to be available. 647 // Load an extension, expect the toolstrip to be available.
648 ASSERT_FALSE(service->HasInstalledExtensions());
644 ASSERT_TRUE(LoadExtension( 649 ASSERT_TRUE(LoadExtension(
645 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 650 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
646 .AppendASCII("bjafgdebaacbbbecmhlhpofkepfkgcpa") 651 .AppendASCII("bjafgdebaacbbbecmhlhpofkepfkgcpa")
647 .AppendASCII("1.0"))); 652 .AppendASCII("1.0")));
648 EXPECT_EQ(1u, service->extensions()->size()); 653 EXPECT_EQ(1u, service->extensions()->size());
649 EXPECT_EQ(0u, service->disabled_extensions()->size()); 654 EXPECT_EQ(0u, service->disabled_extensions()->size());
650 EXPECT_TRUE(FindHostWithPath(manager, "/toolstrip.html", 1)); 655 EXPECT_TRUE(FindHostWithPath(manager, "/toolstrip.html", 1));
656 ASSERT_TRUE(service->HasInstalledExtensions());
651 657
652 // After disabling, the toolstrip should go away. 658 // After disabling, the toolstrip should go away.
653 service->DisableExtension("bjafgdebaacbbbecmhlhpofkepfkgcpa"); 659 service->DisableExtension("bjafgdebaacbbbecmhlhpofkepfkgcpa");
654 EXPECT_EQ(0u, service->extensions()->size()); 660 EXPECT_EQ(0u, service->extensions()->size());
655 EXPECT_EQ(1u, service->disabled_extensions()->size()); 661 EXPECT_EQ(1u, service->disabled_extensions()->size());
656 EXPECT_FALSE(FindHostWithPath(manager, "/toolstrip.html", 0)); 662 EXPECT_FALSE(FindHostWithPath(manager, "/toolstrip.html", 0));
663 ASSERT_TRUE(service->HasInstalledExtensions());
657 664
658 // And bring it back. 665 // And bring it back.
659 service->EnableExtension("bjafgdebaacbbbecmhlhpofkepfkgcpa"); 666 service->EnableExtension("bjafgdebaacbbbecmhlhpofkepfkgcpa");
660 EXPECT_EQ(1u, service->extensions()->size()); 667 EXPECT_EQ(1u, service->extensions()->size());
661 EXPECT_EQ(0u, service->disabled_extensions()->size()); 668 EXPECT_EQ(0u, service->disabled_extensions()->size());
662 EXPECT_TRUE(FindHostWithPath(manager, "/toolstrip.html", 1)); 669 EXPECT_TRUE(FindHostWithPath(manager, "/toolstrip.html", 1));
670 ASSERT_TRUE(service->HasInstalledExtensions());
663 } 671 }
664 672
665 // Helper function for common code shared by the 3 WindowOpen tests below. 673 // Helper function for common code shared by the 3 WindowOpen tests below.
666 static TabContents* WindowOpenHelper(Browser* browser, const GURL& start_url, 674 static TabContents* WindowOpenHelper(Browser* browser, const GURL& start_url,
667 const std::string& newtab_url) { 675 const std::string& newtab_url) {
668 ui_test_utils::NavigateToURL(browser, start_url); 676 ui_test_utils::NavigateToURL(browser, start_url);
669 677
670 bool result = false; 678 bool result = false;
671 ui_test_utils::ExecuteJavaScriptAndExtractBool( 679 ui_test_utils::ExecuteJavaScriptAndExtractBool(
672 browser->GetSelectedTabContents()->render_view_host(), L"", 680 browser->GetSelectedTabContents()->render_view_host(), L"",
(...skipping 123 matching lines...) Expand 10 before | Expand all | Expand 10 after
796 // Note: This interceptor gets requests on the IO thread. 804 // Note: This interceptor gets requests on the IO thread.
797 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor()); 805 scoped_refptr<AutoUpdateInterceptor> interceptor(new AutoUpdateInterceptor());
798 URLFetcher::enable_interception_for_tests(true); 806 URLFetcher::enable_interception_for_tests(true);
799 807
800 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest", 808 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/manifest",
801 basedir.AppendASCII("manifest_v2.xml")); 809 basedir.AppendASCII("manifest_v2.xml"));
802 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx", 810 interceptor->SetResponseOnIOThread("http://localhost/autoupdate/v2.crx",
803 basedir.AppendASCII("v2.crx")); 811 basedir.AppendASCII("v2.crx"));
804 812
805 // Install version 1 of the extension. 813 // Install version 1 of the extension.
814 ExtensionsService* service = browser()->profile()->GetExtensionsService();
815 ASSERT_FALSE(service->HasInstalledExtensions());
806 ASSERT_TRUE(InstallExtension(basedir.AppendASCII("v1.crx"), 1)); 816 ASSERT_TRUE(InstallExtension(basedir.AppendASCII("v1.crx"), 1));
807 ExtensionsService* service = browser()->profile()->GetExtensionsService();
808 const ExtensionList* extensions = service->extensions(); 817 const ExtensionList* extensions = service->extensions();
818 ASSERT_TRUE(service->HasInstalledExtensions());
809 ASSERT_EQ(1u, extensions->size()); 819 ASSERT_EQ(1u, extensions->size());
810 ASSERT_EQ("ogjcoiohnmldgjemafoockdghcjciccf", extensions->at(0)->id()); 820 ASSERT_EQ("ogjcoiohnmldgjemafoockdghcjciccf", extensions->at(0)->id());
811 ASSERT_EQ("1.0", extensions->at(0)->VersionString()); 821 ASSERT_EQ("1.0", extensions->at(0)->VersionString());
812 822
813 // We don't want autoupdate blacklist checks. 823 // We don't want autoupdate blacklist checks.
814 service->updater()->set_blacklist_checks_enabled(false); 824 service->updater()->set_blacklist_checks_enabled(false);
815 825
816 // Run autoupdate and make sure version 2 of the extension was installed. 826 // Run autoupdate and make sure version 2 of the extension was installed.
817 service->updater()->CheckNow(); 827 service->updater()->CheckNow();
818 ASSERT_TRUE(WaitForExtensionInstall()); 828 ASSERT_TRUE(WaitForExtensionInstall());
(...skipping 50 matching lines...) Expand 10 before | Expand all | Expand 10 after
869 879
870 // If the options page hasn't already come up, wait for it. 880 // If the options page hasn't already come up, wait for it.
871 if (tab_strip->count() == 1) { 881 if (tab_strip->count() == 1) {
872 ui_test_utils::WaitForNewTab(browser()); 882 ui_test_utils::WaitForNewTab(browser());
873 } 883 }
874 ASSERT_EQ(2, tab_strip->count()); 884 ASSERT_EQ(2, tab_strip->count());
875 885
876 EXPECT_EQ(extension->GetResourceURL("options.html"), 886 EXPECT_EQ(extension->GetResourceURL("options.html"),
877 tab_strip->GetTabContentsAt(1)->GetURL()); 887 tab_strip->GetTabContentsAt(1)->GetURL());
878 } 888 }
OLDNEW
« no previous file with comments | « no previous file | chrome/browser/extensions/extension_updater.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698