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

Side by Side 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 unified diff | 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 »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 // Copyright 2014 The Chromium Authors. All rights reserved. 1 // Copyright 2014 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/files/file_path.h"
6 #include "base/strings/stringprintf.h"
5 #include "chrome/browser/extensions/extension_apitest.h" 7 #include "chrome/browser/extensions/extension_apitest.h"
8 #include "chrome/test/base/ui_test_utils.h"
6 #include "extensions/common/feature_switch.h" 9 #include "extensions/common/feature_switch.h"
7 #include "extensions/common/switches.h" 10 #include "extensions/common/switches.h"
8 11
9 using extensions::Extension; 12 using extensions::Extension;
10 using extensions::FeatureSwitch; 13 using extensions::FeatureSwitch;
11 14
12 class ExtensionOptionsApiTest : public ExtensionApiTest { 15 class ExtensionOptionsApiTest : public ExtensionApiTest {
13 private: 16 private:
14 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { 17 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE {
18 ExtensionApiTest::SetUpCommandLine(command_line);
19
20 enable_options_.reset(new FeatureSwitch::ScopedOverride(
21 FeatureSwitch::embedded_extension_options(), true));
15 // Need to add a command line flag as well as a FeatureSwitch because the 22 // Need to add a command line flag as well as a FeatureSwitch because the
16 // FeatureSwitch is not copied over to the renderer process from the 23 // FeatureSwitch is not copied over to the renderer process from the
17 // browser process. 24 // browser process.
18 command_line->AppendSwitch( 25 command_line->AppendSwitch(
19 extensions::switches::kEnableEmbeddedExtensionOptions); 26 extensions::switches::kEnableEmbeddedExtensionOptions);
20 ExtensionApiTest::SetUpCommandLine(command_line);
21 } 27 }
28
29 scoped_ptr<FeatureSwitch::ScopedOverride> enable_options_;
22 }; 30 };
23 31
24 IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest, ExtensionCanEmbedOwnOptions) { 32 IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest, ExtensionCanEmbedOwnOptions) {
25 FeatureSwitch::ScopedOverride enable_options( 33 base::FilePath extension_dir =
26 FeatureSwitch::embedded_extension_options(), true); 34 test_data_dir_.AppendASCII("extension_options").AppendASCII("embed_self");
27 35 ASSERT_TRUE(InstallExtension(extension_dir, 1));
28 const Extension* extension = InstallExtension(
29 test_data_dir_.AppendASCII("extension_options").AppendASCII("embed_self"),
30 1);
31 ASSERT_TRUE(extension);
32 ASSERT_TRUE(RunExtensionSubtest("extension_options/embed_self", "test.html")); 36 ASSERT_TRUE(RunExtensionSubtest("extension_options/embed_self", "test.html"));
33 } 37 }
38
39 IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest,
40 ShouldNotEmbedOtherExtensionsOptions) {
41 base::FilePath dir = test_data_dir_.AppendASCII("extension_options")
42 .AppendASCII("embed_other");
43
44 const Extension* embedder = InstallExtension(dir.AppendASCII("embedder"), 1);
45 const Extension* embedded = InstallExtension(dir.AppendASCII("embedded"), 1);
46
47 ASSERT_TRUE(embedder);
48 ASSERT_TRUE(embedded);
49
50 // Since the extension id of the embedded extension is not always the same,
51 // store the embedded extension id in the embedder's storage before running
52 // the tests.
53 std::string script = base::StringPrintf(
54 "chrome.storage.local.set({'embeddedId': '%s'}, function() {"
55 "window.domAutomationController.send('done injecting');});",
56 embedded->id().c_str());
57
58 ExecuteScriptInBackgroundPage(embedder->id(), script);
59 ResultCatcher catcher;
60 ui_test_utils::NavigateToURL(browser(),
61 embedder->GetResourceURL("test.html"));
62 ASSERT_TRUE(catcher.GetNextResult());
63 }
64
65 IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest,
66 CannotEmbedUsingInvalidExtensionIds) {
67 ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("extension_options")
68 .AppendASCII("embed_invalid"),
69 1));
70 ASSERT_TRUE(
71 RunExtensionSubtest("extension_options/embed_invalid", "test.html"));
72 }
OLDNEW
« 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