OLD | NEW |
1 // Copyright (c) 2011 The Chromium Authors. All rights reserved. | 1 // Copyright (c) 2011 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/command_line.h" | 5 #include "base/command_line.h" |
6 #include "chrome/browser/extensions/extension_apitest.h" | 6 #include "chrome/browser/extensions/extension_apitest.h" |
| 7 #include "chrome/browser/extensions/extension_service.h" |
7 #include "chrome/browser/extensions/extension_webrequest_api.h" | 8 #include "chrome/browser/extensions/extension_webrequest_api.h" |
| 9 #include "chrome/browser/profiles/profile.h" |
| 10 #include "chrome/browser/ui/browser.h" |
8 #include "chrome/browser/ui/login/login_prompt.h" | 11 #include "chrome/browser/ui/login/login_prompt.h" |
9 #include "chrome/common/chrome_notification_types.h" | 12 #include "chrome/common/chrome_notification_types.h" |
10 #include "chrome/common/chrome_switches.h" | 13 #include "chrome/common/chrome_switches.h" |
| 14 #include "chrome/test/base/ui_test_utils.h" |
| 15 #include "content/browser/renderer_host/render_view_host.h" |
| 16 #include "content/browser/tab_contents/tab_contents.h" |
11 #include "content/public/browser/notification_registrar.h" | 17 #include "content/public/browser/notification_registrar.h" |
12 #include "content/public/browser/notification_service.h" | 18 #include "content/public/browser/notification_service.h" |
13 #include "net/base/mock_host_resolver.h" | 19 #include "net/base/mock_host_resolver.h" |
| 20 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
14 | 21 |
15 namespace { | 22 namespace { |
16 | 23 |
17 class CancelLoginDialog : public content::NotificationObserver { | 24 class CancelLoginDialog : public content::NotificationObserver { |
18 public: | 25 public: |
19 CancelLoginDialog() { | 26 CancelLoginDialog() { |
20 registrar_.Add(this, | 27 registrar_.Add(this, |
21 chrome::NOTIFICATION_AUTH_NEEDED, | 28 chrome::NOTIFICATION_AUTH_NEEDED, |
22 content::NotificationService::AllSources()); | 29 content::NotificationService::AllSources()); |
23 } | 30 } |
(...skipping 61 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
85 | 92 |
86 // Hangs flakily: http://crbug.com/91715 | 93 // Hangs flakily: http://crbug.com/91715 |
87 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, | 94 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, |
88 DISABLED_WebRequestBlocking) { | 95 DISABLED_WebRequestBlocking) { |
89 CommandLine::ForCurrentProcess()->AppendSwitch( | 96 CommandLine::ForCurrentProcess()->AppendSwitch( |
90 switches::kEnableExperimentalExtensionApis); | 97 switches::kEnableExperimentalExtensionApis); |
91 | 98 |
92 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_blocking.html")) << | 99 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_blocking.html")) << |
93 message_; | 100 message_; |
94 } | 101 } |
| 102 |
| 103 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestNewTab) { |
| 104 CommandLine::ForCurrentProcess()->AppendSwitch( |
| 105 switches::kEnableExperimentalExtensionApis); |
| 106 |
| 107 // Wait for the extension to set itself up and return control to us. |
| 108 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_newTab.html")) |
| 109 << message_; |
| 110 |
| 111 ResultCatcher catcher; |
| 112 |
| 113 ExtensionService* service = browser()->profile()->GetExtensionService(); |
| 114 const Extension* extension = |
| 115 service->GetExtensionById(last_loaded_extension_id_, false); |
| 116 GURL url = extension->GetResourceURL("newTab/a.html"); |
| 117 |
| 118 ui_test_utils::NavigateToURL(browser(), url); |
| 119 |
| 120 // There's a link on a.html with target=_blank. Click on it to open it in a |
| 121 // new tab. |
| 122 WebKit::WebMouseEvent mouse_event; |
| 123 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
| 124 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
| 125 mouse_event.x = 7; |
| 126 mouse_event.y = 7; |
| 127 mouse_event.clickCount = 1; |
| 128 TabContents* tab = browser()->GetSelectedTabContents(); |
| 129 tab->render_view_host()->ForwardMouseEvent(mouse_event); |
| 130 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
| 131 tab->render_view_host()->ForwardMouseEvent(mouse_event); |
| 132 |
| 133 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
| 134 } |
OLD | NEW |