Chromium Code Reviews| Index: chrome/browser/net/websocket_browsertest.cc |
| diff --git a/chrome/browser/net/websocket_browsertest.cc b/chrome/browser/net/websocket_browsertest.cc |
| index 58605de17472bd041be93ceaeb05db77567c0670..3d266cd0e207a7fdb9041893061eb627583f232d 100644 |
| --- a/chrome/browser/net/websocket_browsertest.cc |
| +++ b/chrome/browser/net/websocket_browsertest.cc |
| @@ -29,6 +29,26 @@ class WebSocketBrowserTest : public InProcessBrowserTest { |
| net::SpawnedTestServer ws_server_; |
| net::SpawnedTestServer wss_server_; |
|
mmenke
2014/07/24 14:34:32
data members should go at the end of a section.
yhirano
2014/07/25 01:48:59
Done.
|
| + void NavigateToHTTP(const std::string& path) { |
|
mmenke
2014/07/24 14:34:32
Should probably include string header.
yhirano
2014/07/25 01:48:59
Done.
|
| + // Visit a HTTP page for testing. |
|
mmenke
2014/07/24 14:34:32
This section should use 2-space indent.
yhirano
2014/07/25 01:48:59
Done.
|
| + std::string scheme("http"); |
| + GURL::Replacements replacements; |
| + replacements.SetSchemeStr(scheme); |
|
mmenke
2014/07/24 14:34:32
And the gurl header as well.
yhirano
2014/07/25 01:48:59
Done.
|
| + ui_test_utils::NavigateToURL( |
| + browser(), |
| + ws_server_.GetURL(path).ReplaceComponents(replacements)); |
| + } |
| + |
| + void NavigateToHTTPS(const std::string& path) { |
| + // Visit a HTTPS page for testing. |
|
mmenke
2014/07/24 14:34:31
This section should use 2-space indent.
yhirano
2014/07/25 01:48:59
Done.
|
| + std::string scheme("https"); |
| + GURL::Replacements replacements; |
| + replacements.SetSchemeStr(scheme); |
| + ui_test_utils::NavigateToURL( |
| + browser(), |
| + wss_server_.GetURL(path).ReplaceComponents(replacements)); |
| + } |
| + |
| private: |
| typedef net::SpawnedTestServer::SSLOptions SSLOptions; |
| @@ -47,14 +67,7 @@ IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, WebSocketSplitSegments) { |
| content::TitleWatcher watcher(tab, base::ASCIIToUTF16("PASS")); |
| watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
| - // Visit a HTTP page for testing. |
| - std::string scheme("http"); |
| - GURL::Replacements replacements; |
| - replacements.SetSchemeStr(scheme); |
| - ui_test_utils::NavigateToURL( |
| - browser(), |
| - ws_server_.GetURL( |
| - "split_packet_check.html").ReplaceComponents(replacements)); |
| + NavigateToHTTP("split_packet_check.html"); |
| const base::string16 result = watcher.WaitAndGetTitle(); |
| EXPECT_TRUE(EqualsASCII(result, "PASS")); |
|
mmenke
2014/07/24 14:34:32
optional: Suggest using:
EXPECT_EQ(base::ASCIITo
yhirano
2014/07/25 01:48:59
Done.
|
| @@ -70,17 +83,43 @@ IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, SecureWebSocketSplitRecords) { |
| content::TitleWatcher watcher(tab, base::ASCIIToUTF16("PASS")); |
| watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
| - // Visit a HTTPS page for testing. |
| - std::string scheme("https"); |
| - GURL::Replacements replacements; |
| - replacements.SetSchemeStr(scheme); |
| - ui_test_utils::NavigateToURL( |
| - browser(), |
| - wss_server_.GetURL( |
| - "split_packet_check.html").ReplaceComponents(replacements)); |
| + NavigateToHTTPS("split_packet_check.html"); |
| const base::string16 result = watcher.WaitAndGetTitle(); |
| EXPECT_TRUE(EqualsASCII(result, "PASS")); |
| } |
| +IN_PROC_BROWSER_TEST_F(WebSocketBrowserTest, SendCloseFrameWhenTabIsClosed) { |
| + // Launch a WebSocket server. |
| + ASSERT_TRUE(ws_server_.Start()); |
| + |
| + content::WebContents* tab = |
| + browser()->tab_strip_model()->GetActiveWebContents(); |
| + { |
| + // Create a new tab, establish a WebSocket connection and close the tab. |
| + content::WebContents* newTab = |
|
mmenke
2014/07/24 14:34:32
new_tab.
yhirano
2014/07/25 01:48:59
Done.
|
| + content::WebContents::Create( |
| + content::WebContents::CreateParams(tab->GetBrowserContext())); |
| + browser()->tab_strip_model()->AppendWebContents(newTab, true); |
| + ASSERT_EQ(newTab, browser()->tab_strip_model()->GetWebContentsAt(1)); |
| + content::TitleWatcher title_watcher(newTab, |
|
mmenke
2014/07/24 14:34:32
Suggest using another name for this watcher, to ma
yhirano
2014/07/25 01:48:59
Done.
|
| + base::ASCIIToUTF16("CONNECTED")); |
| + title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("CLOSED")); |
| + content::WebContentsDestroyedWatcher destroyed_watcher(newTab); |
|
mmenke
2014/07/24 14:34:32
Any reason to declare this here, instead of just b
yhirano
2014/07/25 01:48:59
Done.
|
| + |
| + NavigateToHTTP("counted_connection.html"); |
| + const base::string16 result = title_watcher.WaitAndGetTitle(); |
| + EXPECT_TRUE(EqualsASCII(result, "CONNECTED")); |
| + browser()->tab_strip_model()->CloseWebContentsAt(1, 0); |
| + destroyed_watcher.Wait(); |
| + } |
| + |
| + content::TitleWatcher title_watcher(tab, base::ASCIIToUTF16("PASS")); |
| + title_watcher.AlsoWaitForTitle(base::ASCIIToUTF16("FAIL")); |
| + |
| + NavigateToHTTP("count_connection.html"); |
| + const base::string16 result = title_watcher.WaitAndGetTitle(); |
| + EXPECT_TRUE(EqualsASCII(result, "PASS")); |
| +} |
| + |
| } // namespace |