Bug 1528702 [wpt PR 15388] - SignedExchange: Close response body data pipe on integrity error, a=testonly

Automatic update from web-platform-tests
SignedExchange: Close response body data pipe on integrity error

This fixes a bug where data pipe for response body was not closed when
Signed Exchange has payload integrity error.

SourceStreamToDataPipe::OnComplete() attempts to close the pipe by
resetting |pending_write_|. But if |source_| is a FilterSourceStream, it
still retains a reference to |pending_write_|. We should explicitly call
|pending_write_->Complete(0)| to free the pipe on error cases too.

Bug: 931955
Change-Id: I63b2470dbb92aa57016c5c71222bcdabe889fd34
Reviewed-on: https://chromium-review.googlesource.com/c/1470355
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#632118}

--

wpt-commits: 2867bad83ba14201d96f1eaf54027164251fe541
wpt-pr: 15388
This commit is contained in:
Kunihiko Sakamoto 2019-03-05 12:13:47 +00:00 committed by James Graham
parent 9177d56bf4
commit 932dbf1f52
4 changed files with 53 additions and 0 deletions

View File

@ -272,4 +272,7 @@ gen-signedexchange \
-miRecordSize 100 \
-ignoreErrors true
# Signed Exchange with payload integrity error.
echo 'garbage' | cat sxg/sxg-location.sxg - >sxg/sxg-merkle-integrity-error.sxg
rm -fr $tmpdir

View File

@ -0,0 +1,24 @@
<!DOCTYPE html>
<title>SignedHTTPExchange with payload integrity error</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="./resources/sxg-util.js"></script>
<body>
<script>
promise_test(async (t) => {
try {
const sxgUrl = get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg/sxg-merkle-integrity-error.sxg';
const message = await openSXGInIframeAndWaitForMessage(t, sxgUrl);
if (message.is_fallback) {
assert_unreached('Fallback redirect should not have happened');
} else {
assert_unreached('SXG should not have loaded');
}
} catch (e) {
assert_equals(e, 'timeout');
}
}, "SignedHTTPExchange with payload integrity error");
</script>
</body>

View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<title>Prefetching SignedHTTPExchange with payload integrity error should fail</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="/common/get-host-info.sub.js"></script>
<script src="./resources/sxg-util.js"></script>
<body>
<script>
promise_test(async (t) => {
const sxgUrl = get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg/sxg-merkle-integrity-error.sxg';
await new Promise(resolve => {
const link = document.createElement('link');
link.rel = 'prefetch';
link.href = sxgUrl;
link.addEventListener('error', t.step_func(() => {
resolve();
}));
link.addEventListener('load', t.step_func(() => {
assert_unreached('Prefetch should fail');
}));
document.body.appendChild(link);
});
}, "Prefetching SignedHTTPExchange with payload integrity error should fail");
</script>
</body>