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

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

Issue 7488060: Add tests for CWS restriction of Nacl plugin invocation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src/
Patch Set: '' Created 9 years, 4 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
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Property Changes:
Added: svn:eol-style
+ LF
OLDNEW
(Empty)
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
3 // found in the LICENSE file.
4
5 #include "base/command_line.h"
6 #include "base/utf_string_conversions.h"
7 #include "chrome/browser/extensions/crx_installer.h"
8 #include "chrome/browser/extensions/extension_browsertest.h"
9 #include "chrome/browser/extensions/extension_service.h"
10 #include "chrome/browser/prefs/pref_service.h"
11 #include "chrome/browser/profiles/profile.h"
12 #include "chrome/browser/ui/browser.h"
13 #include "chrome/common/chrome_switches.h"
14 #include "chrome/common/pref_names.h"
15 #include "chrome/test/base/ui_test_utils.h"
16 #include "content/browser/tab_contents/tab_contents.h"
17
18 namespace {
19
20 // This class tests that the Native Client plugin is blocked unless the
21 // .nexe is part of an extension from the Chrome Webstore.
22 class NaClExtensionTest : public ExtensionBrowserTest {
23 public:
24 NaClExtensionTest() {
25 EnableDOMAutomation();
26 }
27
28 protected:
29 void CheckPluginsCreated(TabContents* tab_contents,
30 bool* embedded_plugin,
31 bool* content_handler_plugin) {
32 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
33 tab_contents->render_view_host(), L"",
34 L"window.domAutomationController.send(EmbeddedPluginCreated());",
35 embedded_plugin));
36 ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
37 tab_contents->render_view_host(), L"",
38 L"window.domAutomationController.send(ContentHandlerPluginCreated());",
39 content_handler_plugin));
40 }
41 };
42
43 // Test that the NaCl plugin isn't blocked for Webstore extensions.
44 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, WebStoreExtension) {
45 ASSERT_TRUE(test_server()->Start());
46
47 FilePath path = test_data_dir_.AppendASCII("native_client");
48 ASSERT_TRUE(InstallExtensionFromWebstore(path, 1));
49
50 ExtensionService* service = browser()->profile()->GetExtensionService();
51 const Extension* extension =
52 service->GetExtensionById(last_loaded_extension_id_, false);
53 ASSERT_TRUE(extension);
54
55 ui_test_utils::NavigateToURL(
56 browser(), extension->GetResourceURL("test.html"));
57
58 bool embedded_plugin = false;
59 bool content_handler_plugin = false;
60 CheckPluginsCreated(browser()->GetSelectedTabContents(),
61 &embedded_plugin,
62 &content_handler_plugin);
63 EXPECT_TRUE(embedded_plugin && content_handler_plugin);
64 }
65
66 // Test that the NaCl plugin is blocked for non-Webstore extensions.
67 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, NonWebStoreExtension) {
68 ASSERT_TRUE(test_server()->Start());
69
70 FilePath path = test_data_dir_.AppendASCII("native_client");
71 ASSERT_TRUE(InstallExtension(path, 1));
72
73 ExtensionService* service = browser()->profile()->GetExtensionService();
74 const Extension* extension =
75 service->GetExtensionById(last_loaded_extension_id_, false);
76 ASSERT_TRUE(extension);
77
78 ui_test_utils::NavigateToURL(
79 browser(), extension->GetResourceURL("test.html"));
80
81 bool embedded_plugin = false;
82 bool content_handler_plugin = false;
83 CheckPluginsCreated(browser()->GetSelectedTabContents(),
84 &embedded_plugin,
85 &content_handler_plugin);
86 EXPECT_FALSE(embedded_plugin && content_handler_plugin);
87 }
88
89 // Test that the NaCl plugin isn't blocked for component extensions.
90 IN_PROC_BROWSER_TEST_F(NaClExtensionTest, ComponentExtension) {
91 ASSERT_TRUE(test_server()->Start());
92
93 FilePath file_path = test_data_dir_.AppendASCII("native_client");
94 LoadExtensionAsComponent(file_path);
95
96 ExtensionService* service = browser()->profile()->GetExtensionService();
97 const Extension* extension =
98 service->GetExtensionById("bjjcibdiodkkeanflmiijlcfieiemced", false);
99 ASSERT_TRUE(extension);
100
101 ui_test_utils::NavigateToURL(
102 browser(), extension->GetResourceURL("test.html"));
103
104 bool embedded_plugin = false;
105 bool content_handler_plugin = false;
106 CheckPluginsCreated(browser()->GetSelectedTabContents(),
107 &embedded_plugin,
108 &content_handler_plugin);
109 EXPECT_TRUE(embedded_plugin && content_handler_plugin);
asargent_no_longer_on_chrome 2011/08/09 19:23:34 nit: It looks like the body of these 3 tests are i
bbudge 2011/08/11 18:56:02 Done.
110 }
111
112 } // namespace
113
OLDNEW
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698