OLD | NEW |
1 // Copyright (c) 2012 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2012 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 "chrome/app/chrome_command_ids.h" | 5 #include "chrome/app/chrome_command_ids.h" |
6 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" | 6 #include "chrome/browser/extensions/api/web_navigation/web_navigation_api.h" |
7 #include "chrome/browser/extensions/extension_apitest.h" | 7 #include "chrome/browser/extensions/extension_apitest.h" |
8 #include "chrome/browser/extensions/extension_service.h" | 8 #include "chrome/browser/extensions/extension_service.h" |
9 #include "chrome/browser/profiles/profile.h" | 9 #include "chrome/browser/profiles/profile.h" |
10 #include "chrome/browser/tab_contents/render_view_context_menu.h" | 10 #include "chrome/browser/tab_contents/render_view_context_menu.h" |
11 #include "chrome/browser/ui/browser.h" | 11 #include "chrome/browser/ui/browser.h" |
12 #include "chrome/browser/ui/browser_finder.h" | 12 #include "chrome/browser/ui/browser_finder.h" |
| 13 #include "chrome/browser/ui/browser_tabstrip.h" |
13 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
14 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
15 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
16 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
17 #include "content/public/common/context_menu_params.h" | 18 #include "content/public/common/context_menu_params.h" |
18 #include "net/base/mock_host_resolver.h" | 19 #include "net/base/mock_host_resolver.h" |
19 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" | 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebContextMenuData.h" |
20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
21 | 22 |
22 using content::WebContents; | 23 using content::WebContents; |
(...skipping 153 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
176 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationUserAction) { | 177 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationUserAction) { |
177 FrameNavigationState::set_allow_extension_scheme(true); | 178 FrameNavigationState::set_allow_extension_scheme(true); |
178 | 179 |
179 CommandLine::ForCurrentProcess()->AppendSwitch( | 180 CommandLine::ForCurrentProcess()->AppendSwitch( |
180 switches::kAllowLegacyExtensionManifests); | 181 switches::kAllowLegacyExtensionManifests); |
181 | 182 |
182 // Wait for the extension to set itself up and return control to us. | 183 // Wait for the extension to set itself up and return control to us. |
183 ASSERT_TRUE( | 184 ASSERT_TRUE( |
184 RunExtensionSubtest("webnavigation", "test_userAction.html")) << message_; | 185 RunExtensionSubtest("webnavigation", "test_userAction.html")) << message_; |
185 | 186 |
186 WebContents* tab = browser()->GetActiveWebContents(); | 187 WebContents* tab = chrome::GetActiveWebContents(browser()); |
187 ui_test_utils::WaitForLoadStop(tab); | 188 ui_test_utils::WaitForLoadStop(tab); |
188 | 189 |
189 ResultCatcher catcher; | 190 ResultCatcher catcher; |
190 | 191 |
191 ExtensionService* service = browser()->profile()->GetExtensionService(); | 192 ExtensionService* service = browser()->profile()->GetExtensionService(); |
192 const extensions::Extension* extension = | 193 const extensions::Extension* extension = |
193 service->GetExtensionById(last_loaded_extension_id_, false); | 194 service->GetExtensionById(last_loaded_extension_id_, false); |
194 GURL url = extension->GetResourceURL("userAction/a.html"); | 195 GURL url = extension->GetResourceURL("userAction/a.html"); |
195 | 196 |
196 ui_test_utils::NavigateToURL(browser(), url); | 197 ui_test_utils::NavigateToURL(browser(), url); |
(...skipping 17 matching lines...) Expand all Loading... |
214 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationRequestOpenTab) { | 215 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationRequestOpenTab) { |
215 FrameNavigationState::set_allow_extension_scheme(true); | 216 FrameNavigationState::set_allow_extension_scheme(true); |
216 | 217 |
217 CommandLine::ForCurrentProcess()->AppendSwitch( | 218 CommandLine::ForCurrentProcess()->AppendSwitch( |
218 switches::kAllowLegacyExtensionManifests); | 219 switches::kAllowLegacyExtensionManifests); |
219 | 220 |
220 // Wait for the extension to set itself up and return control to us. | 221 // Wait for the extension to set itself up and return control to us. |
221 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_requestOpenTab.html")) | 222 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_requestOpenTab.html")) |
222 << message_; | 223 << message_; |
223 | 224 |
224 WebContents* tab = browser()->GetActiveWebContents(); | 225 WebContents* tab = chrome::GetActiveWebContents(browser()); |
225 ui_test_utils::WaitForLoadStop(tab); | 226 ui_test_utils::WaitForLoadStop(tab); |
226 | 227 |
227 ResultCatcher catcher; | 228 ResultCatcher catcher; |
228 | 229 |
229 ExtensionService* service = browser()->profile()->GetExtensionService(); | 230 ExtensionService* service = browser()->profile()->GetExtensionService(); |
230 const extensions::Extension* extension = | 231 const extensions::Extension* extension = |
231 service->GetExtensionById(last_loaded_extension_id_, false); | 232 service->GetExtensionById(last_loaded_extension_id_, false); |
232 GURL url = extension->GetResourceURL("requestOpenTab/a.html"); | 233 GURL url = extension->GetResourceURL("requestOpenTab/a.html"); |
233 | 234 |
234 ui_test_utils::NavigateToURL(browser(), url); | 235 ui_test_utils::NavigateToURL(browser(), url); |
(...skipping 16 matching lines...) Expand all Loading... |
251 FrameNavigationState::set_allow_extension_scheme(true); | 252 FrameNavigationState::set_allow_extension_scheme(true); |
252 ASSERT_TRUE(StartTestServer()); | 253 ASSERT_TRUE(StartTestServer()); |
253 | 254 |
254 CommandLine::ForCurrentProcess()->AppendSwitch( | 255 CommandLine::ForCurrentProcess()->AppendSwitch( |
255 switches::kAllowLegacyExtensionManifests); | 256 switches::kAllowLegacyExtensionManifests); |
256 | 257 |
257 // Wait for the extension to set itself up and return control to us. | 258 // Wait for the extension to set itself up and return control to us. |
258 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_targetBlank.html")) | 259 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_targetBlank.html")) |
259 << message_; | 260 << message_; |
260 | 261 |
261 WebContents* tab = browser()->GetActiveWebContents(); | 262 WebContents* tab = chrome::GetActiveWebContents(browser()); |
262 ui_test_utils::WaitForLoadStop(tab); | 263 ui_test_utils::WaitForLoadStop(tab); |
263 | 264 |
264 ResultCatcher catcher; | 265 ResultCatcher catcher; |
265 | 266 |
266 GURL url = test_server()->GetURL( | 267 GURL url = test_server()->GetURL( |
267 "files/extensions/api_test/webnavigation/targetBlank/a.html"); | 268 "files/extensions/api_test/webnavigation/targetBlank/a.html"); |
268 | 269 |
269 browser::NavigateParams params(browser(), url, content::PAGE_TRANSITION_LINK); | 270 browser::NavigateParams params(browser(), url, content::PAGE_TRANSITION_LINK); |
270 ui_test_utils::NavigateToURL(¶ms); | 271 ui_test_utils::NavigateToURL(¶ms); |
271 | 272 |
(...skipping 23 matching lines...) Expand all Loading... |
295 ASSERT_TRUE(RunExtensionSubtest( | 296 ASSERT_TRUE(RunExtensionSubtest( |
296 "webnavigation", "test_targetBlank.html", | 297 "webnavigation", "test_targetBlank.html", |
297 ExtensionApiTest::kFlagEnableIncognito)) << message_; | 298 ExtensionApiTest::kFlagEnableIncognito)) << message_; |
298 | 299 |
299 ResultCatcher catcher; | 300 ResultCatcher catcher; |
300 | 301 |
301 GURL url = test_server()->GetURL( | 302 GURL url = test_server()->GetURL( |
302 "files/extensions/api_test/webnavigation/targetBlank/a.html"); | 303 "files/extensions/api_test/webnavigation/targetBlank/a.html"); |
303 | 304 |
304 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), url); | 305 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), url); |
305 WebContents* tab = browser::FindTabbedBrowser( | 306 WebContents* tab = chrome::GetActiveWebContents(browser::FindTabbedBrowser( |
306 browser()->profile()->GetOffTheRecordProfile(), false)-> | 307 browser()->profile()->GetOffTheRecordProfile(), false)); |
307 GetActiveWebContents(); | |
308 | 308 |
309 // There's a link with target=_blank on a.html. Click on it to open it in a | 309 // There's a link with target=_blank on a.html. Click on it to open it in a |
310 // new tab. | 310 // new tab. |
311 WebKit::WebMouseEvent mouse_event; | 311 WebKit::WebMouseEvent mouse_event; |
312 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 312 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
313 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 313 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
314 mouse_event.x = 7; | 314 mouse_event.x = 7; |
315 mouse_event.y = 7; | 315 mouse_event.y = 7; |
316 mouse_event.clickCount = 1; | 316 mouse_event.clickCount = 1; |
317 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 317 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
318 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 318 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
319 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 319 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
320 | 320 |
321 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 321 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
322 } | 322 } |
323 | 323 |
324 } // namespace extensions | 324 } // namespace extensions |
OLD | NEW |