Skip to content

Commit

Permalink
Revert "Add fetch uploading big arraybuffer test in LoaderBrowserTest."
Browse files Browse the repository at this point in the history
This reverts commit 9d31a5e.

Reason for revert: Android test bots failing
Looks like the test is causing a segfault.
Sample run: https://ci.chromium.org/p/chromium/builders/ci/android-marshmallow-x86-rel-non-cq/623

Bug: 1143642

Original change's description:
> Add fetch uploading big arraybuffer test in LoaderBrowserTest.
>
> This CL adds fetch uploading 150Mbytes arraybuffer test.
>
> Since similar layouttest was so slow, I decided to test it in browser
> test.
>
> Bug: 919361
> Change-Id: I693e67666e71b999276f25cfe0c0ff56436c4369
> Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2490964
> Commit-Queue: Yoichi Osato <yoichio@chromium.org>
> Reviewed-by: Matt Menke <mmenke@chromium.org>
> Cr-Commit-Position: refs/heads/master@{#821648}

TBR=mmenke@chromium.org,yoichio@chromium.org

# Not skipping CQ checks because original CL landed > 1 day ago.

Bug: 919361
Change-Id: Id415f1e404bc9bb53ae8e04a9556238314593f83
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2506181
Reviewed-by: Rayan Kanso <rayankans@chromium.org>
Commit-Queue: Rayan Kanso <rayankans@chromium.org>
Cr-Commit-Position: refs/heads/master@{#822150}
  • Loading branch information
rayankans authored and Commit Bot committed Oct 29, 2020
1 parent 25c9d39 commit 9845003
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 50 deletions.
44 changes: 3 additions & 41 deletions content/browser/loader/loader_browsertest.cc
Original file line number Diff line number Diff line change
Expand Up @@ -75,17 +75,6 @@ class LoaderBrowserTest : public ContentBrowserTest,
host_resolver()->AddRule("*", "127.0.0.1");
}

void WaitForTitleTest(const base::string16& expected_title,
const std::vector<base::string16> additional_titles) {
TitleWatcher title_watcher(shell()->web_contents(), expected_title);

for (const auto& title : additional_titles) {
title_watcher.AlsoWaitForTitle(title);
}
base::string16 actual_title = title_watcher.WaitAndGetTitle();
EXPECT_EQ(expected_title, actual_title);
}

void CheckTitleTest(const GURL& url, const std::string& expected_title) {
base::string16 expected_title16(ASCIIToUTF16(expected_title));
TitleWatcher title_watcher(shell()->web_contents(), expected_title16);
Expand Down Expand Up @@ -652,7 +641,8 @@ namespace {
// Creates a valid filesystem URL.
GURL CreateFileSystemURL(Shell* window) {
std::string filesystem_url_string;
EXPECT_TRUE(ExecuteScriptAndExtractString(window, R"(
EXPECT_TRUE(
ExecuteScriptAndExtractString(window, R"(
var blob = new Blob(['<html><body>hello</body></html>'],
{type: 'text/html'});
window.webkitRequestFileSystem(TEMPORARY, blob.size, fs => {
Expand All @@ -664,8 +654,7 @@ GURL CreateFileSystemURL(Shell* window) {
}
});
});
});)",
&filesystem_url_string));
});)", &filesystem_url_string));
GURL filesystem_url(filesystem_url_string);
EXPECT_TRUE(filesystem_url.is_valid());
EXPECT_TRUE(filesystem_url.SchemeIsFileSystem());
Expand Down Expand Up @@ -1277,31 +1266,4 @@ IN_PROC_BROWSER_TEST_F(LoaderBrowserTest, URLLoaderThrottleRedirectModify) {
SetBrowserClientForTesting(old_content_browser_client);
}

