Commit 2957c4d8 authored by Kunihiko Sakamoto's avatar Kunihiko Sakamoto Committed by Commit Bot

Move more Signed Exchange layout tests to WPT

Bug: 895723
Change-Id: If7918de7e3717b01619ee21fa87eeaffb971287c
Reviewed-on: https://chromium-review.googlesource.com/c/1292661Reviewed-by: default avatarKouhei Ueno <kouhei@chromium.org>
Reviewed-by: default avatarTsuyoshi Horo <horo@chromium.org>
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#601828}
parent 63538207
......@@ -662,6 +662,11 @@
"base": "http/tests/devtools/sxg",
"args": ["--enable-features=SignedHTTPExchange,NetworkService"]
},
{
"prefix": "sxg-with-network-service",
"base": "external/wpt/signed-exchange",
"args": ["--enable-features=SignedHTTPExchange,NetworkService"]
},
{
"prefix": "sxg-origin-trial",
"base": "http/tests/loading/sxg",
......
<!DOCTYPE html>
<title>Fallback redirect to another SignedHTTPExchange</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<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) => {
await waitUntilDidFinishLoadForFrame;
const message = await openSXGInIframeAndWaitForMessage(t, 'resources/fallback-to-another-sxg.sxg');
assert_equals(message.location, 'https://127.0.0.1:8443/loading/sxg/resources/inner-url.html');
const sxgUrl = get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/fallback-to-another-sxg.sxg';
const message = await openSXGInIframeAndWaitForMessage(t, sxgUrl);
assert_equals(message.location, innerURLOrigin() + '/signed-exchange/resources/inner-url.html');
assert_false(message.is_fallback);
}, 'Fallback redirect to another SignedHTTPExchange');
......
<!DOCTYPE html>
<title>Nested SignedHTTPExchange</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<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) => {
await waitUntilDidFinishLoadForFrame;
const message = await openSXGInIframeAndWaitForMessage(t, 'resources/nested-sxg.sxg');
assert_equals(message.location, 'https://127.0.0.1:8443/loading/sxg/resources/inner-url.html?fallback-from-nested-sxg');
const sxgUrl = get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/nested-sxg.sxg';
const message = await openSXGInIframeAndWaitForMessage(t, sxgUrl);
assert_equals(message.location, innerURLOrigin() + '/signed-exchange/resources/inner-url.html?fallback-from-nested-sxg');
assert_true(message.is_fallback);
}, 'Nested SignedHTTPExchange');
......
#!/bin/sh
certfile=127.0.0.1.sxg.pem
keyfile=127.0.0.1.sxg.key
host=127.0.0.1
inner_url_origin=https://127.0.0.1:8444
# TODO: Stop hard-coding "web-platform.test" in certUrl when generating
# Signed Exchanges on the fly.
cert_url_origin=https://web-platform.test:8444
sxg_content_type='content-type: application/signed-exchange;v=b2'
set -e
......@@ -18,20 +23,65 @@ tmpdir=$(mktemp -d)
echo -n OCSP >$tmpdir/ocsp
gen-certurl -pem $certfile -ocsp $tmpdir/ocsp > $certfile.cbor
# TODO: Stop hard-coding "web-platform.test" in certUrl when generating
# Signed Exchanges on the fly.
# A valid Signed Exchange.
gen-signedexchange \
-version 1b2 \
-uri https://$host/signed-exchange/resources/inner-url.html \
-uri $inner_url_origin/signed-exchange/resources/inner-url.html \
-status 200 \
-content sxg-location.html \
-certificate $certfile \
-certUrl https://web-platform.test:8444/signed-exchange/resources/$certfile.cbor \
-validityUrl https://$host/signed-exchange/resources/resource.validity.msg \
-certUrl $cert_url_origin/signed-exchange/resources/$certfile.cbor \
-validityUrl $inner_url_origin/signed-exchange/resources/resource.validity.msg \
-privateKey $keyfile \
-date 2018-04-01T00:00:00Z \
-expire 168h \
-o sxg-location.sxg \
-miRecordSize 100
# validityUrl is different origin from request URL.
gen-signedexchange \
-version 1b2 \
-uri $inner_url_origin/signed-exchange/resources/inner-url.html \
-status 200 \
-content failure.html \
-certificate $certfile \
-certUrl $cert_url_origin/signed-exchange/resources/$certfile.cbor \
-validityUrl https://example.com/signed-exchange/resources/resource.validity.msg \
-privateKey $keyfile \
-date 2018-04-01T00:00:00Z \
-expire 168h \
-o sxg-invalid-validity-url.sxg \
-miRecordSize 100
# certUrl is 404 and fallback URL is another signed exchange.
gen-signedexchange \
-version 1b2 \
-uri $inner_url_origin/signed-exchange/resources/sxg-location.sxg \
-status 200 \
-content failure.html \
-certificate $certfile \
-certUrl $cert_url_origin/signed-exchange/resources/not_found_$certfile.cbor \
-validityUrl $inner_url_origin/signed-exchange/resources/resource.validity.msg \
-privateKey $keyfile \
-date 2018-04-01T00:00:00Z \
-expire 168h \
-o fallback-to-another-sxg.sxg \
-miRecordSize 100
# Nested signed exchange.
gen-signedexchange \
-version 1b2 \
-uri "$inner_url_origin/signed-exchange/resources/inner-url.html?fallback-from-nested-sxg" \
-status 200 \
-content sxg-location.sxg \
-responseHeader "$sxg_content_type" \
-certificate $certfile \
-certUrl $cert_url_origin/signed-exchange/resources/$certfile.cbor \
-validityUrl $inner_url_origin/signed-exchange/resources/resource.validity.msg \
-privateKey $keyfile \
-date 2018-04-01T00:00:00Z \
-expire 168h \
-o nested-sxg.sxg \
-miRecordSize 100
rm -fr $tmpdir
<!DOCTYPE html>
<title>Content of fallback URL</title>
<script>
window.addEventListener('message', (event) => {
event.data.port.postMessage({location: document.location.href, is_fallback: true});
}, false);
</script>
......@@ -34,3 +34,7 @@ function loadScript(url) {
document.head.appendChild(scriptTag);
});
}
function innerURLOrigin() {
return 'https://127.0.0.1:8444';
}
<!DOCTYPE html>
<title>Prefetching double SignedHTTPExchange files must not crash</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<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>
......@@ -13,9 +14,9 @@ function addPrefetch(url) {
}
promise_test(async (t) => {
const sxg1_url =
'http://127.0.0.1:8000/loading/sxg/resources/sxg-location.sxg?1';
get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg-location.sxg?1';
const sxg2_url =
'http://127.0.0.1:8000/loading/sxg/resources/sxg-location.sxg?2';
get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg-location.sxg?2';
addPrefetch(sxg1_url);
addPrefetch(sxg2_url);
await new Promise(resolve => {
......
<!DOCTYPE html>
<title>Fallback redirect of SignedHTTPExchange should preserve URL fragment</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<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) => {
await waitUntilDidFinishLoadForFrame;
const message = await openSXGInIframeAndWaitForMessage(t, 'resources/sxg-invalid-validity-url.sxg#fragment');
assert_equals(message.location, 'https://127.0.0.1:8443/loading/sxg/resources/inner-url.html#fragment');
const sxgUrl = get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg-invalid-validity-url.sxg#fragment';
const message = await openSXGInIframeAndWaitForMessage(t, sxgUrl);
assert_equals(message.location, innerURLOrigin() + '/signed-exchange/resources/inner-url.html#fragment');
assert_true(message.is_fallback);
}, 'Fallback redirect of SignedHTTPExchange should preserve URL fragment');
</script>
</body>
<!DOCTYPE html>
<title>Loading SignedHTTPExchange which validity URL is different origin from
request URL must fail</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<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) => {
await waitUntilDidFinishLoadForFrame;
const message = await openSXGInIframeAndWaitForMessage(t, 'resources/sxg-invalid-validity-url.sxg');
assert_equals(message.location, 'https://127.0.0.1:8443/loading/sxg/resources/inner-url.html');
const sxgUrl = get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg-invalid-validity-url.sxg';
const message = await openSXGInIframeAndWaitForMessage(t, sxgUrl);
assert_equals(message.location, innerURLOrigin() + '/signed-exchange/resources/inner-url.html');
assert_true(message.is_fallback);
}, 'Loading SignedHTTPExchange which validity URL is different origin from ' +
'request URL must fail');
......
<!DOCTYPE html>
<title>Navigating to a Signed Exchange should preserve URL fragment</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<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) => {
await waitUntilDidFinishLoadForFrame;
const message = await openSXGInIframeAndWaitForMessage(t, 'resources/sxg-location.sxg#fragment');
assert_equals(message.location, 'https://127.0.0.1:8443/loading/sxg/resources/inner-url.html#fragment');
const sxgUrl = get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg-location.sxg#fragment';
const message = await openSXGInIframeAndWaitForMessage(t, sxgUrl);
assert_equals(message.location, innerURLOrigin() + '/signed-exchange/resources/inner-url.html#fragment');
assert_false(message.is_fallback);
}, 'Navigating to a Signed Exchange should preserve URL fragment');
......
......@@ -9,7 +9,7 @@
promise_test(async (t) => {
const sxgUrl = get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg-location.sxg';
const message = await openSXGInIframeAndWaitForMessage(t, sxgUrl);
assert_equals(message.location, 'https://127.0.0.1/signed-exchange/resources/inner-url.html');
assert_equals(message.location, innerURLOrigin() + '/signed-exchange/resources/inner-url.html');
assert_false(message.is_fallback);
}, 'Location of SignedHTTPExchange');
......
<!DOCTYPE html>
<title>Loading SignedHTTPExchange from non secure origin must fail</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<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) => {
await waitUntilDidFinishLoadForFrame;
try {
await openSXGInIframeAndWaitForMessage(
t, 'http://example.test:8080/loading/sxg/resources/sxg-location.sxg');
const sxgUrl = get_host_info().HTTP_ORIGIN + '/signed-exchange/resources/sxg-location.sxg';
await openSXGInIframeAndWaitForMessage(t, sxgUrl);
assert_unreached('SXG should not have loaded');
} catch (e) {
assert_equals(e, 'timeout');
......
<!DOCTYPE html>
<title>Resource Timing for prefetched SignedHTTPExchange</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<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>
......@@ -11,7 +12,8 @@ function addPrefetch(url) {
link.href = url;
document.body.appendChild(link);
}
async function wait_for_performance_entries(url) {
async function waitForPerformanceEntries(url) {
let entries = performance.getEntriesByName(url);
if (entries.length > 0) {
return entries;
......@@ -27,9 +29,9 @@ async function wait_for_performance_entries(url) {
}
promise_test(async (t) => {
const url = 'http://127.0.0.1:8000/loading/sxg/resources/sxg-location.sxg';
const url = get_host_info().HTTPS_ORIGIN + '/signed-exchange/resources/sxg-location.sxg';
addPrefetch(url);
return wait_for_performance_entries(url).then((entries) => {
return waitForPerformanceEntries(url).then((entries) => {
assert_equals(entries.length, 1, "Should have only one resource timing entry");
const e = entries[0];
assert_greater_than(e.duration, 0, "duration should be greater than 0");
......
......@@ -87,36 +87,4 @@ gen-signedexchange \
-o sxg-invalid-validity-url.sxg \
-miRecordSize 100
# Generate the signed exchange whose certUrl is 404 and fallback URL is another
# signed exchange.
gen-signedexchange \
-version 1b2 \
-uri https://127.0.0.1:8443/loading/sxg/resources/sxg-location.sxg \
-status 200 \
-content failure.html \
-certificate $certs_dir/127.0.0.1.sxg.pem \
-certUrl https://127.0.0.1:8443/loading/sxg/resources/not_found_cert.pem.cbor \
-validityUrl https://127.0.0.1:8443/loading/sxg/resources/not_found_cert.validity.msg \
-privateKey $certs_dir/127.0.0.1.sxg.key \
-date 2018-04-01T00:00:00Z \
-expire 168h \
-o fallback-to-another-sxg.sxg \
-miRecordSize 100
# Generate the nested signed exchange file.
gen-signedexchange \
-version 1b2 \
-uri 'https://127.0.0.1:8443/loading/sxg/resources/inner-url.html?fallback-from-nested-sxg' \
-status 200 \
-content sxg-location.sxg \
-responseHeader 'content-type: application/signed-exchange;v=b2' \
-certificate $certs_dir/127.0.0.1.sxg.pem \
-certUrl https://127.0.0.1:8443/loading/sxg/resources/127.0.0.1.sxg.pem.cbor \
-validityUrl https://127.0.0.1:8443/loading/sxg/resources/resource.validity.msg \
-privateKey $certs_dir/127.0.0.1.sxg.key \
-date 2018-04-01T00:00:00Z \
-expire 168h \
-o nested-sxg.sxg \
-miRecordSize 100
rm -fr $tmpdir
main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Fallback redirect to another SignedHTTPExchange
main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
frame "sxg_iframe" - didReceiveTitle:
frame "sxg_iframe" - didStartProvisionalLoadForFrame
frame "sxg_iframe" - didFailProvisionalLoadWithError
This is a testharness.js-based test.
FAIL Fallback redirect to another SignedHTTPExchange promise_test: Unhandled rejection with value: "timeout"
Harness: the test ran to completion.
main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Nested SignedHTTPExchange
main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
frame "sxg_iframe" - didReceiveTitle:
frame "sxg_iframe" - didStartProvisionalLoadForFrame
frame "sxg_iframe" - didFailProvisionalLoadWithError
This is a testharness.js-based test.
FAIL Nested SignedHTTPExchange promise_test: Unhandled rejection with value: "timeout"
Harness: the test ran to completion.
main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Fallback redirect of SignedHTTPExchange should preserve URL fragment
main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
frame "sxg_iframe" - didReceiveTitle:
frame "sxg_iframe" - didStartProvisionalLoadForFrame
frame "sxg_iframe" - didFailProvisionalLoadWithError
This is a testharness.js-based test.
FAIL Fallback redirect of SignedHTTPExchange should preserve URL fragment promise_test: Unhandled rejection with value: "timeout"
Harness: the test ran to completion.
main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Loading SignedHTTPExchange which validity URL is different origin from request URL must fail
main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
frame "sxg_iframe" - didReceiveTitle:
frame "sxg_iframe" - didStartProvisionalLoadForFrame
frame "sxg_iframe" - didFailProvisionalLoadWithError
This is a testharness.js-based test.
FAIL Loading SignedHTTPExchange which validity URL is different origin from request URL must fail promise_test: Unhandled rejection with value: "timeout"
Harness: the test ran to completion.
main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Navigating to a Signed Exchange should preserve URL fragment
main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
frame "sxg_iframe" - didReceiveTitle:
frame "sxg_iframe" - didStartProvisionalLoadForFrame
frame "sxg_iframe" - didFailProvisionalLoadWithError
This is a testharness.js-based test.
FAIL Navigating to a Signed Exchange should preserve URL fragment promise_test: Unhandled rejection with value: "timeout"
Harness: the test ran to completion.
main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Fallback redirect to another SignedHTTPExchange
main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
frame "sxg_iframe" - didReceiveTitle:
frame "sxg_iframe" - didStartProvisionalLoadForFrame
frame "sxg_iframe" - didFailProvisionalLoadWithError
This is a testharness.js-based test.
FAIL Fallback redirect to another SignedHTTPExchange promise_test: Unhandled rejection with value: "timeout"
Harness: the test ran to completion.
main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Nested SignedHTTPExchange
main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
frame "sxg_iframe" - didReceiveTitle:
frame "sxg_iframe" - didStartProvisionalLoadForFrame
frame "sxg_iframe" - didFailProvisionalLoadWithError
This is a testharness.js-based test.
FAIL Nested SignedHTTPExchange promise_test: Unhandled rejection with value: "timeout"
Harness: the test ran to completion.
main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Fallback redirect of SignedHTTPExchange should preserve URL fragment
main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
frame "sxg_iframe" - didReceiveTitle:
frame "sxg_iframe" - didStartProvisionalLoadForFrame
frame "sxg_iframe" - didFailProvisionalLoadWithError
This is a testharness.js-based test.
FAIL Fallback redirect of SignedHTTPExchange should preserve URL fragment promise_test: Unhandled rejection with value: "timeout"
Harness: the test ran to completion.
main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Loading SignedHTTPExchange which validity URL is different origin from request URL must fail
main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
frame "sxg_iframe" - didReceiveTitle:
frame "sxg_iframe" - didStartProvisionalLoadForFrame
frame "sxg_iframe" - didFailProvisionalLoadWithError
This is a testharness.js-based test.
FAIL Loading SignedHTTPExchange which validity URL is different origin from request URL must fail promise_test: Unhandled rejection with value: "timeout"
Harness: the test ran to completion.
main frame - didStartProvisionalLoadForFrame
main frame - didCommitLoadForFrame
main frame - didReceiveTitle: Navigating to a Signed Exchange should preserve URL fragment
main frame - didFinishDocumentLoadForFrame
main frame - didHandleOnloadEventsForFrame
main frame - didFinishLoadForFrame
frame "sxg_iframe" - didReceiveTitle:
frame "sxg_iframe" - didStartProvisionalLoadForFrame
frame "sxg_iframe" - didFailProvisionalLoadWithError
This is a testharness.js-based test.
FAIL Navigating to a Signed Exchange should preserve URL fragment promise_test: Unhandled rejection with value: "timeout"
Harness: the test ran to completion.
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment