OLD | NEW |
---|---|
(Empty) | |
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 | |
3 // found in the LICENSE file. | |
4 | |
5 #include "base/string_util.h" | |
6 #include "base/utf_string_conversions.h" | |
7 #include "chrome/browser/ui/browser.h" | |
8 #include "chrome/browser/ui/browser_tabstrip.h" | |
9 #include "chrome/test/base/in_process_browser_test.h" | |
10 #include "chrome/test/base/ui_test_utils.h" | |
11 #include "content/public/test/browser_test_utils.h" | |
12 #include "net/base/test_data_directory.h" | |
13 #include "net/test/test_server.h" | |
14 | |
15 namespace { | |
16 | |
17 class WebSocketBrowserTest : public InProcessBrowserTest { | |
18 public: | |
19 WebSocketBrowserTest() | |
20 : ws_server_(net::TestServer::TYPE_WS, | |
21 net::TestServer::kLocalhost, | |
22 net::GetWebSocketTestDataDirectory()), | |
23 wss_server_(net::TestServer::TYPE_WSS, | |
24 SSLOptions(SSLOptions::CERT_OK), | |
25 net::GetWebSocketTestDataDirectory()) { | |
26 } | |
27 | |
28 protected: | |
29 net::TestServer ws_server_; | |
30 net::TestServer wss_server_; | |
31 | |
32 private: | |
33 typedef net::TestServer::SSLOptions SSLOptions; | |
34 | |
35 DISALLOW_COPY_AND_ASSIGN(WebSocketBrowserTest); | |
36 }; | |
37 | |
38 // Test that the browser can handle a WebSocket frame splitted into multiple TCP | |
39 // frames. | |
wtc
2012/12/14 22:55:14
splitted => split
("split" is an irregular verb.
Takashi Toyoshima
2012/12/21 07:43:03
Thanks!
| |
40 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, SplitWebSocketFrame) { | |
41 // Launch a WebSocket server. | |
42 ASSERT_TRUE(ws_server_.Start()); | |
43 | |
44 // Setup page title observer. | |
45 content::WebContents* tab = chrome::GetActiveWebContents(browser()); | |
46 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); | |
47 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | |
48 | |
49 // Visit a HTTP page for testing. | |
50 std::string scheme("http"); | |
51 GURL::Replacements replacements; | |
52 replacements.SetSchemeStr(scheme); | |
53 ui_test_utils::NavigateToURL( | |
54 browser(), | |
55 ws_server_.GetURL( | |
56 "split_frame_check.html").ReplaceComponents(replacements)); | |
57 | |
58 const string16 result = watcher.WaitAndGetTitle(); | |
59 EXPECT_TRUE(EqualsASCII(result, "PASS")); | |
60 } | |
61 | |
62 // Test that the browser can handle a WebSocket frame splitted into multiple TCP | |
63 // or SSL frames. | |
wtc
2012/12/14 22:55:14
In SSL, these are called "records". But informally
Takashi Toyoshima
2012/12/21 07:43:03
Thanks again.
I prefer to use "records" here.
I wa
| |
64 IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, SplitSecureWebSocketFrame) { | |
65 // Launch a secure WebSocket server. | |
66 ASSERT_TRUE(wss_server_.Start()); | |
67 | |
68 // Setup page title observer. | |
69 content::WebContents* tab = chrome::GetActiveWebContents(browser()); | |
70 content::TitleWatcher watcher(tab, ASCIIToUTF16("PASS")); | |
71 watcher.AlsoWaitForTitle(ASCIIToUTF16("FAIL")); | |
72 | |
73 // Visit a HTTPS page for testing. | |
74 std::string scheme("https"); | |
75 GURL::Replacements replacements; | |
76 replacements.SetSchemeStr(scheme); | |
77 ui_test_utils::NavigateToURL( | |
78 browser(), | |
79 wss_server_.GetURL( | |
80 "split_frame_check.html").ReplaceComponents(replacements)); | |
81 | |
82 const string16 result = watcher.WaitAndGetTitle(); | |
83 EXPECT_TRUE(EqualsASCII(result, "PASS")); | |
84 } | |
85 | |
86 } // namespace | |
OLD | NEW |