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/extensions/extension_system.h" | 9 #include "chrome/browser/extensions/extension_system.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/profiles/profile.h" | 11 #include "chrome/browser/profiles/profile.h" |
12 #include "chrome/browser/ui/browser.h" | 12 #include "chrome/browser/ui/browser.h" |
13 #include "chrome/browser/ui/login/login_prompt.h" | 13 #include "chrome/browser/ui/login/login_prompt.h" |
14 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 14 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
15 #include "chrome/common/chrome_notification_types.h" | 15 #include "chrome/common/chrome_notification_types.h" |
16 #include "chrome/common/chrome_switches.h" | 16 #include "chrome/common/chrome_switches.h" |
17 #include "chrome/common/extensions/features/feature.h" | 17 #include "chrome/common/extensions/features/feature.h" |
18 #include "chrome/test/base/ui_test_utils.h" | 18 #include "chrome/test/base/ui_test_utils.h" |
19 #include "content/public/browser/notification_registrar.h" | 19 #include "content/public/browser/notification_registrar.h" |
20 #include "content/public/browser/notification_service.h" | 20 #include "content/public/browser/notification_service.h" |
21 #include "content/public/browser/render_view_host.h" | 21 #include "content/public/browser/render_view_host.h" |
22 #include "content/public/browser/web_contents.h" | 22 #include "content/public/browser/web_contents.h" |
23 #include "content/public/test/browser_test_utils.h" | 23 #include "content/public/test/browser_test_utils.h" |
24 #include "net/dns/mock_host_resolver.h" | 24 #include "net/dns/mock_host_resolver.h" |
| 25 #include "net/test/embedded_test_server/embedded_test_server.h" |
25 #include "third_party/WebKit/public/web/WebInputEvent.h" | 26 #include "third_party/WebKit/public/web/WebInputEvent.h" |
26 | 27 |
27 using content::WebContents; | 28 using content::WebContents; |
28 using extensions::Feature; | 29 using extensions::Feature; |
29 | 30 |
30 namespace { | 31 namespace { |
31 | 32 |
32 class CancelLoginDialog : public content::NotificationObserver { | 33 class CancelLoginDialog : public content::NotificationObserver { |
33 public: | 34 public: |
34 CancelLoginDialog() { | 35 CancelLoginDialog() { |
(...skipping 22 matching lines...) Expand all Loading... |
57 | 58 |
58 class ExtensionWebRequestApiTest : public ExtensionApiTest { | 59 class ExtensionWebRequestApiTest : public ExtensionApiTest { |
59 public: | 60 public: |
60 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { | 61 virtual void SetUpInProcessBrowserTestFixture() OVERRIDE { |
61 // TODO(battre): remove this when declarative webRequest API becomes stable. | 62 // TODO(battre): remove this when declarative webRequest API becomes stable. |
62 CommandLine::ForCurrentProcess()->AppendSwitch( | 63 CommandLine::ForCurrentProcess()->AppendSwitch( |
63 switches::kEnableExperimentalExtensionApis); | 64 switches::kEnableExperimentalExtensionApis); |
64 | 65 |
65 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); | 66 ExtensionApiTest::SetUpInProcessBrowserTestFixture(); |
66 host_resolver()->AddRule("*", "127.0.0.1"); | 67 host_resolver()->AddRule("*", "127.0.0.1"); |
67 ASSERT_TRUE(StartTestServer()); | |
68 } | 68 } |
69 | 69 |
70 void RunPermissionTest( | 70 void RunPermissionTest( |
71 const char* extension_directory, | 71 const char* extension_directory, |
72 bool load_extension_with_incognito_permission, | 72 bool load_extension_with_incognito_permission, |
73 bool wait_for_extension_loaded_in_incognito, | 73 bool wait_for_extension_loaded_in_incognito, |
74 const char* expected_content_regular_window, | 74 const char* expected_content_regular_window, |
75 const char* exptected_content_incognito_window); | 75 const char* exptected_content_incognito_window); |
76 }; | 76 }; |
77 | 77 |
78 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestApi) { | 78 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestApi) { |
| 79 ASSERT_TRUE(StartEmbeddedTestServer()); |
79 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_api.html")) << message_; | 80 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_api.html")) << message_; |
80 } | 81 } |
81 | 82 |
82 // Fails often on Windows dbg bots. http://crbug.com/177163 | 83 // Fails often on Windows dbg bots. http://crbug.com/177163 |
83 #if defined(OS_WIN) | 84 #if defined(OS_WIN) |
84 #define MAYBE_WebRequestSimple DISABLED_WebRequestSimple | 85 #define MAYBE_WebRequestSimple DISABLED_WebRequestSimple |
85 #else | 86 #else |
86 #define MAYBE_WebRequestSimple WebRequestSimple | 87 #define MAYBE_WebRequestSimple WebRequestSimple |
87 #endif // defined(OS_WIN) | 88 #endif // defined(OS_WIN) |
88 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_WebRequestSimple) { | 89 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_WebRequestSimple) { |
| 90 ASSERT_TRUE(StartEmbeddedTestServer()); |
89 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_simple.html")) << | 91 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_simple.html")) << |
90 message_; | 92 message_; |
91 } | 93 } |
92 | 94 |
93 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestComplex) { | 95 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestComplex) { |
| 96 ASSERT_TRUE(StartEmbeddedTestServer()); |
94 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_complex.html")) << | 97 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_complex.html")) << |
95 message_; | 98 message_; |
96 } | 99 } |
97 | 100 |
98 // Flaky (sometimes crash): http://crbug.com/140976 | 101 // Flaky (sometimes crash): http://crbug.com/140976 |
99 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, | 102 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, |
100 DISABLED_WebRequestAuthRequired) { | 103 DISABLED_WebRequestAuthRequired) { |
101 CancelLoginDialog login_dialog_helper; | 104 CancelLoginDialog login_dialog_helper; |
102 | 105 |
| 106 ASSERT_TRUE(StartEmbeddedTestServer()); |
103 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_auth_required.html")) << | 107 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_auth_required.html")) << |
104 message_; | 108 message_; |
105 } | 109 } |
106 | 110 |
107 // This test times out regularly on win_rel trybots. See http://crbug.com/122178 | 111 // This test times out regularly on win_rel trybots. See http://crbug.com/122178 |
108 #if defined(OS_WIN) | 112 #if defined(OS_WIN) |
109 #define MAYBE_WebRequestBlocking DISABLED_WebRequestBlocking | 113 #define MAYBE_WebRequestBlocking DISABLED_WebRequestBlocking |
110 #else | 114 #else |
111 #define MAYBE_WebRequestBlocking WebRequestBlocking | 115 #define MAYBE_WebRequestBlocking WebRequestBlocking |
112 #endif | 116 #endif |
113 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_WebRequestBlocking) { | 117 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_WebRequestBlocking) { |
| 118 ASSERT_TRUE(StartEmbeddedTestServer()); |
114 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_blocking.html")) << | 119 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_blocking.html")) << |
115 message_; | 120 message_; |
116 } | 121 } |
117 | 122 |
118 // Fails often on Windows dbg bots. http://crbug.com/177163 | 123 // Fails often on Windows dbg bots. http://crbug.com/177163 |
119 #if defined(OS_WIN) | 124 #if defined(OS_WIN) |
120 #define MAYBE_WebRequestNewTab DISABLED_WebRequestNewTab | 125 #define MAYBE_WebRequestNewTab DISABLED_WebRequestNewTab |
121 #else | 126 #else |
122 #define MAYBE_WebRequestNewTab WebRequestNewTab | 127 #define MAYBE_WebRequestNewTab WebRequestNewTab |
123 #endif // defined(OS_WIN) | 128 #endif // defined(OS_WIN) |
124 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_WebRequestNewTab) { | 129 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_WebRequestNewTab) { |
| 130 ASSERT_TRUE(StartEmbeddedTestServer()); |
125 // Wait for the extension to set itself up and return control to us. | 131 // Wait for the extension to set itself up and return control to us. |
126 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_newTab.html")) | 132 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_newTab.html")) |
127 << message_; | 133 << message_; |
128 | 134 |
129 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 135 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
130 content::WaitForLoadStop(tab); | 136 content::WaitForLoadStop(tab); |
131 | 137 |
132 ResultCatcher catcher; | 138 ResultCatcher catcher; |
133 | 139 |
134 ExtensionService* service = extensions::ExtensionSystem::Get( | 140 ExtensionService* service = extensions::ExtensionSystem::Get( |
(...skipping 13 matching lines...) Expand all Loading... |
148 mouse_event.y = 7; | 154 mouse_event.y = 7; |
149 mouse_event.clickCount = 1; | 155 mouse_event.clickCount = 1; |
150 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 156 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
151 mouse_event.type = WebKit::WebInputEvent::MouseUp; | 157 mouse_event.type = WebKit::WebInputEvent::MouseUp; |
152 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); | 158 tab->GetRenderViewHost()->ForwardMouseEvent(mouse_event); |
153 | 159 |
154 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); | 160 ASSERT_TRUE(catcher.GetNextResult()) << catcher.message(); |
155 } | 161 } |
156 | 162 |
157 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestDeclarative1) { | 163 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebRequestDeclarative1) { |
| 164 ASSERT_TRUE(StartEmbeddedTestServer()); |
158 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_declarative1.html")) | 165 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_declarative1.html")) |
159 << message_; | 166 << message_; |
160 } | 167 } |
161 | 168 |
162 // This test times out on XP. See http://crbug.com/178296 | 169 // This test times out on XP. See http://crbug.com/178296 |
163 #if defined(OS_WIN) | 170 #if defined(OS_WIN) |
164 #define MAYBE_WebRequestDeclarative2 DISABLED_WebRequestDeclarative2 | 171 #define MAYBE_WebRequestDeclarative2 DISABLED_WebRequestDeclarative2 |
165 #else | 172 #else |
166 #define MAYBE_WebRequestDeclarative2 WebRequestDeclarative2 | 173 #define MAYBE_WebRequestDeclarative2 WebRequestDeclarative2 |
167 #endif | 174 #endif |
168 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, | 175 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, |
169 MAYBE_WebRequestDeclarative2) { | 176 MAYBE_WebRequestDeclarative2) { |
| 177 ASSERT_TRUE(StartEmbeddedTestServer()); |
170 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_declarative2.html")) | 178 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_declarative2.html")) |
171 << message_; | 179 << message_; |
172 } | 180 } |
173 | 181 |
174 void ExtensionWebRequestApiTest::RunPermissionTest( | 182 void ExtensionWebRequestApiTest::RunPermissionTest( |
175 const char* extension_directory, | 183 const char* extension_directory, |
176 bool load_extension_with_incognito_permission, | 184 bool load_extension_with_incognito_permission, |
177 bool wait_for_extension_loaded_in_incognito, | 185 bool wait_for_extension_loaded_in_incognito, |
178 const char* expected_content_regular_window, | 186 const char* expected_content_regular_window, |
179 const char* exptected_content_incognito_window) { | 187 const char* exptected_content_incognito_window) { |
(...skipping 13 matching lines...) Expand all Loading... |
193 test_data_dir_.AppendASCII("webrequest_permissions") | 201 test_data_dir_.AppendASCII("webrequest_permissions") |
194 .AppendASCII(extension_directory), | 202 .AppendASCII(extension_directory), |
195 load_extension_flags)); | 203 load_extension_flags)); |
196 | 204 |
197 // Test that navigation in regular window is properly redirected. | 205 // Test that navigation in regular window is properly redirected. |
198 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 206 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
199 | 207 |
200 // This navigation should be redirected. | 208 // This navigation should be redirected. |
201 ui_test_utils::NavigateToURL( | 209 ui_test_utils::NavigateToURL( |
202 browser(), | 210 browser(), |
203 test_server()->GetURL("files/extensions/test_file.html")); | 211 embedded_test_server()->GetURL("/extensions/test_file.html")); |
204 | 212 |
205 std::string body; | 213 std::string body; |
206 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); | 214 WebContents* tab = browser()->tab_strip_model()->GetActiveWebContents(); |
207 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 215 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
208 tab, | 216 tab, |
209 "window.domAutomationController.send(document.body.textContent)", | 217 "window.domAutomationController.send(document.body.textContent)", |
210 &body)); | 218 &body)); |
211 EXPECT_EQ(expected_content_regular_window, body); | 219 EXPECT_EQ(expected_content_regular_window, body); |
212 | 220 |
213 // Test that navigation in OTR window is properly redirected. | 221 // Test that navigation in OTR window is properly redirected. |
214 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( | 222 Browser* otr_browser = ui_test_utils::OpenURLOffTheRecord( |
215 browser()->profile(), GURL("about:blank")); | 223 browser()->profile(), GURL("about:blank")); |
216 | 224 |
217 if (wait_for_extension_loaded_in_incognito) | 225 if (wait_for_extension_loaded_in_incognito) |
218 EXPECT_TRUE(listener_incognito.WaitUntilSatisfied()); | 226 EXPECT_TRUE(listener_incognito.WaitUntilSatisfied()); |
219 | 227 |
220 // This navigation should be redirected if | 228 // This navigation should be redirected if |
221 // load_extension_with_incognito_permission is true. | 229 // load_extension_with_incognito_permission is true. |
222 ui_test_utils::NavigateToURL( | 230 ui_test_utils::NavigateToURL( |
223 otr_browser, | 231 otr_browser, |
224 test_server()->GetURL("files/extensions/test_file.html")); | 232 embedded_test_server()->GetURL("/extensions/test_file.html")); |
225 | 233 |
226 body.clear(); | 234 body.clear(); |
227 WebContents* otr_tab = otr_browser->tab_strip_model()->GetActiveWebContents(); | 235 WebContents* otr_tab = otr_browser->tab_strip_model()->GetActiveWebContents(); |
228 ASSERT_TRUE(content::ExecuteScriptAndExtractString( | 236 ASSERT_TRUE(content::ExecuteScriptAndExtractString( |
229 otr_tab, | 237 otr_tab, |
230 "window.domAutomationController.send(document.body.textContent)", | 238 "window.domAutomationController.send(document.body.textContent)", |
231 &body)); | 239 &body)); |
232 EXPECT_EQ(exptected_content_incognito_window, body); | 240 EXPECT_EQ(exptected_content_incognito_window, body); |
233 } | 241 } |
234 | 242 |
235 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, | 243 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, |
236 WebRequestDeclarativePermissionSpanning1) { | 244 WebRequestDeclarativePermissionSpanning1) { |
237 // Test spanning with incognito permission. | 245 // Test spanning with incognito permission. |
| 246 ASSERT_TRUE(StartEmbeddedTestServer()); |
238 RunPermissionTest("spanning", true, false, "redirected1", "redirected1"); | 247 RunPermissionTest("spanning", true, false, "redirected1", "redirected1"); |
239 } | 248 } |
240 | 249 |
241 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, | 250 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, |
242 WebRequestDeclarativePermissionSpanning2) { | 251 WebRequestDeclarativePermissionSpanning2) { |
243 // Test spanning without incognito permission. | 252 // Test spanning without incognito permission. |
| 253 ASSERT_TRUE(StartEmbeddedTestServer()); |
244 RunPermissionTest("spanning", false, false, "redirected1", ""); | 254 RunPermissionTest("spanning", false, false, "redirected1", ""); |
245 } | 255 } |
246 | 256 |
247 | 257 |
248 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, | 258 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, |
249 WebRequestDeclarativePermissionSplit1) { | 259 WebRequestDeclarativePermissionSplit1) { |
250 // Test split with incognito permission. | 260 // Test split with incognito permission. |
| 261 ASSERT_TRUE(StartEmbeddedTestServer()); |
251 RunPermissionTest("split", true, true, "redirected1", "redirected2"); | 262 RunPermissionTest("split", true, true, "redirected1", "redirected2"); |
252 } | 263 } |
253 | 264 |
254 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, | 265 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, |
255 WebRequestDeclarativePermissionSplit2) { | 266 WebRequestDeclarativePermissionSplit2) { |
256 // Test split without incognito permission. | 267 // Test split without incognito permission. |
| 268 ASSERT_TRUE(StartEmbeddedTestServer()); |
257 RunPermissionTest("split", false, false, "redirected1", ""); | 269 RunPermissionTest("split", false, false, "redirected1", ""); |
258 } | 270 } |
259 | 271 |
260 // TODO(vabr): Cure these flaky tests, http://crbug.com/238179. | 272 // TODO(vabr): Cure these flaky tests, http://crbug.com/238179. |
261 #if !defined(NDEBUG) | 273 #if !defined(NDEBUG) |
262 #define MAYBE_PostData1 DISABLED_PostData1 | 274 #define MAYBE_PostData1 DISABLED_PostData1 |
263 #define MAYBE_PostData2 DISABLED_PostData2 | 275 #define MAYBE_PostData2 DISABLED_PostData2 |
264 #else | 276 #else |
265 #define MAYBE_PostData1 PostData1 | 277 #define MAYBE_PostData1 PostData1 |
266 #define MAYBE_PostData2 PostData2 | 278 #define MAYBE_PostData2 PostData2 |
267 #endif | 279 #endif |
268 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_PostData1) { | 280 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_PostData1) { |
269 // Test HTML form POST data access with the default and "url" encoding. | 281 // Test HTML form POST data access with the default and "url" encoding. |
| 282 ASSERT_TRUE(StartEmbeddedTestServer()); |
270 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_post1.html")) << | 283 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_post1.html")) << |
271 message_; | 284 message_; |
272 } | 285 } |
273 | 286 |
274 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_PostData2) { | 287 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, MAYBE_PostData2) { |
275 // Test HTML form POST data access with the multipart and plaintext encoding. | 288 // Test HTML form POST data access with the multipart and plaintext encoding. |
| 289 ASSERT_TRUE(StartEmbeddedTestServer()); |
276 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_post2.html")) << | 290 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_post2.html")) << |
277 message_; | 291 message_; |
278 } | 292 } |
279 | 293 |
280 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, | 294 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, |
281 DeclarativeSendMessage) { | 295 DeclarativeSendMessage) { |
| 296 ASSERT_TRUE(StartEmbeddedTestServer()); |
282 ASSERT_TRUE(RunExtensionTest("webrequest_sendmessage")) << message_; | 297 ASSERT_TRUE(RunExtensionTest("webrequest_sendmessage")) << message_; |
283 } | 298 } |
284 | 299 |
285 // Check that reloading an extension that runs in incognito split mode and | 300 // Check that reloading an extension that runs in incognito split mode and |
286 // has two active background pages with registered events does not crash the | 301 // has two active background pages with registered events does not crash the |
287 // browser. Regression test for http://crbug.com/224094 | 302 // browser. Regression test for http://crbug.com/224094 |
288 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, IncognitoSplitModeReload) { | 303 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, IncognitoSplitModeReload) { |
| 304 ASSERT_TRUE(StartEmbeddedTestServer()); |
289 // Wait for rules to be set up. | 305 // Wait for rules to be set up. |
290 ExtensionTestMessageListener listener("done", true); | 306 ExtensionTestMessageListener listener("done", true); |
291 ExtensionTestMessageListener listener_incognito("done_incognito", true); | 307 ExtensionTestMessageListener listener_incognito("done_incognito", true); |
292 | 308 |
293 const extensions::Extension* extension = LoadExtensionWithFlags( | 309 const extensions::Extension* extension = LoadExtensionWithFlags( |
294 test_data_dir_.AppendASCII("webrequest_reload"), | 310 test_data_dir_.AppendASCII("webrequest_reload"), |
295 kFlagEnableIncognito); | 311 kFlagEnableIncognito); |
296 ASSERT_TRUE(extension); | 312 ASSERT_TRUE(extension); |
297 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); | 313 ui_test_utils::OpenURLOffTheRecord(browser()->profile(), GURL("about:blank")); |
298 | 314 |
299 EXPECT_TRUE(listener.WaitUntilSatisfied()); | 315 EXPECT_TRUE(listener.WaitUntilSatisfied()); |
300 EXPECT_TRUE(listener_incognito.WaitUntilSatisfied()); | 316 EXPECT_TRUE(listener_incognito.WaitUntilSatisfied()); |
301 | 317 |
302 // Reload extension and wait for rules to be set up again. This should not | 318 // Reload extension and wait for rules to be set up again. This should not |
303 // crash the browser. | 319 // crash the browser. |
304 ExtensionTestMessageListener listener2("done", true); | 320 ExtensionTestMessageListener listener2("done", true); |
305 ExtensionTestMessageListener listener_incognito2("done_incognito", true); | 321 ExtensionTestMessageListener listener_incognito2("done_incognito", true); |
306 | 322 |
307 ReloadExtension(extension->id()); | 323 ReloadExtension(extension->id()); |
308 | 324 |
309 EXPECT_TRUE(listener2.WaitUntilSatisfied()); | 325 EXPECT_TRUE(listener2.WaitUntilSatisfied()); |
310 EXPECT_TRUE(listener_incognito2.WaitUntilSatisfied()); | 326 EXPECT_TRUE(listener_incognito2.WaitUntilSatisfied()); |
311 } | 327 } |
OLD | NEW |