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

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

Issue 9015022: Replace most of Browser::GetSelectedTabContents calls into Browser::GetSelectedWebContents. I've ... (Closed) Base URL: svn://chrome-svn/chrome/trunk/src/
Patch Set: '' Created 8 years, 11 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 | Annotate | Revision Log
OLDNEW
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. 1 // Copyright (c) 2011 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"
(...skipping 19 matching lines...) Expand all
30 #include "content/public/browser/navigation_entry.h" 30 #include "content/public/browser/navigation_entry.h"
31 #include "content/public/browser/notification_service.h" 31 #include "content/public/browser/notification_service.h"
32 #include "net/base/net_util.h" 32 #include "net/base/net_util.h"
33 #include "net/test/test_server.h" 33 #include "net/test/test_server.h"
34 #include "webkit/glue/webpreferences.h" 34 #include "webkit/glue/webpreferences.h"
35 35
36 #if defined(TOOLKIT_VIEWS) 36 #if defined(TOOLKIT_VIEWS)
37 #include "chrome/browser/ui/views/frame/browser_view.h" 37 #include "chrome/browser/ui/views/frame/browser_view.h"
38 #endif 38 #endif
39 39
40 using content::WebContents;
41
40 const std::string kSubscribePage = "/subscribe.html"; 42 const std::string kSubscribePage = "/subscribe.html";
41 const std::string kFeedPage = "files/feeds/feed.html"; 43 const std::string kFeedPage = "files/feeds/feed.html";
42 const std::string kFeedPageMultiRel = "files/feeds/feed_multi_rel.html"; 44 const std::string kFeedPageMultiRel = "files/feeds/feed_multi_rel.html";
43 const std::string kNoFeedPage = "files/feeds/no_feed.html"; 45 const std::string kNoFeedPage = "files/feeds/no_feed.html";
44 const std::string kValidFeed0 = "files/feeds/feed_script.xml"; 46 const std::string kValidFeed0 = "files/feeds/feed_script.xml";
45 const std::string kValidFeed1 = "files/feeds/feed1.xml"; 47 const std::string kValidFeed1 = "files/feeds/feed1.xml";
46 const std::string kValidFeed2 = "files/feeds/feed2.xml"; 48 const std::string kValidFeed2 = "files/feeds/feed2.xml";
47 const std::string kValidFeed3 = "files/feeds/feed3.xml"; 49 const std::string kValidFeed3 = "files/feeds/feed3.xml";
48 const std::string kValidFeed4 = "files/feeds/feed4.xml"; 50 const std::string kValidFeed4 = "files/feeds/feed4.xml";
49 const std::string kValidFeed5 = "files/feeds/feed5.xml"; 51 const std::string kValidFeed5 = "files/feeds/feed5.xml";
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after
89 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 91 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
90 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 92 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
91 .AppendASCII("1.0.0.0"))); 93 .AppendASCII("1.0.0.0")));
92 94
93 ui_test_utils::NavigateToURL( 95 ui_test_utils::NavigateToURL(
94 browser(), 96 browser(),
95 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); 97 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"));
96 98
97 bool result = false; 99 bool result = false;
98 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 100 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
99 browser()->GetSelectedTabContents()->GetRenderViewHost(), L"", 101 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
100 L"testTabsAPI()", &result)); 102 L"testTabsAPI()", &result));
101 EXPECT_TRUE(result); 103 EXPECT_TRUE(result);
102 104
103 // 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
104 // 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
105 // do some setup. 107 // do some setup.
106 ui_test_utils::NavigateToURL( 108 ui_test_utils::NavigateToURL(
107 browser(), 109 browser(),
108 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html")); 110 GURL("chrome-extension://behllobkkfkfnphdnhnkndlbkcpglgmj/page.html"));
109 result = false; 111 result = false;
110 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 112 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
111 browser()->GetSelectedTabContents()->GetRenderViewHost(), L"", 113 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
112 L"testTabsAPI()", &result)); 114 L"testTabsAPI()", &result));
113 EXPECT_TRUE(result); 115 EXPECT_TRUE(result);
114 } 116 }
115 117
116 // Tests that GPU-related WebKit preferences are set for extension background 118 // Tests that GPU-related WebKit preferences are set for extension background
117 // pages. See http://crbug.com/64512. 119 // pages. See http://crbug.com/64512.
118 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebKitPrefsBackgroundPage) { 120 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WebKitPrefsBackgroundPage) {
119 ASSERT_TRUE(LoadExtension( 121 ASSERT_TRUE(LoadExtension(
120 test_data_dir_.AppendASCII("good").AppendASCII("Extensions") 122 test_data_dir_.AppendASCII("good").AppendASCII("Extensions")
121 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj") 123 .AppendASCII("behllobkkfkfnphdnhnkndlbkcpglgmj")
(...skipping 170 matching lines...) Expand 10 before | Expand all | Expand 10 after
292 .AppendASCII("title_localized")); 294 .AppendASCII("title_localized"));
293 const Extension* extension = LoadExtension(extension_path); 295 const Extension* extension = LoadExtension(extension_path);
294 ASSERT_TRUE(extension); 296 ASSERT_TRUE(extension);
295 297
296 ASSERT_EQ(size_before + 1, service->extensions()->size()); 298 ASSERT_EQ(size_before + 1, service->extensions()->size());
297 299
298 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n browser action").c_str(), 300 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n browser action").c_str(),
299 extension->description().c_str()); 301 extension->description().c_str());
300 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(), 302 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(),
301 extension->name().c_str()); 303 extension->name().c_str());
302 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); 304 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedWebContents());
303 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(), 305 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(),
304 extension->browser_action()->GetTitle(tab_id).c_str()); 306 extension->browser_action()->GetTitle(tab_id).c_str());
305 } 307 }
306 308
307 // Tests that tooltips of a page action icon can be specified using UTF8. 309 // Tests that tooltips of a page action icon can be specified using UTF8.
308 // See http://crbug.com/25349. 310 // See http://crbug.com/25349.
309 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) { 311 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, TitleLocalizationPageAction) {
310 ASSERT_TRUE(test_server()->Start()); 312 ASSERT_TRUE(test_server()->Start());
311 313
312 ExtensionService* service = browser()->profile()->GetExtensionService(); 314 ExtensionService* service = browser()->profile()->GetExtensionService();
313 const size_t size_before = service->extensions()->size(); 315 const size_t size_before = service->extensions()->size();
314 316
315 FilePath extension_path(test_data_dir_.AppendASCII("browsertest") 317 FilePath extension_path(test_data_dir_.AppendASCII("browsertest")
316 .AppendASCII("title_localized_pa")); 318 .AppendASCII("title_localized_pa"));
317 const Extension* extension = LoadExtension(extension_path); 319 const Extension* extension = LoadExtension(extension_path);
318 ASSERT_TRUE(extension); 320 ASSERT_TRUE(extension);
319 321
320 // Any navigation prompts the location bar to load the page action. 322 // Any navigation prompts the location bar to load the page action.
321 GURL url = test_server()->GetURL(kLocalization); 323 GURL url = test_server()->GetURL(kLocalization);
322 ui_test_utils::NavigateToURL(browser(), url); 324 ui_test_utils::NavigateToURL(browser(), url);
323 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1)); 325 ASSERT_TRUE(WaitForPageActionVisibilityChangeTo(1));
324 326
325 ASSERT_EQ(size_before + 1, service->extensions()->size()); 327 ASSERT_EQ(size_before + 1, service->extensions()->size());
326 328
327 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(), 329 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur: l10n page action").c_str(),
328 extension->description().c_str()); 330 extension->description().c_str());
329 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(), 331 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur is my name").c_str(),
330 extension->name().c_str()); 332 extension->name().c_str());
331 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedTabContents()); 333 int tab_id = ExtensionTabUtil::GetTabId(browser()->GetSelectedWebContents());
332 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(), 334 EXPECT_STREQ(WideToUTF8(L"Hreggvi\u00F0ur").c_str(),
333 extension->page_action()->GetTitle(tab_id).c_str()); 335 extension->page_action()->GetTitle(tab_id).c_str());
334 } 336 }
335 337
336 GURL GetFeedUrl(net::TestServer* server, const std::string& feed_page, 338 GURL GetFeedUrl(net::TestServer* server, const std::string& feed_page,
337 bool direct_url, std::string extension_id) { 339 bool direct_url, std::string extension_id) {
338 GURL feed_url = server->GetURL(feed_page); 340 GURL feed_url = server->GetURL(feed_page);
339 if (direct_url) { 341 if (direct_url) {
340 // We navigate directly to the subscribe page for feeds where the feed 342 // We navigate directly to the subscribe page for feeds where the feed
341 // sniffing won't work, in other words, as is the case for malformed feeds. 343 // sniffing won't work, in other words, as is the case for malformed feeds.
(...skipping 26 matching lines...) Expand all
368 L" document.getElementById('desc_0').textContent : " 370 L" document.getElementById('desc_0').textContent : "
369 L" \"element 'desc_0' not found\"" 371 L" \"element 'desc_0' not found\""
370 L");"; 372 L");";
371 static const wchar_t* jscript_error = 373 static const wchar_t* jscript_error =
372 L"window.domAutomationController.send(" 374 L"window.domAutomationController.send("
373 L" document.getElementById('error') ? " 375 L" document.getElementById('error') ? "
374 L" document.getElementById('error').textContent : " 376 L" document.getElementById('error').textContent : "
375 L" \"No error\"" 377 L" \"No error\""
376 L");"; 378 L");";
377 379
378 bool ValidatePageElement(TabContents* tab, 380 bool ValidatePageElement(WebContents* tab,
379 const std::wstring& frame, 381 const std::wstring& frame,
380 const std::wstring& javascript, 382 const std::wstring& javascript,
381 const std::string& expected_value) { 383 const std::string& expected_value) {
382 std::string returned_value; 384 std::string returned_value;
383 std::string error; 385 std::string error;
384 386
385 if (!ui_test_utils::ExecuteJavaScriptAndExtractString( 387 if (!ui_test_utils::ExecuteJavaScriptAndExtractString(
386 tab->GetRenderViewHost(), 388 tab->GetRenderViewHost(),
387 frame, 389 frame,
388 javascript, &returned_value)) 390 javascript, &returned_value))
(...skipping 17 matching lines...) Expand all
406 const std::string& expected_item_desc, 408 const std::string& expected_item_desc,
407 const std::string& expected_error) { 409 const std::string& expected_error) {
408 if (sniff_xml_type) { 410 if (sniff_xml_type) {
409 // TODO(finnur): Implement this is a non-flaky way. 411 // TODO(finnur): Implement this is a non-flaky way.
410 } 412 }
411 413
412 // Navigate to the subscribe page directly. 414 // Navigate to the subscribe page directly.
413 ui_test_utils::NavigateToURL(browser, 415 ui_test_utils::NavigateToURL(browser,
414 GetFeedUrl(server, url, true, extension_id)); 416 GetFeedUrl(server, url, true, extension_id));
415 417
416 TabContents* tab = browser->GetSelectedTabContents(); 418 WebContents* tab = browser->GetSelectedWebContents();
417 ASSERT_TRUE(ValidatePageElement(tab, 419 ASSERT_TRUE(ValidatePageElement(tab,
418 L"", 420 L"",
419 jscript_feed_title, 421 jscript_feed_title,
420 expected_feed_title)); 422 expected_feed_title));
421 ASSERT_TRUE(ValidatePageElement(tab, 423 ASSERT_TRUE(ValidatePageElement(tab,
422 L"//html/body/div/iframe[1]", 424 L"//html/body/div/iframe[1]",
423 jscript_anchor, 425 jscript_anchor,
424 expected_item_title)); 426 expected_item_title));
425 ASSERT_TRUE(ValidatePageElement(tab, 427 ASSERT_TRUE(ValidatePageElement(tab,
426 L"//html/body/div/iframe[1]", 428 L"//html/body/div/iframe[1]",
(...skipping 251 matching lines...) Expand 10 before | Expand all | Expand 10 after
678 680
679 bool result = false; 681 bool result = false;
680 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 682 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
681 host->render_view_host(), L"", L"testLastError()", &result)); 683 host->render_view_host(), L"", L"testLastError()", &result));
682 EXPECT_TRUE(result); 684 EXPECT_TRUE(result);
683 } 685 }
684 686
685 // Helper function for common code shared by the 3 WindowOpen tests below. 687 // Helper function for common code shared by the 3 WindowOpen tests below.
686 static void WindowOpenHelper(Browser* browser, const GURL& start_url, 688 static void WindowOpenHelper(Browser* browser, const GURL& start_url,
687 const std::string& newtab_url, 689 const std::string& newtab_url,
688 TabContents** newtab_result) { 690 WebContents** newtab_result) {
689 ui_test_utils::NavigateToURL(browser, start_url); 691 ui_test_utils::NavigateToURL(browser, start_url);
690 692
691 ui_test_utils::WindowedNotificationObserver observer( 693 ui_test_utils::WindowedNotificationObserver observer(
692 content::NOTIFICATION_LOAD_STOP, 694 content::NOTIFICATION_LOAD_STOP,
693 content::NotificationService::AllSources()); 695 content::NotificationService::AllSources());
694 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 696 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
695 browser->GetSelectedTabContents()->GetRenderViewHost(), L"", 697 browser->GetSelectedWebContents()->GetRenderViewHost(), L"",
696 L"window.open('" + UTF8ToWide(newtab_url) + L"');")); 698 L"window.open('" + UTF8ToWide(newtab_url) + L"');"));
697 699
698 // Now the active tab in last active window should be the new tab. 700 // Now the active tab in last active window should be the new tab.
699 Browser* last_active_browser = BrowserList::GetLastActive(); 701 Browser* last_active_browser = BrowserList::GetLastActive();
700 EXPECT_TRUE(last_active_browser); 702 EXPECT_TRUE(last_active_browser);
701 TabContents* newtab = last_active_browser->GetSelectedTabContents(); 703 WebContents* newtab = last_active_browser->GetSelectedWebContents();
702 EXPECT_TRUE(newtab); 704 EXPECT_TRUE(newtab);
703 GURL expected_url = start_url.Resolve(newtab_url); 705 GURL expected_url = start_url.Resolve(newtab_url);
704 observer.Wait(); 706 observer.Wait();
705 EXPECT_EQ(expected_url, 707 EXPECT_EQ(expected_url,
706 newtab->GetController().GetLastCommittedEntry()->GetURL()); 708 newtab->GetController().GetLastCommittedEntry()->GetURL());
707 if (newtab_result) 709 if (newtab_result)
708 *newtab_result = newtab; 710 *newtab_result = newtab;
709 } 711 }
710 712
711 // Tests that an extension page can call window.open to an extension URL and 713 // Tests that an extension page can call window.open to an extension URL and
712 // the new window has extension privileges. 714 // the new window has extension privileges.
713 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) { 715 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenExtension) {
714 ASSERT_TRUE(LoadExtension( 716 ASSERT_TRUE(LoadExtension(
715 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); 717 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")));
716 718
717 TabContents* newtab; 719 WebContents* newtab;
718 ASSERT_NO_FATAL_FAILURE(WindowOpenHelper( 720 ASSERT_NO_FATAL_FAILURE(WindowOpenHelper(
719 browser(), 721 browser(),
720 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ + 722 GURL(std::string("chrome-extension://") + last_loaded_extension_id_ +
721 "/test.html"), 723 "/test.html"),
722 "newtab.html", &newtab)); 724 "newtab.html", &newtab));
723 725
724 bool result = false; 726 bool result = false;
725 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 727 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
726 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result)); 728 newtab->GetRenderViewHost(), L"", L"testExtensionApi()", &result));
727 EXPECT_TRUE(result); 729 EXPECT_TRUE(result);
(...skipping 15 matching lines...) Expand all
743 } 745 }
744 746
745 // Tests that calling window.open from the newtab page to an extension URL 747 // Tests that calling window.open from the newtab page to an extension URL
746 // gives the new window extension privileges - even though the opening page 748 // gives the new window extension privileges - even though the opening page
747 // does not have extension privileges, we break the script connection, so 749 // does not have extension privileges, we break the script connection, so
748 // there is no privilege leak. 750 // there is no privilege leak.
749 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenNoPrivileges) { 751 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, WindowOpenNoPrivileges) {
750 ASSERT_TRUE(LoadExtension( 752 ASSERT_TRUE(LoadExtension(
751 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open"))); 753 test_data_dir_.AppendASCII("uitest").AppendASCII("window_open")));
752 754
753 TabContents* newtab; 755 WebContents* newtab;
754 ASSERT_NO_FATAL_FAILURE(WindowOpenHelper( 756 ASSERT_NO_FATAL_FAILURE(WindowOpenHelper(
755 browser(), 757 browser(),
756 GURL("about:blank"), 758 GURL("about:blank"),
757 std::string("chrome-extension://") + last_loaded_extension_id_ + 759 std::string("chrome-extension://") + last_loaded_extension_id_ +
758 "/newtab.html", 760 "/newtab.html",
759 &newtab)); 761 &newtab));
760 762
761 // Extension API should succeed. 763 // Extension API should succeed.
762 bool result = false; 764 bool result = false;
763 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 765 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
(...skipping 17 matching lines...) Expand all
781 #endif 783 #endif
782 784
783 // Tests that a renderer's plugin list is properly updated when we load and 785 // Tests that a renderer's plugin list is properly updated when we load and
784 // unload an extension that contains a plugin. 786 // unload an extension that contains a plugin.
785 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MAYBE_PluginLoadUnload) { 787 IN_PROC_BROWSER_TEST_F(ExtensionBrowserTest, MAYBE_PluginLoadUnload) {
786 FilePath extension_dir = 788 FilePath extension_dir =
787 test_data_dir_.AppendASCII("uitest").AppendASCII("plugins"); 789 test_data_dir_.AppendASCII("uitest").AppendASCII("plugins");
788 790
789 ui_test_utils::NavigateToURL(browser(), 791 ui_test_utils::NavigateToURL(browser(),
790 net::FilePathToFileURL(extension_dir.AppendASCII("test.html"))); 792 net::FilePathToFileURL(extension_dir.AppendASCII("test.html")));
791 TabContents* tab = browser()->GetSelectedTabContents(); 793 WebContents* tab = browser()->GetSelectedWebContents();
792 794
793 // With no extensions, the plugin should not be loaded. 795 // With no extensions, the plugin should not be loaded.
794 bool result = false; 796 bool result = false;
795 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 797 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
796 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); 798 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result));
797 EXPECT_FALSE(result); 799 EXPECT_FALSE(result);
798 800
799 ExtensionService* service = browser()->profile()->GetExtensionService(); 801 ExtensionService* service = browser()->profile()->GetExtensionService();
800 service->set_show_extensions_prompts(false); 802 service->set_show_extensions_prompts(false);
801 const size_t size_before = service->extensions()->size(); 803 const size_t size_before = service->extensions()->size();
(...skipping 62 matching lines...) Expand 10 before | Expand all | Expand 10 after
864 ExtensionService* service = browser()->profile()->GetExtensionService(); 866 ExtensionService* service = browser()->profile()->GetExtensionService();
865 service->set_show_extensions_prompts(false); 867 service->set_show_extensions_prompts(false);
866 const size_t size_before = service->extensions()->size(); 868 const size_t size_before = service->extensions()->size();
867 const Extension* extension = LoadExtension(extension_dir); 869 const Extension* extension = LoadExtension(extension_dir);
868 ASSERT_TRUE(extension); 870 ASSERT_TRUE(extension);
869 EXPECT_EQ(size_before + 1, service->extensions()->size()); 871 EXPECT_EQ(size_before + 1, service->extensions()->size());
870 872
871 // Load the test page through the extension URL, and the plugin should work. 873 // Load the test page through the extension URL, and the plugin should work.
872 ui_test_utils::NavigateToURL(browser(), 874 ui_test_utils::NavigateToURL(browser(),
873 extension->GetResourceURL("test.html")); 875 extension->GetResourceURL("test.html"));
874 TabContents* tab = browser()->GetSelectedTabContents(); 876 WebContents* tab = browser()->GetSelectedWebContents();
875 bool result = false; 877 bool result = false;
876 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 878 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
877 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result)); 879 tab->GetRenderViewHost(), L"", L"testPluginWorks()", &result));
878 // We don't allow extension plugins to run on ChromeOS. 880 // We don't allow extension plugins to run on ChromeOS.
879 #if defined(OS_CHROMEOS) 881 #if defined(OS_CHROMEOS)
880 EXPECT_FALSE(result); 882 EXPECT_FALSE(result);
881 #else 883 #else
882 EXPECT_TRUE(result); 884 EXPECT_TRUE(result);
883 #endif 885 #endif
884 886
(...skipping 25 matching lines...) Expand all
910 ASSERT_TRUE(extension); 912 ASSERT_TRUE(extension);
911 ExtensionService* service = browser()->profile()->GetExtensionService(); 913 ExtensionService* service = browser()->profile()->GetExtensionService();
912 ASSERT_EQ(1u, service->extensions()->size()); 914 ASSERT_EQ(1u, service->extensions()->size());
913 915
914 // Go to the Extension Settings page and click the Options button. 916 // Go to the Extension Settings page and click the Options button.
915 ui_test_utils::NavigateToURL( 917 ui_test_utils::NavigateToURL(
916 browser(), GURL(std::string(chrome::kChromeUISettingsURL) + 918 browser(), GURL(std::string(chrome::kChromeUISettingsURL) +
917 chrome::kExtensionsSubPage)); 919 chrome::kExtensionsSubPage));
918 TabStripModel* tab_strip = browser()->tabstrip_model(); 920 TabStripModel* tab_strip = browser()->tabstrip_model();
919 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript( 921 ASSERT_TRUE(ui_test_utils::ExecuteJavaScript(
920 browser()->GetSelectedTabContents()->GetRenderViewHost(), L"", 922 browser()->GetSelectedWebContents()->GetRenderViewHost(), L"",
921 jscript_click_option_button)); 923 jscript_click_option_button));
922 924
923 // If the options page hasn't already come up, wait for it. 925 // If the options page hasn't already come up, wait for it.
924 if (tab_strip->count() == 1) { 926 if (tab_strip->count() == 1) {
925 ui_test_utils::WaitForNewTab(browser()); 927 ui_test_utils::WaitForNewTab(browser());
926 } 928 }
927 ASSERT_EQ(2, tab_strip->count()); 929 ASSERT_EQ(2, tab_strip->count());
928 930
929 EXPECT_EQ(extension->GetResourceURL("options.html"), 931 EXPECT_EQ(extension->GetResourceURL("options.html"),
930 tab_strip->GetTabContentsAt(1)->tab_contents()->GetURL()); 932 tab_strip->GetTabContentsAt(1)->tab_contents()->GetURL());
931 } 933 }
932 934
933 //============================================================================== 935 //==============================================================================
934 // STOP! Please do not add any more random-ass tests here. Create new files for 936 // STOP! Please do not add any more random-ass tests here. Create new files for
935 // your tests grouped by functionality. Also, you should strongly consider using 937 // your tests grouped by functionality. Also, you should strongly consider using
936 // ExtensionAPITest if possible. 938 // ExtensionAPITest if possible.
937 //============================================================================== 939 //==============================================================================
OLDNEW
« no previous file with comments | « chrome/browser/extensions/content_script_apitest.cc ('k') | chrome/browser/extensions/extension_context_menu_model.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698