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

Unified 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 side-by-side diff with in-line comments
Download patch
« no previous file with comments | « chrome/browser/extensions/extension_browsertest.cc ('k') | chrome/chrome_tests.gypi » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/extensions/extension_nacl_browsertest.cc
===================================================================
--- chrome/browser/extensions/extension_nacl_browsertest.cc (revision 0)
+++ chrome/browser/extensions/extension_nacl_browsertest.cc (revision 0)
@@ -0,0 +1,113 @@
+// Copyright (c) 2011 The Chromium Authors. All rights reserved.
+// Use of this source code is governed by a BSD-style license that can be
+// found in the LICENSE file.
+
+#include "base/command_line.h"
+#include "base/utf_string_conversions.h"
+#include "chrome/browser/extensions/crx_installer.h"
+#include "chrome/browser/extensions/extension_browsertest.h"
+#include "chrome/browser/extensions/extension_service.h"
+#include "chrome/browser/prefs/pref_service.h"
+#include "chrome/browser/profiles/profile.h"
+#include "chrome/browser/ui/browser.h"
+#include "chrome/common/chrome_switches.h"
+#include "chrome/common/pref_names.h"
+#include "chrome/test/base/ui_test_utils.h"
+#include "content/browser/tab_contents/tab_contents.h"
+
+namespace {
+
+// This class tests that the Native Client plugin is blocked unless the
+// .nexe is part of an extension from the Chrome Webstore.
+class NaClExtensionTest : public ExtensionBrowserTest {
+ public:
+ NaClExtensionTest() {
+ EnableDOMAutomation();
+ }
+
+ protected:
+ void CheckPluginsCreated(TabContents* tab_contents,
+ bool* embedded_plugin,
+ bool* content_handler_plugin) {
+ ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
+ tab_contents->render_view_host(), L"",
+ L"window.domAutomationController.send(EmbeddedPluginCreated());",
+ embedded_plugin));
+ ASSERT_TRUE(ui_test_utils::ExecuteJavaScriptAndExtractBool(
+ tab_contents->render_view_host(), L"",
+ L"window.domAutomationController.send(ContentHandlerPluginCreated());",
+ content_handler_plugin));
+ }
+};
+
+// Test that the NaCl plugin isn't blocked for Webstore extensions.
+IN_PROC_BROWSER_TEST_F(NaClExtensionTest, WebStoreExtension) {
+ ASSERT_TRUE(test_server()->Start());
+
+ FilePath path = test_data_dir_.AppendASCII("native_client");
+ ASSERT_TRUE(InstallExtensionFromWebstore(path, 1));
+
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+ const Extension* extension =
+ service->GetExtensionById(last_loaded_extension_id_, false);
+ ASSERT_TRUE(extension);
+
+ ui_test_utils::NavigateToURL(
+ browser(), extension->GetResourceURL("test.html"));
+
+ bool embedded_plugin = false;
+ bool content_handler_plugin = false;
+ CheckPluginsCreated(browser()->GetSelectedTabContents(),
+ &embedded_plugin,
+ &content_handler_plugin);
+ EXPECT_TRUE(embedded_plugin && content_handler_plugin);
+}
+
+// Test that the NaCl plugin is blocked for non-Webstore extensions.
+IN_PROC_BROWSER_TEST_F(NaClExtensionTest, NonWebStoreExtension) {
+ ASSERT_TRUE(test_server()->Start());
+
+ FilePath path = test_data_dir_.AppendASCII("native_client");
+ ASSERT_TRUE(InstallExtension(path, 1));
+
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+ const Extension* extension =
+ service->GetExtensionById(last_loaded_extension_id_, false);
+ ASSERT_TRUE(extension);
+
+ ui_test_utils::NavigateToURL(
+ browser(), extension->GetResourceURL("test.html"));
+
+ bool embedded_plugin = false;
+ bool content_handler_plugin = false;
+ CheckPluginsCreated(browser()->GetSelectedTabContents(),
+ &embedded_plugin,
+ &content_handler_plugin);
+ EXPECT_FALSE(embedded_plugin && content_handler_plugin);
+}
+
+// Test that the NaCl plugin isn't blocked for component extensions.
+IN_PROC_BROWSER_TEST_F(NaClExtensionTest, ComponentExtension) {
+ ASSERT_TRUE(test_server()->Start());
+
+ FilePath file_path = test_data_dir_.AppendASCII("native_client");
+ LoadExtensionAsComponent(file_path);
+
+ ExtensionService* service = browser()->profile()->GetExtensionService();
+ const Extension* extension =
+ service->GetExtensionById("bjjcibdiodkkeanflmiijlcfieiemced", false);
+ ASSERT_TRUE(extension);
+
+ ui_test_utils::NavigateToURL(
+ browser(), extension->GetResourceURL("test.html"));
+
+ bool embedded_plugin = false;
+ bool content_handler_plugin = false;
+ CheckPluginsCreated(browser()->GetSelectedTabContents(),
+ &embedded_plugin,
+ &content_handler_plugin);
+ 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.
+}
+
+} // namespace
+
Property changes on: chrome\browser\extensions\extension_nacl_browsertest.cc
___________________________________________________________________
Added: svn:eol-style
+ LF
« 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