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

Unified Diff: chrome/browser/guest_view/extension_options/extension_options_apitest.cc

Issue 429763002: Implement createfailed event for <extensionoptions> (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Remove self hack Created 6 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 | « no previous file | chrome/browser/guest_view/extension_options/extension_options_guest.cc » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: chrome/browser/guest_view/extension_options/extension_options_apitest.cc
diff --git a/chrome/browser/guest_view/extension_options/extension_options_apitest.cc b/chrome/browser/guest_view/extension_options/extension_options_apitest.cc
index af96f02598a0da2fbf0b011631a3e1afb3cbc170..1de892f5a2437e807bcc856aa1b6d2269a12025d 100644
--- a/chrome/browser/guest_view/extension_options/extension_options_apitest.cc
+++ b/chrome/browser/guest_view/extension_options/extension_options_apitest.cc
@@ -2,7 +2,10 @@
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.
+#include "base/files/file_path.h"
+#include "base/strings/stringprintf.h"
#include "chrome/browser/extensions/extension_apitest.h"
+#include "chrome/test/base/ui_test_utils.h"
#include "extensions/common/feature_switch.h"
#include "extensions/common/switches.h"
@@ -12,22 +15,58 @@ using extensions::FeatureSwitch;
class ExtensionOptionsApiTest : public ExtensionApiTest {
private:
virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
+ ExtensionApiTest::SetUpCommandLine(command_line);
+
+ enable_options_.reset(new FeatureSwitch::ScopedOverride(
+ FeatureSwitch::embedded_extension_options(), true));
// Need to add a command line flag as well as a FeatureSwitch because the
// FeatureSwitch is not copied over to the renderer process from the
// browser process.
command_line->AppendSwitch(
extensions::switches::kEnableEmbeddedExtensionOptions);
- ExtensionApiTest::SetUpCommandLine(command_line);
}
+
+ scoped_ptr<FeatureSwitch::ScopedOverride> enable_options_;
};
IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest, ExtensionCanEmbedOwnOptions) {
- FeatureSwitch::ScopedOverride enable_options(
- FeatureSwitch::embedded_extension_options(), true);
-
- const Extension* extension = InstallExtension(
- test_data_dir_.AppendASCII("extension_options").AppendASCII("embed_self"),
- 1);
- ASSERT_TRUE(extension);
+ base::FilePath extension_dir =
+ test_data_dir_.AppendASCII("extension_options").AppendASCII("embed_self");
+ ASSERT_TRUE(InstallExtension(extension_dir, 1));
ASSERT_TRUE(RunExtensionSubtest("extension_options/embed_self", "test.html"));
}
+
+IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest,
+ ShouldNotEmbedOtherExtensionsOptions) {
+ base::FilePath dir = test_data_dir_.AppendASCII("extension_options")
+ .AppendASCII("embed_other");
+
+ const Extension* embedder = InstallExtension(dir.AppendASCII("embedder"), 1);
+ const Extension* embedded = InstallExtension(dir.AppendASCII("embedded"), 1);
+
+ ASSERT_TRUE(embedder);
+ ASSERT_TRUE(embedded);
+
+ // Since the extension id of the embedded extension is not always the same,
+ // store the embedded extension id in the embedder's storage before running
+ // the tests.
+ std::string script = base::StringPrintf(
+ "chrome.storage.local.set({'embeddedId': '%s'}, function() {"
+ "window.domAutomationController.send('done injecting');});",
+ embedded->id().c_str());
+
+ ExecuteScriptInBackgroundPage(embedder->id(), script);
+ ResultCatcher catcher;
+ ui_test_utils::NavigateToURL(browser(),
+ embedder->GetResourceURL("test.html"));
+ ASSERT_TRUE(catcher.GetNextResult());
+}
+
+IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest,
+ CannotEmbedUsingInvalidExtensionIds) {
+ ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("extension_options")
+ .AppendASCII("embed_invalid"),
+ 1));
+ ASSERT_TRUE(
+ RunExtensionSubtest("extension_options/embed_invalid", "test.html"));
+}
« no previous file with comments | « no previous file | chrome/browser/guest_view/extension_options/extension_options_guest.cc » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698