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 "base/macros.h" | 6 #include "base/macros.h" |
7 #include "base/memory/ptr_util.h" | 7 #include "base/memory/ptr_util.h" |
8 #include "base/strings/stringprintf.h" | 8 #include "base/strings/stringprintf.h" |
9 #include "build/build_config.h" | 9 #include "build/build_config.h" |
10 #include "chrome/browser/chrome_notification_types.h" | 10 #include "chrome/browser/chrome_notification_types.h" |
(...skipping 21 matching lines...) Expand all Loading... |
32 #include "content/public/test/browser_test_utils.h" | 32 #include "content/public/test/browser_test_utils.h" |
33 #include "extensions/browser/api/web_request/web_request_api.h" | 33 #include "extensions/browser/api/web_request/web_request_api.h" |
34 #include "extensions/browser/blocked_action_type.h" | 34 #include "extensions/browser/blocked_action_type.h" |
35 #include "extensions/browser/extension_system.h" | 35 #include "extensions/browser/extension_system.h" |
36 #include "extensions/common/extension_builder.h" | 36 #include "extensions/common/extension_builder.h" |
37 #include "extensions/common/features/feature.h" | 37 #include "extensions/common/features/feature.h" |
38 #include "extensions/test/extension_test_message_listener.h" | 38 #include "extensions/test/extension_test_message_listener.h" |
39 #include "extensions/test/result_catcher.h" | 39 #include "extensions/test/result_catcher.h" |
40 #include "net/dns/mock_host_resolver.h" | 40 #include "net/dns/mock_host_resolver.h" |
41 #include "net/test/embedded_test_server/embedded_test_server.h" | 41 #include "net/test/embedded_test_server/embedded_test_server.h" |
| 42 #include "net/test/test_data_directory.h" |
42 #include "third_party/WebKit/public/platform/WebInputEvent.h" | 43 #include "third_party/WebKit/public/platform/WebInputEvent.h" |
43 | 44 |
44 using content::WebContents; | 45 using content::WebContents; |
45 | 46 |
46 namespace extensions { | 47 namespace extensions { |
47 | 48 |
48 namespace { | 49 namespace { |
49 | 50 |
50 class CancelLoginDialog : public content::NotificationObserver { | 51 class CancelLoginDialog : public content::NotificationObserver { |
51 public: | 52 public: |
(...skipping 594 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
646 TabHelper::FromWebContents(web_contents)->active_tab_permission_granter(); | 647 TabHelper::FromWebContents(web_contents)->active_tab_permission_granter(); |
647 ASSERT_TRUE(granter); | 648 ASSERT_TRUE(granter); |
648 granter->RevokeForTesting(); | 649 granter->RevokeForTesting(); |
649 base::RunLoop().RunUntilIdle(); | 650 base::RunLoop().RunUntilIdle(); |
650 PerformXhrInFrame(main_frame, kHost, port, kXhrPath); | 651 PerformXhrInFrame(main_frame, kHost, port, kXhrPath); |
651 EXPECT_EQ(xhr_count, | 652 EXPECT_EQ(xhr_count, |
652 GetWebRequestCountFromBackgroundPage(extension, profile())); | 653 GetWebRequestCountFromBackgroundPage(extension, profile())); |
653 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); | 654 EXPECT_EQ(BLOCKED_ACTION_WEB_REQUEST, runner->GetBlockedActions(extension)); |
654 } | 655 } |
655 | 656 |
| 657 // Test that the webRequest events are dispatched for the WebSocket handshake |
| 658 // requests. |
| 659 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, WebSocketRequest) { |
| 660 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 661 ASSERT_TRUE(StartWebSocketServer(net::GetWebSocketTestDataDirectory())); |
| 662 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_websocket.html")) |
| 663 << message_; |
| 664 } |
| 665 |
| 666 // Test that the webRequest events are dispatched for the WebSocket handshake |
| 667 // requests when authenrication is requested by server. |
| 668 IN_PROC_BROWSER_TEST_F(ExtensionWebRequestApiTest, |
| 669 WebSocketRequestAuthRequired) { |
| 670 ASSERT_TRUE(StartEmbeddedTestServer()); |
| 671 ASSERT_TRUE(StartWebSocketServer(net::GetWebSocketTestDataDirectory(), true)); |
| 672 ASSERT_TRUE(RunExtensionSubtest("webrequest", "test_websocket_auth.html")) |
| 673 << message_; |
| 674 } |
| 675 |
656 } // namespace extensions | 676 } // namespace extensions |
OLD | NEW |