IN_PROC_BROWSER_TEST_F(LoaderBrowserTest, FetchUpload150MB) {
ASSERT_TRUE(embedded_test_server()->Start());
ASSERT_TRUE(
NavigateToURL(shell(), embedded_test_server()->GetURL("/title2.html")));
EXPECT_EQ(shell()->web_contents()->GetTitle(), ASCIIToUTF16("Title Of Awesomeness"));

ASSERT_TRUE(ExecuteScript(
shell(), base::StringPrintf(R"JS(
const length = 150*1000*1000; // 150 MB;
async function run() {
const array = new Uint8Array(length);
const response = await fetch('%s', { method: 'POST', body: array });
const text = await response.text();
if (text != length.toString())
throw `Content-Length actual:${text}, expected:${length.toString()}.`
};
run().then(() => { document.title = 'PASS'; },
(e) => { console.log(e); document.title = 'FAIL'; });
)JS",
embedded_test_server()
->GetURL("/echoheader?Content-Length")
.spec()
.c_str())));

WaitForTitleTest(ASCIIToUTF16("PASS"), {ASCIIToUTF16("FAIL")});
}

} // namespace content
27 changes: 18 additions & 9 deletions net/test/embedded_test_server/http_request.cc
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ namespace test_server {

namespace {

size_t kRequestSizeLimit = 64 * 1024 * 1024; // 64 mb.

// Helper function used to trim tokens in http request headers.
std::string Trim(const std::string& value) {
std::string result;
Expand All @@ -28,7 +30,9 @@ std::string Trim(const std::string& value) {

} // namespace

HttpRequest::HttpRequest() : method(METHOD_UNKNOWN), has_content(false) {}
HttpRequest::HttpRequest() : method(METHOD_UNKNOWN),
has_content(false) {
}

HttpRequest::HttpRequest(const HttpRequest& other) = default;

Expand All @@ -50,6 +54,8 @@ HttpRequestParser::~HttpRequestParser() = default;

void HttpRequestParser::ProcessChunk(const base::StringPiece& data) {
buffer_.append(data.data(), data.size());
DCHECK_LE(buffer_.size() + data.size(), kRequestSizeLimit) <<
"The HTTP request is too large.";
}

std::string HttpRequestParser::ShiftLine() {
Expand Down Expand Up @@ -110,8 +116,8 @@ HttpRequestParser::ParseResult HttpRequestParser::ParseHeaders() {

// Protocol.
const std::string protocol = base::ToLowerASCII(header_line_tokens[2]);
CHECK(protocol == "http/1.0" || protocol == "http/1.1")
<< "Protocol not supported: " << protocol;
CHECK(protocol == "http/1.0" || protocol == "http/1.1") <<
"Protocol not supported: " << protocol;
}

// Parse further headers.
Expand All @@ -134,7 +140,8 @@ HttpRequestParser::ParseResult HttpRequestParser::ParseHeaders() {
DCHECK_NE(std::string::npos, delimiter_pos) << "Syntax error.";
header_name = Trim(header_line.substr(0, delimiter_pos));
std::string header_value = Trim(header_line.substr(
delimiter_pos + 1, header_line.size() - delimiter_pos - 1));
delimiter_pos + 1,
header_line.size() - delimiter_pos - 1));
http_request_->headers[header_name] = header_value;
}
}
Expand All @@ -145,7 +152,8 @@ HttpRequestParser::ParseResult HttpRequestParser::ParseHeaders() {
if (http_request_->headers.count("Content-Length") > 0) {
http_request_->has_content = true;
const bool success = base::StringToSizeT(
http_request_->headers["Content-Length"], &declared_content_length_);
http_request_->headers["Content-Length"],
&declared_content_length_);
if (!success) {
declared_content_length_ = 0;
LOG(WARNING) << "Malformed Content-Length header's value.";
Expand Down Expand Up @@ -191,10 +199,11 @@ HttpRequestParser::ParseResult HttpRequestParser::ParseContent() {
return WAITING;
}

const size_t fetch_bytes =
std::min(available_bytes,
declared_content_length_ - http_request_->content.size());
http_request_->content.append(buffer_.data() + buffer_position_, fetch_bytes);
const size_t fetch_bytes = std::min(
available_bytes,
declared_content_length_ - http_request_->content.size());
http_request_->content.append(buffer_.data() + buffer_position_,
fetch_bytes);
buffer_position_ += fetch_bytes;

if (declared_content_length_ == http_request_->content.size()) {
Expand Down

0 comments on commit 9845003

Please sign in to comment.