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

Side by Side Diff: chrome/browser/extensions/extension_nacl_browsertest.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/command_line.h" 5 #include "base/command_line.h"
6 #include "base/file_path.h" 6 #include "base/file_path.h"
7 #include "base/path_service.h" 7 #include "base/path_service.h"
8 #include "base/utf_string_conversions.h" 8 #include "base/utf_string_conversions.h"
9 #include "chrome/browser/extensions/crx_installer.h" 9 #include "chrome/browser/extensions/crx_installer.h"
10 #include "chrome/browser/extensions/extension_browsertest.h" 10 #include "chrome/browser/extensions/extension_browsertest.h"
11 #include "chrome/browser/extensions/extension_service.h" 11 #include "chrome/browser/extensions/extension_service.h"
12 #include "chrome/browser/prefs/pref_service.h" 12 #include "chrome/browser/prefs/pref_service.h"
13 #include "chrome/browser/profiles/profile.h" 13 #include "chrome/browser/profiles/profile.h"
14 #include "chrome/browser/ui/browser.h" 14 #include "chrome/browser/ui/browser.h"
15 #include "chrome/common/chrome_paths.h" 15 #include "chrome/common/chrome_paths.h"
16 #include "chrome/common/chrome_switches.h" 16 #include "chrome/common/chrome_switches.h"
17 #include "chrome/common/pref_names.h" 17 #include "chrome/common/pref_names.h"
18 #include "chrome/test/base/ui_test_utils.h" 18 #include "chrome/test/base/ui_test_utils.h"
19 #include "content/browser/tab_contents/tab_contents.h"
20 #include "content/public/browser/plugin_service.h" 19 #include "content/public/browser/plugin_service.h"
20 #include "content/public/browser/web_contents.h"
21 #include "webkit/plugins/webplugininfo.h" 21 #include "webkit/plugins/webplugininfo.h"
22 22
23 using content::PluginService; 23 using content::PluginService;
24 using content::WebContents;
24 25
25 namespace { 26 namespace {
26 27
27 const char* kExtensionId = "bjjcibdiodkkeanflmiijlcfieiemced"; 28 const char* kExtensionId = "bjjcibdiodkkeanflmiijlcfieiemced";
28 29
29 // This class tests that the Native Client plugin is blocked unless the 30 // This class tests that the Native Client plugin is blocked unless the
30 // .nexe is part of an extension from the Chrome Webstore. 31 // .nexe is part of an extension from the Chrome Webstore.
31 class NaClExtensionTest : public ExtensionBrowserTest { 32 class NaClExtensionTest : public ExtensionBrowserTest {
32 public: 33 public:
33 NaClExtensionTest() { 34 NaClExtensionTest() {
(...skipping 56 matching lines...) Expand 10 before | Expand all | Expand 10 after
90 91
91 void CheckPluginsCreated(const Extension* extension, bool should_create) { 92 void CheckPluginsCreated(const Extension* extension, bool should_create) {
92 ui_test_utils::NavigateToURL(browser(), 93 ui_test_utils::NavigateToURL(browser(),
93 extension->GetResourceURL("test.html")); 94 extension->GetResourceURL("test.html"));
94 // Don't run tests if the NaCl plugin isn't loaded. 95 // Don't run tests if the NaCl plugin isn't loaded.
95 if (!IsNaClPluginLoaded()) 96 if (!IsNaClPluginLoaded())
96 return; 97 return;
97 98
98 bool embedded_plugin_created = false; 99 bool embedded_plugin_created = false;
99 bool content_handler_plugin_created = false; 100 bool content_handler_plugin_created = false;
100 TabContents* tab_contents = browser()->GetSelectedTabContents(); 101 WebContents* web_contents = browser()->GetSelectedWebContents();
101 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 102 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
102 tab_contents->GetRenderViewHost(), L"", 103 web_contents->GetRenderViewHost(), L"",
103 L"window.domAutomationController.send(EmbeddedPluginCreated());", 104 L"window.domAutomationController.send(EmbeddedPluginCreated());",
104 &embedded_plugin_created)); 105 &embedded_plugin_created));
105 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool( 106 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
106 tab_contents->GetRenderViewHost(), L"", 107 web_contents->GetRenderViewHost(), L"",
107 L"window.domAutomationController.send(ContentHandlerPluginCreated());", 108 L"window.domAutomationController.send(ContentHandlerPluginCreated());",
108 &content_handler_plugin_created)); 109 &content_handler_plugin_created));
109 110
110 EXPECT_EQ(should_create, embedded_plugin_created); 111 EXPECT_EQ(should_create, embedded_plugin_created);
111 EXPECT_EQ(should_create, content_handler_plugin_created); 112 EXPECT_EQ(should_create, content_handler_plugin_created);
112 } 113 }
113 }; 114 };
114 115
115 // Test that the NaCl plugin isn't blocked for Webstore extensions. 116 // Test that the NaCl plugin isn't blocked for Webstore extensions.
116 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, WebStoreExtension) { 117 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, WebStoreExtension) {
(...skipping 27 matching lines...) Expand all
144 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, UnpackedExtension) { 145 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, UnpackedExtension) {
145 ASSERT_TRUE(test_server()->Start()); 146 ASSERT_TRUE(test_server()->Start());
146 147
147 const Extension* extension = InstallExtension(INSTALL_TYPE_UNPACKED); 148 const Extension* extension = InstallExtension(INSTALL_TYPE_UNPACKED);
148 ASSERT_TRUE(extension); 149 ASSERT_TRUE(extension);
149 ASSERT_EQ(extension->location(), Extension::LOAD); 150 ASSERT_EQ(extension->location(), Extension::LOAD);
150 CheckPluginsCreated(extension, true); 151 CheckPluginsCreated(extension, true);
151 } 152 }
152 153
153 } // namespace 154 } // namespace
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_install_ui_browsertest.cc ('k') | chrome/browser/extensions/extension_override_apitest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698