| OLD | NEW |
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 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 "content/browser/loader/async_resource_handler.h" | 5 #include "content/browser/loader/async_resource_handler.h" |
| 6 | 6 |
| 7 #include <string> | 7 #include <string> |
| 8 | 8 |
| 9 #include "base/format_macros.h" | 9 #include "base/format_macros.h" |
| 10 #include "base/strings/string_util.h" | 10 #include "base/strings/string_util.h" |
| (...skipping 47 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 58 return scoped_ptr<net::test_server::HttpResponse>(); | 58 return scoped_ptr<net::test_server::HttpResponse>(); |
| 59 } | 59 } |
| 60 } | 60 } |
| 61 | 61 |
| 62 } // namespace | 62 } // namespace |
| 63 | 63 |
| 64 class AsyncResourceHandlerBrowserTest : public ContentBrowserTest { | 64 class AsyncResourceHandlerBrowserTest : public ContentBrowserTest { |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 IN_PROC_BROWSER_TEST_F(AsyncResourceHandlerBrowserTest, UploadProgress) { | 67 IN_PROC_BROWSER_TEST_F(AsyncResourceHandlerBrowserTest, UploadProgress) { |
| 68 net::test_server::EmbeddedTestServer* test_server = embedded_test_server(); | 68 net::EmbeddedTestServer* test_server = embedded_test_server(); |
| 69 ASSERT_TRUE(test_server->InitializeAndWaitUntilReady()); | 69 ASSERT_TRUE(test_server->Start()); |
| 70 test_server->RegisterRequestHandler( | 70 test_server->RegisterRequestHandler( |
| 71 base::Bind(&HandlePostAndRedirectURLs, kPostPath)); | 71 base::Bind(&HandlePostAndRedirectURLs, kPostPath)); |
| 72 | 72 |
| 73 NavigateToURL(shell(), | 73 NavigateToURL(shell(), |
| 74 test_server->GetURL("/loader/async_resource_handler.html")); | 74 test_server->GetURL("/loader/async_resource_handler.html")); |
| 75 | 75 |
| 76 std::string js_result; | 76 std::string js_result; |
| 77 EXPECT_TRUE(ExecuteScriptAndExtractString( | 77 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 78 shell()->web_contents(), | 78 shell()->web_contents(), |
| 79 base::StringPrintf("WaitForAsyncXHR('%s', %" PRIuS ")", | 79 base::StringPrintf("WaitForAsyncXHR('%s', %" PRIuS ")", |
| 80 kPostPath, | 80 kPostPath, |
| 81 kPayloadSize), | 81 kPayloadSize), |
| 82 &js_result)); | 82 &js_result)); |
| 83 EXPECT_EQ(js_result, "success"); | 83 EXPECT_EQ(js_result, "success"); |
| 84 } | 84 } |
| 85 | 85 |
| 86 IN_PROC_BROWSER_TEST_F(AsyncResourceHandlerBrowserTest, | 86 IN_PROC_BROWSER_TEST_F(AsyncResourceHandlerBrowserTest, |
| 87 UploadProgressRedirect) { | 87 UploadProgressRedirect) { |
| 88 net::test_server::EmbeddedTestServer* test_server = embedded_test_server(); | 88 net::EmbeddedTestServer* test_server = embedded_test_server(); |
| 89 ASSERT_TRUE(test_server->InitializeAndWaitUntilReady()); | 89 ASSERT_TRUE(test_server->Start()); |
| 90 test_server->RegisterRequestHandler( | 90 test_server->RegisterRequestHandler( |
| 91 base::Bind(&HandlePostAndRedirectURLs, kRedirectPostPath)); | 91 base::Bind(&HandlePostAndRedirectURLs, kRedirectPostPath)); |
| 92 | 92 |
| 93 NavigateToURL(shell(), | 93 NavigateToURL(shell(), |
| 94 test_server->GetURL("/loader/async_resource_handler.html")); | 94 test_server->GetURL("/loader/async_resource_handler.html")); |
| 95 | 95 |
| 96 std::string js_result; | 96 std::string js_result; |
| 97 EXPECT_TRUE(ExecuteScriptAndExtractString( | 97 EXPECT_TRUE(ExecuteScriptAndExtractString( |
| 98 shell()->web_contents(), | 98 shell()->web_contents(), |
| 99 base::StringPrintf("WaitForAsyncXHR('%s', %" PRIuS ")", | 99 base::StringPrintf("WaitForAsyncXHR('%s', %" PRIuS ")", |
| 100 kRedirectPostPath, | 100 kRedirectPostPath, |
| 101 kPayloadSize), | 101 kPayloadSize), |
| 102 &js_result)); | 102 &js_result)); |
| 103 EXPECT_EQ(js_result, "success"); | 103 EXPECT_EQ(js_result, "success"); |
| 104 } | 104 } |
| 105 | 105 |
| 106 } // namespace content | 106 } // namespace content |
| OLD | NEW |