| 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" |
| (...skipping 165 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 176 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationUserAction) { | 176 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationUserAction) { |
| 177 FrameNavigationState::set_allow_extension_scheme(true); | 177 FrameNavigationState::set_allow_extension_scheme(true); |
| 178 | 178 |
| 179 CommandLine::ForCurrentProcess()->AppendSwitch( | 179 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 180 switches::kAllowLegacyExtensionManifests); | 180 switches::kAllowLegacyExtensionManifests); |
| 181 | 181 |
| 182 // Wait for the extension to set itself up and return control to us. | 182 // Wait for the extension to set itself up and return control to us. |
| 183 ASSERT_TRUE( | 183 ASSERT_TRUE( |
| 184 RunExtensionSubtest("webnavigation", "test_userAction.html")) << message_; | 184 RunExtensionSubtest("webnavigation", "test_userAction.html")) << message_; |
| 185 | 185 |
| 186 WebContents* tab = browser()->GetSelectedWebContents(); | 186 WebContents* tab = browser()->GetActiveWebContents(); |
| 187 ui_test_utils::WaitForLoadStop(tab); | 187 ui_test_utils::WaitForLoadStop(tab); |
| 188 | 188 |
| 189 ResultCatcher catcher; | 189 ResultCatcher catcher; |
| 190 | 190 |
| 191 ExtensionService* service = browser()->profile()->GetExtensionService(); | 191 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 192 const extensions::Extension* extension = | 192 const extensions::Extension* extension = |
| 193 service->GetExtensionById(last_loaded_extension_id_, false); | 193 service->GetExtensionById(last_loaded_extension_id_, false); |
| 194 GURL url = extension->GetResourceURL("userAction/a.html"); | 194 GURL url = extension->GetResourceURL("userAction/a.html"); |
| 195 | 195 |
| 196 ui_test_utils::NavigateToURL(browser(), url); | 196 ui_test_utils::NavigateToURL(browser(), url); |
| (...skipping 17 matching lines...) Expand all Loading... |
| 214 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationRequestOpenTab) { | 214 IN_PROC_BROWSER_TEST_F(ExtensionApiTest, WebNavigationRequestOpenTab) { |
| 215 FrameNavigationState::set_allow_extension_scheme(true); | 215 FrameNavigationState::set_allow_extension_scheme(true); |
| 216 | 216 |
| 217 CommandLine::ForCurrentProcess()->AppendSwitch( | 217 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 218 switches::kAllowLegacyExtensionManifests); | 218 switches::kAllowLegacyExtensionManifests); |
| 219 | 219 |
| 220 // Wait for the extension to set itself up and return control to us. | 220 // Wait for the extension to set itself up and return control to us. |
| 221 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_requestOpenTab.html")) | 221 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_requestOpenTab.html")) |
| 222 << message_; | 222 << message_; |
| 223 | 223 |
| 224 WebContents* tab = browser()->GetSelectedWebContents(); | 224 WebContents* tab = browser()->GetActiveWebContents(); |
| 225 ui_test_utils::WaitForLoadStop(tab); | 225 ui_test_utils::WaitForLoadStop(tab); |
| 226 | 226 |
| 227 ResultCatcher catcher; | 227 ResultCatcher catcher; |
| 228 | 228 |
| 229 ExtensionService* service = browser()->profile()->GetExtensionService(); | 229 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 230 const extensions::Extension* extension = | 230 const extensions::Extension* extension = |
| 231 service->GetExtensionById(last_loaded_extension_id_, false); | 231 service->GetExtensionById(last_loaded_extension_id_, false); |
| 232 GURL url = extension->GetResourceURL("requestOpenTab/a.html"); | 232 GURL url = extension->GetResourceURL("requestOpenTab/a.html"); |
| 233 | 233 |
| 234 ui_test_utils::NavigateToURL(browser(), url); | 234 ui_test_utils::NavigateToURL(browser(), url); |
| (...skipping 16 matching lines...) Expand all Loading... |
| 251 FrameNavigationState::set_allow_extension_scheme(true); | 251 FrameNavigationState::set_allow_extension_scheme(true); |
| 252 ASSERT_TRUE(StartTestServer()); | 252 ASSERT_TRUE(StartTestServer()); |
| 253 | 253 |
| 254 CommandLine::ForCurrentProcess()->AppendSwitch( | 254 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 255 switches::kAllowLegacyExtensionManifests); | 255 switches::kAllowLegacyExtensionManifests); |
| 256 | 256 |
| 257 // Wait for the extension to set itself up and return control to us. | 257 // Wait for the extension to set itself up and return control to us. |
| 258 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_targetBlank.html")) | 258 ASSERT_TRUE(RunExtensionSubtest("webnavigation", "test_targetBlank.html")) |
| 259 << message_; | 259 << message_; |
| 260 | 260 |
| 261 WebContents* tab = browser()->GetSelectedWebContents(); | 261 WebContents* tab = browser()->GetActiveWebContents(); |
| 262 ui_test_utils::WaitForLoadStop(tab); | 262 ui_test_utils::WaitForLoadStop(tab); |
| 263 | 263 |
| 264 ResultCatcher catcher; | 264 ResultCatcher catcher; |
| 265 | 265 |
| 266 GURL url = test_server()->GetURL( | 266 GURL url = test_server()->GetURL( |
| 267 "files/extensions/api_test/webnavigation/targetBlank/a.html"); | 267 "files/extensions/api_test/webnavigation/targetBlank/a.html"); |
| 268 | 268 |
| 269 browser::NavigateParams params(browser(), url, content::PAGE_TRANSITION_LINK); | 269 browser::NavigateParams params(browser(), url, content::PAGE_TRANSITION_LINK); |
| 270 ui_test_utils::NavigateToURL(¶ms); | 270 ui_test_utils::NavigateToURL(¶ms); |
| 271 | 271 |
| (...skipping 25 matching lines...) Expand all Loading... |
| 297 ExtensionApiTest::kFlagEnableIncognito)) << message_; | 297 ExtensionApiTest::kFlagEnableIncognito)) << message_; |
| 298 | 298 |
| 299 ResultCatcher catcher; | 299 ResultCatcher catcher; |
| 300 | 300 |
| 301 GURL url = test_server()->GetURL( | 301 GURL url = test_server()->GetURL( |
| 302 "files/extensions/api_test/webnavigation/targetBlank/a.html"); | 302 "files/extensions/api_test/webnavigation/targetBlank/a.html"); |
| 303 | 303 |
| 304 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), url); | 304 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), url); |
| 305 WebContents* tab = browser::FindTabbedBrowser( | 305 WebContents* tab = browser::FindTabbedBrowser( |
| 306 browser()->profile()->GetOffTheRecordProfile(), false)-> | 306 browser()->profile()->GetOffTheRecordProfile(), false)-> |
| 307 GetSelectedWebContents(); | 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 |