OLD | NEW |
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/extension_browsertest.h" | 9 #include "chrome/browser/extensions/extension_browsertest.h" |
10 #include "chrome/browser/extensions/extension_host.h" | 10 #include "chrome/browser/extensions/extension_host.h" |
(...skipping 483 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
494 ExtensionsService* service = browser()->profile()->GetExtensionsService(); | 494 ExtensionsService* service = browser()->profile()->GetExtensionsService(); |
495 EXPECT_EQ(0u, service->extensions()->size()); | 495 EXPECT_EQ(0u, service->extensions()->size()); |
496 ASSERT_EQ(1u, service->disabled_extensions()->size()); | 496 ASSERT_EQ(1u, service->disabled_extensions()->size()); |
497 | 497 |
498 // Now try uninstalling it. | 498 // Now try uninstalling it. |
499 UninstallExtension(service->disabled_extensions()->at(0)->id()); | 499 UninstallExtension(service->disabled_extensions()->at(0)->id()); |
500 EXPECT_EQ(0u, service->extensions()->size()); | 500 EXPECT_EQ(0u, service->extensions()->size()); |
501 EXPECT_EQ(0u, service->disabled_extensions()->size()); | 501 EXPECT_EQ(0u, service->disabled_extensions()->size()); |
502 } | 502 } |
503 | 503 |
| 504 // Tests that disabling and re-enabling an extension works. |
| 505 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, DisableEnable) { |
| 506 ExtensionsService* service = browser()->profile()->GetExtensionsService(); |
| 507 ExtensionProcessManager* manager = |
| 508 browser()->profile()->GetExtensionProcessManager(); |
| 509 |
| 510 // Load an extension, expect the toolstrip to be available. |
| 511 ASSERT_TRUE(LoadExtension( |
| 512 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
| 513 .AppendASCII("bjafgdebaacbbbecmhlhpofkepfkgcpa") |
| 514 .AppendASCII("1.0"))); |
| 515 EXPECT_EQ(1u, service->extensions()->size()); |
| 516 EXPECT_EQ(0u, service->disabled_extensions()->size()); |
| 517 EXPECT_TRUE(FindHostWithPath(manager, "/toolstrip.html", 1)); |
| 518 |
| 519 // After disabling, the toolstrip should go away. |
| 520 service->DisableExtension("bjafgdebaacbbbecmhlhpofkepfkgcpa"); |
| 521 EXPECT_EQ(0u, service->extensions()->size()); |
| 522 EXPECT_EQ(1u, service->disabled_extensions()->size()); |
| 523 EXPECT_FALSE(FindHostWithPath(manager, "/toolstrip.html", 0)); |
| 524 |
| 525 // And bring it back. |
| 526 service->EnableExtension("bjafgdebaacbbbecmhlhpofkepfkgcpa"); |
| 527 EXPECT_EQ(1u, service->extensions()->size()); |
| 528 EXPECT_EQ(0u, service->disabled_extensions()->size()); |
| 529 EXPECT_TRUE(FindHostWithPath(manager, "/toolstrip.html", 1)); |
| 530 } |
| 531 |
504 // Helper function for common code shared by the 3 WindowOpen tests below. | 532 // Helper function for common code shared by the 3 WindowOpen tests below. |
505 static TabContents* WindowOpenHelper(Browser* browser, const GURL& start_url, | 533 static TabContents* WindowOpenHelper(Browser* browser, const GURL& start_url, |
506 const std::string& newtab_url) { | 534 const std::string& newtab_url) { |
507 ui_test_utils::NavigateToURL(browser, start_url); | 535 ui_test_utils::NavigateToURL(browser, start_url); |
508 | 536 |
509 bool result = false; | 537 bool result = false; |
510 ui_test_utils::ExecuteJavaScriptAndExtractBool( | 538 ui_test_utils::ExecuteJavaScriptAndExtractBool( |
511 browser->GetSelectedTabContents()->render_view_host(), L"", | 539 browser->GetSelectedTabContents()->render_view_host(), L"", |
512 L"window.open('" + UTF8ToWide(newtab_url) + L"');" | 540 L"window.open('" + UTF8ToWide(newtab_url) + L"');" |
513 L"window.domAutomationController.send(true);", &result); | 541 L"window.domAutomationController.send(true);", &result); |
(...skipping 53 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
567 browser(), | 595 browser(), |
568 GURL("about:blank"), | 596 GURL("about:blank"), |
569 "chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/newtab.html"); | 597 "chrome-extension://aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/newtab.html"); |
570 | 598 |
571 // Extension API should fail. | 599 // Extension API should fail. |
572 bool result = false; | 600 bool result = false; |
573 ui_test_utils::ExecuteJavaScriptAndExtractBool( | 601 ui_test_utils::ExecuteJavaScriptAndExtractBool( |
574 newtab->render_view_host(), L"", L"testExtensionApi()", &result); | 602 newtab->render_view_host(), L"", L"testExtensionApi()", &result); |
575 EXPECT_FALSE(result); | 603 EXPECT_FALSE(result); |
576 } | 604 } |
OLD | NEW |