OLD | NEW |
1 // Copyright (c) 2010 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2010 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 723 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
734 | 734 |
735 ExtensionsService* service = browser()->profile()->GetExtensionsService(); | 735 ExtensionsService* service = browser()->profile()->GetExtensionsService(); |
736 const size_t size_before = service->extensions()->size(); | 736 const size_t size_before = service->extensions()->size(); |
737 ASSERT_TRUE(LoadExtension(extension_dir)); | 737 ASSERT_TRUE(LoadExtension(extension_dir)); |
738 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 738 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
739 // Now the plugin should be in the cache, but we have to reload the page for | 739 // Now the plugin should be in the cache, but we have to reload the page for |
740 // it to work. | 740 // it to work. |
741 ui_test_utils::ExecuteJavaScriptAndExtractBool( | 741 ui_test_utils::ExecuteJavaScriptAndExtractBool( |
742 tab->render_view_host(), L"", L"testPluginWorks()", &result); | 742 tab->render_view_host(), L"", L"testPluginWorks()", &result); |
743 EXPECT_FALSE(result); | 743 EXPECT_FALSE(result); |
744 browser()->Reload(); | 744 browser()->Reload(CURRENT_TAB); |
745 ui_test_utils::WaitForNavigationInCurrentTab(browser()); | 745 ui_test_utils::WaitForNavigationInCurrentTab(browser()); |
746 ui_test_utils::ExecuteJavaScriptAndExtractBool( | 746 ui_test_utils::ExecuteJavaScriptAndExtractBool( |
747 tab->render_view_host(), L"", L"testPluginWorks()", &result); | 747 tab->render_view_host(), L"", L"testPluginWorks()", &result); |
748 EXPECT_TRUE(result); | 748 EXPECT_TRUE(result); |
749 | 749 |
750 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 750 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
751 UnloadExtension(service->extensions()->at(size_before)->id()); | 751 UnloadExtension(service->extensions()->at(size_before)->id()); |
752 EXPECT_EQ(size_before, service->extensions()->size()); | 752 EXPECT_EQ(size_before, service->extensions()->size()); |
753 | 753 |
754 // Now the plugin should be unloaded, and the page should be broken. | 754 // Now the plugin should be unloaded, and the page should be broken. |
755 | 755 |
756 ui_test_utils::ExecuteJavaScriptAndExtractBool( | 756 ui_test_utils::ExecuteJavaScriptAndExtractBool( |
757 tab->render_view_host(), L"", L"testPluginWorks()", &result); | 757 tab->render_view_host(), L"", L"testPluginWorks()", &result); |
758 EXPECT_FALSE(result); | 758 EXPECT_FALSE(result); |
759 | 759 |
760 // If we reload the extension and page, it should work again. | 760 // If we reload the extension and page, it should work again. |
761 | 761 |
762 ASSERT_TRUE(LoadExtension(extension_dir)); | 762 ASSERT_TRUE(LoadExtension(extension_dir)); |
763 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 763 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
764 browser()->Reload(); | 764 browser()->Reload(CURRENT_TAB); |
765 ui_test_utils::WaitForNavigationInCurrentTab(browser()); | 765 ui_test_utils::WaitForNavigationInCurrentTab(browser()); |
766 ui_test_utils::ExecuteJavaScriptAndExtractBool( | 766 ui_test_utils::ExecuteJavaScriptAndExtractBool( |
767 tab->render_view_host(), L"", L"testPluginWorks()", &result); | 767 tab->render_view_host(), L"", L"testPluginWorks()", &result); |
768 EXPECT_TRUE(result); | 768 EXPECT_TRUE(result); |
769 } | 769 } |
770 | 770 |
771 // Used to simulate a click on the first button named 'Options'. | 771 // Used to simulate a click on the first button named 'Options'. |
772 static const wchar_t* jscript_click_option_button = | 772 static const wchar_t* jscript_click_option_button = |
773 L"(function() { " | 773 L"(function() { " |
774 L" var button = document.evaluate(\"//button[text()='Options']\"," | 774 L" var button = document.evaluate(\"//button[text()='Options']\"," |
(...skipping 24 matching lines...) Expand all Loading... |
799 | 799 |
800 // If the options page hasn't already come up, wait for it. | 800 // If the options page hasn't already come up, wait for it. |
801 if (tab_strip->count() == 1) { | 801 if (tab_strip->count() == 1) { |
802 ui_test_utils::WaitForNewTab(browser()); | 802 ui_test_utils::WaitForNewTab(browser()); |
803 } | 803 } |
804 ASSERT_EQ(2, tab_strip->count()); | 804 ASSERT_EQ(2, tab_strip->count()); |
805 | 805 |
806 EXPECT_EQ(extension->GetResourceURL("options.html"), | 806 EXPECT_EQ(extension->GetResourceURL("options.html"), |
807 tab_strip->GetTabContentsAt(1)->GetURL()); | 807 tab_strip->GetTabContentsAt(1)->GetURL()); |
808 } | 808 } |
OLD | NEW |