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 "base/files/file_path.h" |
6 #include "base/strings/stringprintf.h" | 6 #include "base/strings/stringprintf.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/test/base/ui_test_utils.h" | 8 #include "chrome/test/base/ui_test_utils.h" |
9 #include "extensions/common/feature_switch.h" | 9 #include "extensions/common/feature_switch.h" |
10 #include "extensions/common/switches.h" | 10 #include "extensions/common/switches.h" |
| 11 #include "extensions/test/result_catcher.h" |
11 | 12 |
12 using extensions::Extension; | 13 using extensions::Extension; |
13 using extensions::FeatureSwitch; | 14 using extensions::FeatureSwitch; |
14 | 15 |
15 class ExtensionOptionsApiTest : public ExtensionApiTest { | 16 class ExtensionOptionsApiTest : public ExtensionApiTest { |
16 private: | 17 private: |
17 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { | 18 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
18 ExtensionApiTest::SetUpCommandLine(command_line); | 19 ExtensionApiTest::SetUpCommandLine(command_line); |
19 | 20 |
20 enable_options_.reset(new FeatureSwitch::ScopedOverride( | 21 enable_options_.reset(new FeatureSwitch::ScopedOverride( |
(...skipping 28 matching lines...) Expand all Loading... |
49 | 50 |
50 // Since the extension id of the embedded extension is not always the same, | 51 // 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 // store the embedded extension id in the embedder's storage before running |
52 // the tests. | 53 // the tests. |
53 std::string script = base::StringPrintf( | 54 std::string script = base::StringPrintf( |
54 "chrome.storage.local.set({'embeddedId': '%s'}, function() {" | 55 "chrome.storage.local.set({'embeddedId': '%s'}, function() {" |
55 "window.domAutomationController.send('done injecting');});", | 56 "window.domAutomationController.send('done injecting');});", |
56 embedded->id().c_str()); | 57 embedded->id().c_str()); |
57 | 58 |
58 ExecuteScriptInBackgroundPage(embedder->id(), script); | 59 ExecuteScriptInBackgroundPage(embedder->id(), script); |
59 ResultCatcher catcher; | 60 extensions::ResultCatcher catcher; |
60 ui_test_utils::NavigateToURL(browser(), | 61 ui_test_utils::NavigateToURL(browser(), |
61 embedder->GetResourceURL("test.html")); | 62 embedder->GetResourceURL("test.html")); |
62 ASSERT_TRUE(catcher.GetNextResult()); | 63 ASSERT_TRUE(catcher.GetNextResult()); |
63 } | 64 } |
64 | 65 |
65 IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest, | 66 IN_PROC_BROWSER_TEST_F(ExtensionOptionsApiTest, |
66 CannotEmbedUsingInvalidExtensionIds) { | 67 CannotEmbedUsingInvalidExtensionIds) { |
67 ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("extension_options") | 68 ASSERT_TRUE(InstallExtension(test_data_dir_.AppendASCII("extension_options") |
68 .AppendASCII("embed_invalid"), | 69 .AppendASCII("embed_invalid"), |
69 1)); | 70 1)); |
70 ASSERT_TRUE( | 71 ASSERT_TRUE( |
71 RunExtensionSubtest("extension_options/embed_invalid", "test.html")); | 72 RunExtensionSubtest("extension_options/embed_invalid", "test.html")); |
72 } | 73 } |
OLD | NEW |