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/file_util.h" | 5 #include "base/file_util.h" |
6 #include "base/files/file_path.h" | 6 #include "base/files/file_path.h" |
7 #include "base/path_service.h" | 7 #include "base/path_service.h" |
8 #include "base/values.h" | 8 #include "base/values.h" |
9 #include "chrome/browser/extensions/extension_apitest.h" | 9 #include "chrome/browser/extensions/extension_apitest.h" |
10 #include "chrome/browser/extensions/extension_test_message_listener.h" | 10 #include "chrome/browser/extensions/extension_test_message_listener.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/common/chrome_paths.h" | 13 #include "chrome/common/chrome_paths.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 14 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/browser/render_frame_host.h" | 15 #include "content/public/browser/render_frame_host.h" |
16 #include "content/public/browser/web_contents.h" | 16 #include "content/public/browser/web_contents.h" |
17 #include "content/public/test/browser_test_utils.h" | 17 #include "content/public/test/browser_test_utils.h" |
18 #include "extensions/browser/event_router.h" | 18 #include "extensions/browser/event_router.h" |
19 #include "extensions/common/api/test.h" | 19 #include "extensions/common/api/test.h" |
20 #include "extensions/common/extension.h" | 20 #include "extensions/common/extension.h" |
| 21 #include "extensions/common/feature_switch.h" |
| 22 #include "extensions/common/switches.h" |
21 #include "testing/gtest/include/gtest/gtest.h" | 23 #include "testing/gtest/include/gtest/gtest.h" |
22 | 24 |
23 namespace extensions { | 25 namespace extensions { |
24 | 26 |
25 namespace OnMessage = core_api::test::OnMessage; | 27 namespace OnMessage = core_api::test::OnMessage; |
26 | 28 |
27 namespace { | 29 namespace { |
28 | 30 |
29 void FindFrame(const GURL& url, | 31 void FindFrame(const GURL& url, |
30 content::RenderFrameHost** out, | 32 content::RenderFrameHost** out, |
(...skipping 70 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
101 browser()->tab_strip_model()->GetActiveWebContents(); | 103 browser()->tab_strip_model()->GetActiveWebContents(); |
102 | 104 |
103 if (active_web_contents->GetLastCommittedURL() == frame_url) | 105 if (active_web_contents->GetLastCommittedURL() == frame_url) |
104 return active_web_contents->GetMainFrame(); | 106 return active_web_contents->GetMainFrame(); |
105 | 107 |
106 content::RenderFrameHost* frame_host = NULL; | 108 content::RenderFrameHost* frame_host = NULL; |
107 active_web_contents->ForEachFrame( | 109 active_web_contents->ForEachFrame( |
108 base::Bind(&FindFrame, frame_url, &frame_host)); | 110 base::Bind(&FindFrame, frame_url, &frame_host)); |
109 return frame_host; | 111 return frame_host; |
110 } | 112 } |
| 113 |
| 114 virtual void SetUpCommandLine(CommandLine* command_line) OVERRIDE { |
| 115 FeatureSwitch::ScopedOverride enable_options( |
| 116 FeatureSwitch::embedded_extension_options(), true); |
| 117 // Need to add a command line flag as well as a FeatureSwitch because the |
| 118 // FeatureSwitch is not copied over to the renderer process from the |
| 119 // browser process. |
| 120 command_line->AppendSwitch(switches::kEnableEmbeddedExtensionOptions); |
| 121 ExtensionApiTest::SetUpCommandLine(command_line); |
| 122 } |
| 123 |
| 124 scoped_ptr<FeatureSwitch::ScopedOverride> enable_options_; |
111 }; | 125 }; |
112 | 126 |
113 IN_PROC_BROWSER_TEST_F(ExtensionWebUITest, SanityCheckAvailableAPIs) { | 127 IN_PROC_BROWSER_TEST_F(ExtensionWebUITest, SanityCheckAvailableAPIs) { |
114 ASSERT_TRUE(RunTestOnExtensions("sanity_check_available_apis.js")); | 128 ASSERT_TRUE(RunTestOnExtensions("sanity_check_available_apis.js")); |
115 } | 129 } |
116 | 130 |
117 IN_PROC_BROWSER_TEST_F(ExtensionWebUITest, SanityCheckUnavailableAPIs) { | 131 IN_PROC_BROWSER_TEST_F(ExtensionWebUITest, SanityCheckUnavailableAPIs) { |
118 ASSERT_TRUE(RunTestOnAbout("sanity_check_available_apis.js")); | 132 ASSERT_TRUE(RunTestOnAbout("sanity_check_available_apis.js")); |
119 } | 133 } |
120 | 134 |
(...skipping 39 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
160 ASSERT_TRUE(RunTestOnExtensions("runtime_last_error.js")); | 174 ASSERT_TRUE(RunTestOnExtensions("runtime_last_error.js")); |
161 | 175 |
162 ASSERT_TRUE(listener->WaitUntilSatisfied()); | 176 ASSERT_TRUE(listener->WaitUntilSatisfied()); |
163 listener->ReplyWithError("unknown host"); | 177 listener->ReplyWithError("unknown host"); |
164 | 178 |
165 listener.reset(new ExtensionTestMessageListener(false)); | 179 listener.reset(new ExtensionTestMessageListener(false)); |
166 ASSERT_TRUE(listener->WaitUntilSatisfied()); | 180 ASSERT_TRUE(listener->WaitUntilSatisfied()); |
167 EXPECT_EQ("true", listener->message()); | 181 EXPECT_EQ("true", listener->message()); |
168 } | 182 } |
169 | 183 |
| 184 IN_PROC_BROWSER_TEST_F(ExtensionWebUITest, CanEmbedExtensionOptions) { |
| 185 scoped_ptr<ExtensionTestMessageListener> listener( |
| 186 new ExtensionTestMessageListener("ready", true)); |
| 187 |
| 188 const Extension* extension = InstallExtension( |
| 189 test_data_dir_.AppendASCII("extension_options").AppendASCII("embed_self"), |
| 190 1); |
| 191 ASSERT_TRUE(extension); |
| 192 |
| 193 ASSERT_TRUE(RunTestOnExtensions("can_embed_extension_options.js")); |
| 194 |
| 195 ASSERT_TRUE(listener->WaitUntilSatisfied()); |
| 196 listener->Reply(extension->id()); |
| 197 listener.reset(new ExtensionTestMessageListener("guest loaded", false)); |
| 198 ASSERT_TRUE(listener->WaitUntilSatisfied()); |
| 199 } |
| 200 |
170 } // namespace | 201 } // namespace |
171 | 202 |
172 } // namespace extensions | 203 } // namespace extensions |
OLD | NEW |