OLD | NEW |
---|---|
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" | |
5 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
7 #include "chrome/test/base/ui_test_utils.h" | |
6 #include "extensions/common/feature_switch.h" | 8 #include "extensions/common/feature_switch.h" |
7 #include "extensions/common/switches.h" | 9 #include "extensions/common/switches.h" |
8 | 10 |
9 using extensions::Extension; | 11 using extensions::Extension; |
10 using extensions::FeatureSwitch; | 12 using extensions::FeatureSwitch; |
11 | 13 |
12 class ExtensionOptionsApiTest : public ExtensionApiTest { | 14 class ExtensionOptionsApiTest : public ExtensionApiTest { |
13 private: | 15 private: |
14 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 16 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
17 enable_options_.reset(new FeatureSwitch::ScopedOverride( | |
18 FeatureSwitch::embedded_extension_options(), true)); | |
15 // Need to add a command line flag as well as a FeatureSwitch because the | 19 // 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 | 20 // FeatureSwitch is not copied over to the renderer process from the |
17 // browser process. | 21 // browser process. |
18 command_line->AppendSwitch( | 22 command_line->AppendSwitch( |
19 extensions::switches::kEnableEmbeddedExtensionOptions); | 23 extensions::switches::kEnableEmbeddedExtensionOptions); |
20 ExtensionApiTest::SetUpCommandLine(command_line); | 24 ExtensionApiTest::SetUpCommandLine(command_line); |
not at google - send to devlin
2014/08/04 19:12:03
ideally call the superclass SetUpCommandLine first
ericzeng
2014/08/04 21:15:33
Done.
| |
21 } | 25 } |
26 | |
27 scoped_ptr<FeatureSwitch::ScopedOverride> enable_options_; | |
22 }; | 28 }; |
23 | 29 |
24 IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest, ExtensionCanEmbedOwnOptions) { | 30 IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest, ExtensionCanEmbedOwnOptions) { |
31 base::FilePath extension_dir = | |
32 test_data_dir_.AppendASCII("extension_options").AppendASCII("embed_self"); | |
33 ASSERT_TRUE(InstallExtension(extension_dir, 1)); | |
34 ASSERT_TRUE(RunExtensionSubtest("extension_options/embed_self", "test.html")); | |
35 } | |
36 | |
37 IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest, | |
38 ShouldNotEmbedOtherExtensionsOptions) { | |
25 FeatureSwitch::ScopedOverride enable_options( | 39 FeatureSwitch::ScopedOverride enable_options( |
26 FeatureSwitch::embedded_extension_options(), true); | 40 FeatureSwitch::embedded_extension_options(), true); |
41 base::FilePath dir = test_data_dir_.AppendASCII("extension_options") | |
42 .AppendASCII("embed_other"); | |
27 | 43 |
28 const Extension* extension = InstallExtension( | 44 const Extension* embedder = InstallExtension(dir.AppendASCII("embedder"), 1); |
29 test_data_dir_.AppendASCII("extension_options").AppendASCII("embed_self"), | 45 const Extension* embedded = InstallExtension(dir.AppendASCII("embedded"), 1); |
30 1); | 46 |
31 ASSERT_TRUE(extension); | 47 ASSERT_TRUE(embedder); |
32 ASSERT_TRUE(RunExtensionSubtest("extension_options/embed_self", "test.html")); | 48 ASSERT_TRUE(embedded); |
49 | |
50 std::stringstream script; | |
not at google - send to devlin
2014/08/04 19:12:03
don't use stringstream. It's just as easy to const
ericzeng
2014/08/04 21:15:33
Done.
| |
51 script << "chrome.storage.local.set(" | |
52 << "{'embeddedId': '" << embedded->id() << "'}, function() {" | |
53 << "window.domAutomationController.send('done injecting');" | |
54 << "});"; | |
55 | |
56 ExecuteScriptInBackgroundPage(embedder->id(), script.str()); | |
57 ResultCatcher catcher; | |
58 ui_test_utils::NavigateToURL(browser(), | |
59 embedder->GetResourceURL("test.html")); | |
60 ASSERT_TRUE(catcher.GetNextResult()); | |
33 } | 61 } |
OLD | NEW |