| OLD | NEW |
| 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 "base/file_util.h" | 5 #include "base/file_util.h" |
| 6 #include "base/memory/ref_counted.h" | 6 #include "base/memory/ref_counted.h" |
| 7 #include "base/utf_string_conversions.h" | 7 #include "base/utf_string_conversions.h" |
| 8 #include "chrome/browser/extensions/autoupdate_interceptor.h" | 8 #include "chrome/browser/extensions/autoupdate_interceptor.h" |
| 9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
| 10 #include "chrome/browser/extensions/extension_browsertest.h" | 10 #include "chrome/browser/extensions/extension_browsertest.h" |
| 11 #include "chrome/browser/extensions/extension_error_reporter.h" | 11 #include "chrome/browser/extensions/extension_error_reporter.h" |
| 12 #include "chrome/browser/extensions/extension_host.h" | 12 #include "chrome/browser/extensions/extension_host.h" |
| 13 #include "chrome/browser/extensions/extension_process_manager.h" | 13 #include "chrome/browser/extensions/extension_process_manager.h" |
| 14 #include "chrome/browser/extensions/extension_service.h" | 14 #include "chrome/browser/extensions/extension_service.h" |
| 15 #include "chrome/browser/extensions/extension_tab_util.h" | 15 #include "chrome/browser/extensions/extension_tab_util.h" |
| 16 #include "chrome/browser/prefs/pref_service.h" | 16 #include "chrome/browser/prefs/pref_service.h" |
| 17 #include "chrome/browser/profiles/profile.h" | 17 #include "chrome/browser/profiles/profile.h" |
| 18 #include "chrome/browser/ui/browser.h" | 18 #include "chrome/browser/ui/browser.h" |
| 19 #include "chrome/browser/ui/browser_list.h" | 19 #include "chrome/browser/ui/browser_list.h" |
| 20 #include "chrome/browser/ui/tab_contents/tab_contents_wrapper.h" | 20 #include "chrome/browser/ui/tab_contents/tab_contents.h" |
| 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 21 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
| 22 #include "chrome/common/chrome_paths.h" | 22 #include "chrome/common/chrome_paths.h" |
| 23 #include "chrome/common/chrome_switches.h" | 23 #include "chrome/common/chrome_switches.h" |
| 24 #include "chrome/common/extensions/extension_action.h" | 24 #include "chrome/common/extensions/extension_action.h" |
| 25 #include "chrome/common/pref_names.h" | 25 #include "chrome/common/pref_names.h" |
| 26 #include "chrome/common/url_constants.h" | 26 #include "chrome/common/url_constants.h" |
| 27 #include "chrome/test/base/ui_test_utils.h" | 27 #include "chrome/test/base/ui_test_utils.h" |
| 28 #include "content/public/browser/navigation_entry.h" | 28 #include "content/public/browser/navigation_entry.h" |
| 29 #include "content/public/browser/notification_service.h" | 29 #include "content/public/browser/notification_service.h" |
| 30 #include "content/public/browser/render_view_host.h" | 30 #include "content/public/browser/render_view_host.h" |
| (...skipping 60 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 91 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 91 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
| 92 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 92 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| 93 .AppendASCII("1.0.0.0"))); | 93 .AppendASCII("1.0.0.0"))); |
| 94 | 94 |
| 95 ui_test_utils::NavigateToURL( | 95 ui_test_utils::NavigateToURL( |
| 96 browser(), | 96 browser(), |
| 97 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); | 97 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); |
| 98 | 98 |
| 99 bool result = false; | 99 bool result = false; |
| 100 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 100 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 101 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", | 101 browser()->GetActiveWebContents()->GetRenderViewHost(), L"", |
| 102 L"testTabsAPI()", &result)); | 102 L"testTabsAPI()", &result)); |
| 103 EXPECT_TRUE(result); | 103 EXPECT_TRUE(result); |
| 104 | 104 |
| 105 // There was a bug where we would crash if we navigated to a page in the same | 105 // There was a bug where we would crash if we navigated to a page in the same |
| 106 // extension because no new render view was getting created, so we would not | 106 // extension because no new render view was getting created, so we would not |
| 107 // do some setup. | 107 // do some setup. |
| 108 ui_test_utils::NavigateToURL( | 108 ui_test_utils::NavigateToURL( |
| 109 browser(), | 109 browser(), |
| 110 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); | 110 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); |
| 111 result = false; | 111 result = false; |
| 112 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 112 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 113 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", | 113 browser()->GetActiveWebContents()->GetRenderViewHost(), L"", |
| 114 L"testTabsAPI()", &result)); | 114 L"testTabsAPI()", &result)); |
| 115 EXPECT_TRUE(result); | 115 EXPECT_TRUE(result); |
| 116 } | 116 } |
| 117 | 117 |
| 118 // Tests that GPU-related WebKit preferences are set for extension background | 118 // Tests that GPU-related WebKit preferences are set for extension background |
| 119 // pages. See http://crbug.com/64512. | 119 // pages. See http://crbug.com/64512. |
| 120 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebKitPrefsBackgroundPage) { | 120 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebKitPrefsBackgroundPage) { |
| 121 ASSERT_TRUE(LoadExtension( | 121 ASSERT_TRUE(LoadExtension( |
| 122 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") | 122 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") |
| 123 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") | 123 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") |
| (...skipping 173 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 297 .AppendASCII("title_localized")); | 297 .AppendASCII("title_localized")); |
| 298 const Extension* extension = LoadExtension(extension_path); | 298 const Extension* extension = LoadExtension(extension_path); |
| 299 ASSERT_TRUE(extension); | 299 ASSERT_TRUE(extension); |
| 300 | 300 |
| 301 ASSERT_EQ(size_before + 1, service->extensions()->size()); | 301 ASSERT_EQ(size_before + 1, service->extensions()->size()); |
| 302 | 302 |
| 303 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n browser action").c_str(), | 303 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n browser action").c_str(), |
| 304 extension->description().c_str()); | 304 extension->description().c_str()); |
| 305 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(), | 305 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(), |
| 306 extension->name().c_str()); | 306 extension->name().c_str()); |
| 307 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedWebContents()); | 307 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetActiveWebContents()); |
| 308 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(), | 308 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(), |
| 309 extension->browser_action()->GetTitle(tab_id).c_str()); | 309 extension->browser_action()->GetTitle(tab_id).c_str()); |
| 310 } | 310 } |
| 311 | 311 |
| 312 // Tests that tooltips of a page action icon can be specified using UTF8. | 312 // Tests that tooltips of a page action icon can be specified using UTF8. |
| 313 // See http://crbug.com/25349. | 313 // See http://crbug.com/25349. |
| 314 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) { | 314 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) { |
| 315 ASSERT_TRUE(test_server()->Start()); | 315 ASSERT_TRUE(test_server()->Start()); |
| 316 | 316 |
| 317 ExtensionService* service = browser()->profile()->GetExtensionService(); | 317 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 318 const size_t size_before = service->extensions()->size(); | 318 const size_t size_before = service->extensions()->size(); |
| 319 | 319 |
| 320 FilePath extension_path(test_data_dir_.AppendASCII("browsertest") | 320 FilePath extension_path(test_data_dir_.AppendASCII("browsertest") |
| 321 .AppendASCII("title_localized_pa")); | 321 .AppendASCII("title_localized_pa")); |
| 322 const Extension* extension = LoadExtension(extension_path); | 322 const Extension* extension = LoadExtension(extension_path); |
| 323 ASSERT_TRUE(extension); | 323 ASSERT_TRUE(extension); |
| 324 | 324 |
| 325 // Any navigation prompts the location bar to load the page action. | 325 // Any navigation prompts the location bar to load the page action. |
| 326 GURL url = test_server()->GetURL(kLocalization); | 326 GURL url = test_server()->GetURL(kLocalization); |
| 327 ui_test_utils::NavigateToURL(browser(), url); | 327 ui_test_utils::NavigateToURL(browser(), url); |
| 328 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); | 328 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); |
| 329 | 329 |
| 330 ASSERT_EQ(size_before + 1, service->extensions()->size()); | 330 ASSERT_EQ(size_before + 1, service->extensions()->size()); |
| 331 | 331 |
| 332 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(), | 332 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(), |
| 333 extension->description().c_str()); | 333 extension->description().c_str()); |
| 334 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(), | 334 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(), |
| 335 extension->name().c_str()); | 335 extension->name().c_str()); |
| 336 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedWebContents()); | 336 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetActiveWebContents()); |
| 337 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(), | 337 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(), |
| 338 extension->page_action()->GetTitle(tab_id).c_str()); | 338 extension->page_action()->GetTitle(tab_id).c_str()); |
| 339 } | 339 } |
| 340 | 340 |
| 341 GURL GetFeedUrl(net::TestServer* server, const std::string& feed_page, | 341 GURL GetFeedUrl(net::TestServer* server, const std::string& feed_page, |
| 342 bool direct_url, std::string extension_id) { | 342 bool direct_url, std::string extension_id) { |
| 343 GURL feed_url = server->GetURL(feed_page); | 343 GURL feed_url = server->GetURL(feed_page); |
| 344 if (direct_url) { | 344 if (direct_url) { |
| 345 // We navigate directly to the subscribe page for feeds where the feed | 345 // We navigate directly to the subscribe page for feeds where the feed |
| 346 // sniffing won't work, in other words, as is the case for malformed feeds. | 346 // sniffing won't work, in other words, as is the case for malformed feeds. |
| (...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 411 const std::string& expected_item_desc, | 411 const std::string& expected_item_desc, |
| 412 const std::string& expected_error) { | 412 const std::string& expected_error) { |
| 413 if (sniff_xml_type) { | 413 if (sniff_xml_type) { |
| 414 // TODO(finnur): Implement this is a non-flaky way. | 414 // TODO(finnur): Implement this is a non-flaky way. |
| 415 } | 415 } |
| 416 | 416 |
| 417 // Navigate to the subscribe page directly. | 417 // Navigate to the subscribe page directly. |
| 418 ui_test_utils::NavigateToURL(browser, | 418 ui_test_utils::NavigateToURL(browser, |
| 419 GetFeedUrl(server, url, true, extension_id)); | 419 GetFeedUrl(server, url, true, extension_id)); |
| 420 | 420 |
| 421 WebContents* tab = browser->GetSelectedWebContents(); | 421 WebContents* tab = browser->GetActiveWebContents(); |
| 422 ASSERT_TRUE(ValidatePageElement(tab, | 422 ASSERT_TRUE(ValidatePageElement(tab, |
| 423 L"", | 423 L"", |
| 424 jscript_feed_title, | 424 jscript_feed_title, |
| 425 expected_feed_title)); | 425 expected_feed_title)); |
| 426 ASSERT_TRUE(ValidatePageElement(tab, | 426 ASSERT_TRUE(ValidatePageElement(tab, |
| 427 L"//html/body/div/iframe[1]", | 427 L"//html/body/div/iframe[1]", |
| 428 jscript_anchor, | 428 jscript_anchor, |
| 429 expected_item_title)); | 429 expected_item_title)); |
| 430 ASSERT_TRUE(ValidatePageElement(tab, | 430 ASSERT_TRUE(ValidatePageElement(tab, |
| 431 L"//html/body/div/iframe[1]", | 431 L"//html/body/div/iframe[1]", |
| (...skipping 222 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 654 // Tests that an extension page can call window.open to an extension URL and | 654 // Tests that an extension page can call window.open to an extension URL and |
| 655 // the new window has extension privileges. | 655 // the new window has extension privileges. |
| 656 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) { | 656 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) { |
| 657 ASSERT_TRUE(LoadExtension( | 657 ASSERT_TRUE(LoadExtension( |
| 658 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); | 658 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); |
| 659 | 659 |
| 660 GURL start_url(std::string("chrome-extension://") + | 660 GURL start_url(std::string("chrome-extension://") + |
| 661 last_loaded_extension_id_ + "/test.html"); | 661 last_loaded_extension_id_ + "/test.html"); |
| 662 ui_test_utils::NavigateToURL(browser(), start_url); | 662 ui_test_utils::NavigateToURL(browser(), start_url); |
| 663 WebContents* newtab; | 663 WebContents* newtab; |
| 664 ASSERT_NO_FATAL_FAILURE(OpenWindow(browser()->GetSelectedWebContents(), | 664 ASSERT_NO_FATAL_FAILURE(OpenWindow(browser()->GetActiveWebContents(), |
| 665 start_url.Resolve("newtab.html"), true, &newtab)); | 665 start_url.Resolve("newtab.html"), true, &newtab)); |
| 666 | 666 |
| 667 bool result = false; | 667 bool result = false; |
| 668 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 668 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 669 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); | 669 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); |
| 670 EXPECT_TRUE(result); | 670 EXPECT_TRUE(result); |
| 671 } | 671 } |
| 672 | 672 |
| 673 // Tests that if an extension page calls window.open to an invalid extension | 673 // Tests that if an extension page calls window.open to an invalid extension |
| 674 // URL, the browser doesn't crash. | 674 // URL, the browser doesn't crash. |
| 675 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenInvalidExtension) { | 675 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenInvalidExtension) { |
| 676 ASSERT_TRUE(LoadExtension( | 676 ASSERT_TRUE(LoadExtension( |
| 677 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); | 677 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); |
| 678 | 678 |
| 679 GURL start_url(std::string("chrome-extension://") + | 679 GURL start_url(std::string("chrome-extension://") + |
| 680 last_loaded_extension_id_ + "/test.html"); | 680 last_loaded_extension_id_ + "/test.html"); |
| 681 ui_test_utils::NavigateToURL(browser(), start_url); | 681 ui_test_utils::NavigateToURL(browser(), start_url); |
| 682 ASSERT_NO_FATAL_FAILURE(OpenWindow(browser()->GetSelectedWebContents(), | 682 ASSERT_NO_FATAL_FAILURE(OpenWindow(browser()->GetActiveWebContents(), |
| 683 GURL("chrome-extension://thisissurelynotavalidextensionid/newtab.html"), | 683 GURL("chrome-extension://thisissurelynotavalidextensionid/newtab.html"), |
| 684 false, NULL)); | 684 false, NULL)); |
| 685 | 685 |
| 686 // If we got to this point, we didn't crash, so we're good. | 686 // If we got to this point, we didn't crash, so we're good. |
| 687 } | 687 } |
| 688 | 688 |
| 689 // Tests that calling window.open from the newtab page to an extension URL | 689 // Tests that calling window.open from the newtab page to an extension URL |
| 690 // gives the new window extension privileges - even though the opening page | 690 // gives the new window extension privileges - even though the opening page |
| 691 // does not have extension privileges, we break the script connection, so | 691 // does not have extension privileges, we break the script connection, so |
| 692 // there is no privilege leak. | 692 // there is no privilege leak. |
| 693 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenNoPrivileges) { | 693 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenNoPrivileges) { |
| 694 ASSERT_TRUE(LoadExtension( | 694 ASSERT_TRUE(LoadExtension( |
| 695 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); | 695 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); |
| 696 | 696 |
| 697 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); | 697 ui_test_utils::NavigateToURL(browser(), GURL("about:blank")); |
| 698 WebContents* newtab; | 698 WebContents* newtab; |
| 699 ASSERT_NO_FATAL_FAILURE(OpenWindow(browser()->GetSelectedWebContents(), | 699 ASSERT_NO_FATAL_FAILURE(OpenWindow(browser()->GetActiveWebContents(), |
| 700 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ + | 700 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ + |
| 701 "/newtab.html"), false, &newtab)); | 701 "/newtab.html"), false, &newtab)); |
| 702 | 702 |
| 703 // Extension API should succeed. | 703 // Extension API should succeed. |
| 704 bool result = false; | 704 bool result = false; |
| 705 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 705 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 706 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); | 706 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); |
| 707 EXPECT_TRUE(result); | 707 EXPECT_TRUE(result); |
| 708 } | 708 } |
| 709 | 709 |
| (...skipping 14 matching lines...) Expand all Loading... |
| 724 // unload an extension that contains a plugin. | 724 // unload an extension that contains a plugin. |
| 725 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MAYBE_PluginLoadUnload) { | 725 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MAYBE_PluginLoadUnload) { |
| 726 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, | 726 browser()->profile()->GetPrefs()->SetBoolean(prefs::kPluginsAlwaysAuthorize, |
| 727 true); | 727 true); |
| 728 | 728 |
| 729 FilePath extension_dir = | 729 FilePath extension_dir = |
| 730 test_data_dir_.AppendASCII("uitest").AppendASCII("plugins"); | 730 test_data_dir_.AppendASCII("uitest").AppendASCII("plugins"); |
| 731 | 731 |
| 732 ui_test_utils::NavigateToURL(browser(), | 732 ui_test_utils::NavigateToURL(browser(), |
| 733 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); | 733 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); |
| 734 WebContents* tab = browser()->GetSelectedWebContents(); | 734 WebContents* tab = browser()->GetActiveWebContents(); |
| 735 | 735 |
| 736 // With no extensions, the plugin should not be loaded. | 736 // With no extensions, the plugin should not be loaded. |
| 737 bool result = false; | 737 bool result = false; |
| 738 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 738 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 739 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 739 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
| 740 EXPECT_FALSE(result); | 740 EXPECT_FALSE(result); |
| 741 | 741 |
| 742 ExtensionService* service = browser()->profile()->GetExtensionService(); | 742 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 743 service->set_show_extensions_prompts(false); | 743 service->set_show_extensions_prompts(false); |
| 744 const size_t size_before = service->extensions()->size(); | 744 const size_t size_before = service->extensions()->size(); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 761 EXPECT_FALSE(result); | 761 EXPECT_FALSE(result); |
| 762 | 762 |
| 763 // If we reload the extension and page, it should work again. | 763 // If we reload the extension and page, it should work again. |
| 764 | 764 |
| 765 ASSERT_TRUE(LoadExtension(extension_dir)); | 765 ASSERT_TRUE(LoadExtension(extension_dir)); |
| 766 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 766 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
| 767 { | 767 { |
| 768 ui_test_utils::WindowedNotificationObserver observer( | 768 ui_test_utils::WindowedNotificationObserver observer( |
| 769 content::NOTIFICATION_LOAD_STOP, | 769 content::NOTIFICATION_LOAD_STOP, |
| 770 content::Source<NavigationController>( | 770 content::Source<NavigationController>( |
| 771 &browser()->GetSelectedTabContentsWrapper()->web_contents()-> | 771 &browser()->GetActiveWebContents()->GetController())); |
| 772 GetController())); | |
| 773 browser()->Reload(CURRENT_TAB); | 772 browser()->Reload(CURRENT_TAB); |
| 774 observer.Wait(); | 773 observer.Wait(); |
| 775 } | 774 } |
| 776 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 775 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 777 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 776 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
| 778 EXPECT_TRUE(result); | 777 EXPECT_TRUE(result); |
| 779 } | 778 } |
| 780 | 779 |
| 781 #if defined(OS_WIN) || defined(OS_LINUX) | 780 #if defined(OS_WIN) || defined(OS_LINUX) |
| 782 #define MAYBE_PluginPrivate PluginPrivate | 781 #define MAYBE_PluginPrivate PluginPrivate |
| (...skipping 10 matching lines...) Expand all Loading... |
| 793 ExtensionService* service = browser()->profile()->GetExtensionService(); | 792 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 794 service->set_show_extensions_prompts(false); | 793 service->set_show_extensions_prompts(false); |
| 795 const size_t size_before = service->extensions()->size(); | 794 const size_t size_before = service->extensions()->size(); |
| 796 const Extension* extension = LoadExtension(extension_dir); | 795 const Extension* extension = LoadExtension(extension_dir); |
| 797 ASSERT_TRUE(extension); | 796 ASSERT_TRUE(extension); |
| 798 EXPECT_EQ(size_before + 1, service->extensions()->size()); | 797 EXPECT_EQ(size_before + 1, service->extensions()->size()); |
| 799 | 798 |
| 800 // Load the test page through the extension URL, and the plugin should work. | 799 // Load the test page through the extension URL, and the plugin should work. |
| 801 ui_test_utils::NavigateToURL(browser(), | 800 ui_test_utils::NavigateToURL(browser(), |
| 802 extension->GetResourceURL("test.html")); | 801 extension->GetResourceURL("test.html")); |
| 803 WebContents* tab = browser()->GetSelectedWebContents(); | 802 WebContents* tab = browser()->GetActiveWebContents(); |
| 804 bool result = false; | 803 bool result = false; |
| 805 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( | 804 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( |
| 806 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); | 805 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); |
| 807 // We don't allow extension plugins to run on ChromeOS. | 806 // We don't allow extension plugins to run on ChromeOS. |
| 808 #if defined(OS_CHROMEOS) | 807 #if defined(OS_CHROMEOS) |
| 809 EXPECT_FALSE(result); | 808 EXPECT_FALSE(result); |
| 810 #else | 809 #else |
| 811 EXPECT_TRUE(result); | 810 EXPECT_TRUE(result); |
| 812 #endif | 811 #endif |
| 813 | 812 |
| (...skipping 23 matching lines...) Expand all Loading... |
| 837 const Extension* extension = | 836 const Extension* extension = |
| 838 InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1); | 837 InstallExtension(test_data_dir_.AppendASCII("options.crx"), 1); |
| 839 ASSERT_TRUE(extension); | 838 ASSERT_TRUE(extension); |
| 840 ExtensionService* service = browser()->profile()->GetExtensionService(); | 839 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 841 ASSERT_EQ(1u, service->extensions()->size()); | 840 ASSERT_EQ(1u, service->extensions()->size()); |
| 842 | 841 |
| 843 // Go to the Extension Settings page and click the Options button. | 842 // Go to the Extension Settings page and click the Options button. |
| 844 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL)); | 843 ui_test_utils::NavigateToURL(browser(), GURL(chrome::kChromeUIExtensionsURL)); |
| 845 TabStripModel* tab_strip = browser()->tab_strip_model(); | 844 TabStripModel* tab_strip = browser()->tab_strip_model(); |
| 846 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( | 845 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( |
| 847 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"", | 846 browser()->GetActiveWebContents()->GetRenderViewHost(), L"", |
| 848 jscript_click_option_button)); | 847 jscript_click_option_button)); |
| 849 | 848 |
| 850 // If the options page hasn't already come up, wait for it. | 849 // If the options page hasn't already come up, wait for it. |
| 851 if (tab_strip->count() == 1) { | 850 if (tab_strip->count() == 1) { |
| 852 ui_test_utils::WaitForNewTab(browser()); | 851 ui_test_utils::WaitForNewTab(browser()); |
| 853 } | 852 } |
| 854 ASSERT_EQ(2, tab_strip->count()); | 853 ASSERT_EQ(2, tab_strip->count()); |
| 855 | 854 |
| 856 EXPECT_EQ(extension->GetResourceURL("options.html"), | 855 EXPECT_EQ(extension->GetResourceURL("options.html"), |
| 857 tab_strip->GetTabContentsAt(1)->web_contents()->GetURL()); | 856 tab_strip->GetTabContentsAt(1)->web_contents()->GetURL()); |
| 858 } | 857 } |
| 859 | 858 |
| 860 //============================================================================== | 859 //============================================================================== |
| 861 // STOP! Please do not add any more random-ass tests here. Create new files for | 860 // STOP! Please do not add any more random-ass tests here. Create new files for |
| 862 // your tests grouped by functionality. Also, you should strongly consider using | 861 // your tests grouped by functionality. Also, you should strongly consider using |
| 863 // ExtensionAPITest if possible. | 862 // ExtensionAPITest if possible. |
| 864 //============================================================================== | 863 //============================================================================== |
| OLD | NEW |