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/chrome_notification_types.h" | 6 #include "chrome/browser/chrome_notification_types.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/login/login_prompt.h" | 11 #include "chrome/browser/ui/login/login_prompt.h" |
12 #include "chrome/browser/ui/tabs/tab_strip_model.h" | 12 #include "chrome/browser/ui/tabs/tab_strip_model.h" |
13 #include "chrome/test/base/ui_test_utils.h" | 13 #include "chrome/test/base/ui_test_utils.h" |
14 #include "content/public/browser/notification_registrar.h" | 14 #include "content/public/browser/notification_registrar.h" |
15 #include "content/public/browser/notification_service.h" | 15 #include "content/public/browser/notification_service.h" |
16 #include "content/public/browser/render_view_host.h" | 16 #include "content/public/browser/render_view_host.h" |
17 #include "content/public/browser/web_contents.h" | 17 #include "content/public/browser/web_contents.h" |
18 #include "content/public/common/content_switches.h" | 18 #include "content/public/common/content_switches.h" |
19 #include "content/public/test/browser_test_utils.h" | 19 #include "content/public/test/browser_test_utils.h" |
20 #include "extensions/browser/api/web_request/web_request_api.h" | 20 #include "extensions/browser/api/web_request/web_request_api.h" |
21 #include "extensions/browser/extension_system.h" | 21 #include "extensions/browser/extension_system.h" |
| 22 #include "extensions/common/extension_builder.h" |
22 #include "extensions/common/features/feature.h" | 23 #include "extensions/common/features/feature.h" |
23 #include "extensions/test/extension_test_message_listener.h" | 24 #include "extensions/test/extension_test_message_listener.h" |
24 #include "extensions/test/result_catcher.h" | 25 #include "extensions/test/result_catcher.h" |
25 #include "net/dns/mock_host_resolver.h" | 26 #include "net/dns/mock_host_resolver.h" |
26 #include "net/test/embedded_test_server/embedded_test_server.h" | 27 #include "net/test/embedded_test_server/embedded_test_server.h" |
27 #include "third_party/WebKit/public/web/WebInputEvent.h" | 28 #include "third_party/WebKit/public/web/WebInputEvent.h" |
28 | 29 |
29 using content::WebContents; | 30 using content::WebContents; |
30 using extensions::Feature; | 31 using extensions::Feature; |
31 using extensions::ResultCatcher; | 32 using extensions::ResultCatcher; |
(...skipping 350 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
382 switches::kSitePerProcess)) { | 383 switches::kSitePerProcess)) { |
383 // With --site-per-process, the extension frame does run in the extension's | 384 // With --site-per-process, the extension frame does run in the extension's |
384 // process. | 385 // process. |
385 EXPECT_EQ("Intercepted requests: ?contentscript", | 386 EXPECT_EQ("Intercepted requests: ?contentscript", |
386 listener_result.message()); | 387 listener_result.message()); |
387 } else { | 388 } else { |
388 EXPECT_EQ("Intercepted requests: ?contentscript, ?framescript", | 389 EXPECT_EQ("Intercepted requests: ?contentscript, ?framescript", |
389 listener_result.message()); | 390 listener_result.message()); |
390 } | 391 } |
391 } | 392 } |
| 393 |
| 394 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, HostedAppRequest) { |
| 395 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 396 GURL hosted_app_url( |
| 397 embedded_test_server()->GetURL( |
| 398 "/extensions/api_test/webrequest_hosted_app/index.html")); |
| 399 scoped_refptr<extensions::Extension> hosted_app = |
| 400 extensions::ExtensionBuilder() |
| 401 .SetManifest(extensions::DictionaryBuilder() |
| 402 .Set("name", "Some hosted app") |
| 403 .Set("version", "1") |
| 404 .Set("manifest_version", 2) |
| 405 .Set("app", extensions::DictionaryBuilder() |
| 406 .Set("launch", extensions::DictionaryBuilder() |
| 407 .Set("web_url", hosted_app_url.spec())))) |
| 408 .Build(); |
| 409 extensions::ExtensionSystem::Get(browser()->profile())->extension_service() |
| 410 ->AddExtension(hosted_app.get()); |
| 411 |
| 412 ExtensionTestMessageListener listener1("main_frame", false); |
| 413 ExtensionTestMessageListener listener2("xmlhttprequest", false); |
| 414 |
| 415 ASSERT_TRUE(LoadExtension( |
| 416 test_data_dir_.AppendASCII("webrequest_hosted_app"))); |
| 417 |
| 418 ui_test_utils::NavigateToURL(browser(), hosted_app_url); |
| 419 |
| 420 EXPECT_TRUE(listener1.WaitUntilSatisfied()); |
| 421 EXPECT_TRUE(listener2.WaitUntilSatisfied()); |
| 422 } |
OLD | NEW |