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 "base/command_line.h" | 5 #include "base/command_line.h" |
6 #include "chrome/browser/extensions/api/web_request/web_request_api.h" | 6 #include "chrome/browser/extensions/api/web_request/web_request_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/ui/browser.h" | 10 #include "chrome/browser/ui/browser.h" |
11 #include "chrome/browser/ui/browser_tabstrip.h" | 11 #include "chrome/browser/ui/browser_tabstrip.h" |
12 #include "chrome/browser/ui/login/login_prompt.h" | 12 #include "chrome/browser/ui/login/login_prompt.h" |
13 #include "chrome/common/chrome_notification_types.h" | 13 #include "chrome/common/chrome_notification_types.h" |
14 #include "chrome/common/chrome_switches.h" | 14 #include "chrome/common/chrome_switches.h" |
15 #include "chrome/test/base/ui_test_utils.h" | 15 #include "chrome/test/base/ui_test_utils.h" |
16 #include "content/public/browser/notification_registrar.h" | 16 #include "content/public/browser/notification_registrar.h" |
17 #include "content/public/browser/notification_service.h" | 17 #include "content/public/browser/notification_service.h" |
18 #include "content/public/browser/render_view_host.h" | 18 #include "content/public/browser/render_view_host.h" |
19 #include "content/public/browser/web_contents.h" | 19 #include "content/public/browser/web_contents.h" |
| 20 #include "content/public/test/browser_test_utils.h" |
20 #include "net/base/mock_host_resolver.h" | 21 #include "net/base/mock_host_resolver.h" |
21 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" | 22 #include "third_party/WebKit/Source/WebKit/chromium/public/WebInputEvent.h" |
22 | 23 |
23 using content::WebContents; | 24 using content::WebContents; |
24 | 25 |
25 namespace { | 26 namespace { |
26 | 27 |
27 class CancelLoginDialog : public content::NotificationObserver { | 28 class CancelLoginDialog : public content::NotificationObserver { |
28 public: | 29 public: |
29 CancelLoginDialog() { | 30 CancelLoginDialog() { |
(...skipping 64 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
94 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_blocking.html")) << | 95 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_blocking.html")) << |
95 message_; | 96 message_; |
96 } | 97 } |
97 | 98 |
98 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestNewTab) { | 99 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestNewTab) { |
99 // Wait for the extension to set itself up and return control to us. | 100 // Wait for the extension to set itself up and return control to us. |
100 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_newTab.html")) | 101 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_newTab.html")) |
101 << message_; | 102 << message_; |
102 | 103 |
103 WebContents* tab = chrome::GetActiveWebContents(browser()); | 104 WebContents* tab = chrome::GetActiveWebContents(browser()); |
104 ui_test_utils::WaitForLoadStop(tab); | 105 content::WaitForLoadStop(tab); |
105 | 106 |
106 ResultCatcher catcher; | 107 ResultCatcher catcher; |
107 | 108 |
108 ExtensionService* service = browser()->profile()->GetExtensionService(); | 109 ExtensionService* service = browser()->profile()->GetExtensionService(); |
109 const extensions::Extension* extension = | 110 const extensions::Extension* extension = |
110 service->GetExtensionById(last_loaded_extension_id_, false); | 111 service->GetExtensionById(last_loaded_extension_id_, false); |
111 GURL url = extension->GetResourceURL("newTab/a.html"); | 112 GURL url = extension->GetResourceURL("newTab/a.html"); |
112 | 113 |
113 ui_test_utils::NavigateToURL(browser(), url); | 114 ui_test_utils::NavigateToURL(browser(), url); |
114 | 115 |
115 // There's a link on a.html with target=_blank. Click on it to open it in a | 116 // There's a link on a.html with target=_blank. Click on it to open it in a |
116 // new tab. | 117 // new tab. |
117 WebKit::WebMouseEvent mouse_event; | 118 WebKit::WebMouseEvent mouse_event; |
118 mouse_event.type = WebKit::WebInputEvent::MouseDown; | 119 mouse_event.type = WebKit::WebInputEvent::MouseDown; |
119 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; | 120 mouse_event.button = WebKit::WebMouseEvent::ButtonLeft; |
120 mouse_event.x = 7; | 121 mouse_event.x = 7; |
121 mouse_event.y = 7; | 122 mouse_event.y = 7; |
122 mouse_event.clickCount = 1; | 123 mouse_event.clickCount = 1; |
123 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 124 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
124 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 125 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
125 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 126 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
126 | 127 |
127 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 128 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
128 } | 129 } |
129 | 130 |
130 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestDeclarative) { | 131 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestDeclarative) { |
131 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_declarative.html")) << | 132 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_declarative.html")) << |
132 message_; | 133 message_; |
133 } | 134 } |
OLD | NEW |