Skip to content

Commit

Permalink
Re-enable SignedExchangeSubresourcePrefetchBrowserTest.CORS
Browse files Browse the repository at this point in the history
It now fetches the preloaded resources concurrently (possibly making the
test run a bit faster), and console.log()s fetch results to help
diagnosing issues.

Bug: 1350046
Change-Id: I06082ad823f75b6af433c087611581e0696d59af
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3830858
Reviewed-by: Hayato Ito <hayato@chromium.org>
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Cr-Commit-Position: refs/heads/main@{#1034997}
  • Loading branch information
irori authored and Chromium LUCI CQ committed Aug 15, 2022
1 parent 2a81ba4 commit 6f8e9f9
Showing 1 changed file with 20 additions and 14 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1906,9 +1906,7 @@ IN_PROC_BROWSER_TEST_F(SignedExchangeSubresourcePrefetchBrowserTest,
EXPECT_EQ(1, script2_request_counter->GetRequestCount());
}

// TODO(crbug.com/1350046): Flaky.
IN_PROC_BROWSER_TEST_F(SignedExchangeSubresourcePrefetchBrowserTest,
DISABLED_CORS) {
IN_PROC_BROWSER_TEST_F(SignedExchangeSubresourcePrefetchBrowserTest, CORS) {
std::unique_ptr<net::EmbeddedTestServer> data_server =
std::make_unique<net::EmbeddedTestServer>(
net::EmbeddedTestServer::TYPE_HTTPS);
Expand Down Expand Up @@ -2096,18 +2094,26 @@ IN_PROC_BROWSER_TEST_F(SignedExchangeSubresourcePrefetchBrowserTest,
CreateSignedExchangeResponseEntry(
base::StringPrintf(R"(
<head><title>Prefetch Target (SXG)</title><script>
let results = [];
(async function(requests) {
for (let i = 0; i < requests.length; ++i) {
try {
const res = await fetch(requests[i]);
results.push(await res.text());
} catch (err) {
results.push('failed');
}
const requests = [%s];
const promises = [];
for (const request of requests) {
promises.push((async (request) => {
try {
const res = await fetch(request);
const result = await res.text();
console.log(request.url + ': ' + result);
return result;
} catch (err) {
console.log(request.url + ': failed');
return 'failed';
}
})(request));
}
document.title = 'done';
})([%s]);
let results = null;
Promise.all(promises).then((values) => {
results = values;
document.title = 'done';
});
</script></head>)",
requests_list_string.c_str()),
{{"link", target_sxg_outer_link_header}}));
Expand Down

0 comments on commit 6f8e9f9

Please sign in to comment.