-
Notifications
You must be signed in to change notification settings - Fork 3.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Set network_isolation_key for signed exchange cert fetch
Currently network_isolation_key is not set for signed exchange cert fetch. So, even if the signed exchange and the certificate were prefetched, the certificate is fetched again while navigation when SplitCacheByNetworkIsolationKey is enabled. Bug=1047110 Change-Id: I524df1da097c6f544777f20cca5a3e53246693cf Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2029564 Reviewed-by: Kinuko Yasuda <kinuko@chromium.org> Commit-Queue: Tsuyoshi Horo <horo@chromium.org> Cr-Commit-Position: refs/heads/master@{#737251}
- Loading branch information
1 parent
cdd3b61
commit 18200a1
Showing
6 changed files
with
98 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
import os | ||
|
||
|
||
def main(request, response): | ||
stash_id = request.GET.first("id") | ||
if request.server.stash.take(stash_id) is not None: | ||
response.status = (404, "Not Found") | ||
response.headers.set("Content-Type", "text/plain") | ||
return "not found" | ||
request.server.stash.put(stash_id, True) | ||
|
||
path = os.path.join(os.path.dirname(__file__), "127.0.0.1.sxg.pem.cbor") | ||
body = open(path, "rb").read() | ||
|
||
response.headers.set("Content-Type", "application/cert-chain+cbor") | ||
response.headers.set("Cache-Control", "public, max-age=600") | ||
return body |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import os | ||
|
||
|
||
def main(request, response): | ||
stash_id = request.GET.first("id") | ||
if request.server.stash.take(stash_id) is not None: | ||
response.status = (404, "Not Found") | ||
response.headers.set("Content-Type", "text/plain") | ||
return "not found" | ||
request.server.stash.put(stash_id, True) | ||
|
||
path = os.path.join(os.path.dirname(__file__), "sxg", "sxg-prefetch-test.sxg") | ||
body = open(path, "rb").read() | ||
|
||
response.headers.set("Content-Type", "application/signed-exchange;v=b3") | ||
response.headers.set("X-Content-Type-Options", "nosniff") | ||
response.headers.set("Cache-Control", "public, max-age=600") | ||
|
||
return body.replace('XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX', stash_id) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
<!DOCTYPE html> | ||
<title>Prefetch test SXG</title> | ||
<script> | ||
window.opener.postMessage('loaded', '*'); | ||
</script> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
<!DOCTYPE html> | ||
<title>Prefetched signed exchange and certificate must not be fetched again</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/common/get-host-info.sub.js"></script> | ||
<script src="/common/utils.js"></script> | ||
<script src="./resources/sxg-util.js"></script> | ||
<body> | ||
<script> | ||
promise_test(async (t) => { | ||
const id = token(); | ||
const sxgUrl = get_host_info().HTTPS_REMOTE_ORIGIN + '/signed-exchange/resources/prefetch-test-sxg.py?id=' + id; | ||
|
||
await new Promise(resolve => { | ||
const link = document.createElement('link'); | ||
link.rel = 'prefetch'; | ||
link.href = sxgUrl; | ||
link.as = 'document'; | ||
link.addEventListener('error', t.step_func(() => { | ||
assert_unreached('Prefetch should not fail'); | ||
})); | ||
link.addEventListener('load', t.step_func(() => { | ||
resolve(); | ||
})); | ||
document.body.appendChild(link); | ||
}); | ||
const message_promise = new Promise((resolve) => { | ||
window.addEventListener('message', (event) => { | ||
resolve(event.data); | ||
}, false); | ||
}); | ||
const win = window.open(sxgUrl, "_blank"); | ||
const message = await message_promise; | ||
win.close(); | ||
assert_equals(message, 'loaded'); | ||
}, 'Prefetched signed exchange and certificate must not be fetched again.'); | ||
|
||
</script> | ||
</body> |