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