Commit 6f7e36e4 authored by Hayato Ito's avatar Hayato Ito Committed by Chromium LUCI CQ

Add more tests for cross-origin WebBundles

A follow-up to https://crrev.com/c/2617167.

Note that the test fails in the current implementation.
See the https://crbug.com/1168449 for details.
The test is now marked as Timeout.

Bug: 1149816, 1168449

Change-Id: I2552f64ea12ac5030c9740f30a94edef2760986c
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2639337Reviewed-by: default avatarTsuyoshi Horo <horo@chromium.org>
Commit-Queue: Hayato Ito <hayato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#845498}
parent 633872e8
...@@ -5806,6 +5806,9 @@ crbug.com/1130020 virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/ ...@@ -5806,6 +5806,9 @@ crbug.com/1130020 virtual/threaded-prefer-compositing/fast/scrolling/scrollbars/
crbug.com/1159502 http/tests/devtools/service-workers/service-workers-view.js [ Pass Failure ] crbug.com/1159502 http/tests/devtools/service-workers/service-workers-view.js [ Pass Failure ]
crbug.com/1159502 http/tests/devtools/service-workers/service-workers-redundant.js [ Pass Failure ] crbug.com/1159502 http/tests/devtools/service-workers/service-workers-redundant.js [ Pass Failure ]
# WebBundle tests which fail
crbug.com/1168449 external/wpt/web-bundle/subresource-loading/subresource-loading-cross-origin.tentative.html [ Pass Timeout ]
# Sheriff 2020-11-16 # Sheriff 2020-11-16
crbug.com/1149734 http/tests/devtools/sources/debugger-ui/debugger-inline-values-frames.js [ Pass Failure Timeout ] crbug.com/1149734 http/tests/devtools/sources/debugger-ui/debugger-inline-values-frames.js [ Pass Failure Timeout ]
crbug.com/1149734 http/tests/devtools/sources/debugger-ui/reveal-execution-line.js [ Pass Failure Timeout ] crbug.com/1149734 http/tests/devtools/sources/debugger-ui/reveal-execution-line.js [ Pass Failure Timeout ]
......
{
"log": {
"entries": [
{
"request": {
"method": "GET",
"url": "https://web-platform.test:8444/web-bundle/resources/wbn/no-cors/resource.cors.json",
"headers": []
},
"response": {
"status": 200,
"headers": [
{
"name": "Content-type",
"value": "application/json"
},
{
"name": "Access-Control-Allow-Origin",
"value": "*"
}
],
"content": {
"text": "{ cors: 1 }"
}
}
},
{
"request": {
"method": "GET",
"url": "https://web-platform.test:8444/web-bundle/resources/wbn/no-cors/resource.no-cors.json",
"headers": []
},
"response": {
"status": 200,
"headers": [
{
"name": "Content-type",
"value": "application/json"
}
],
"content": {
"text": "{ no_cors: 1 }"
}
}
}
]
}
}
...@@ -76,3 +76,9 @@ gen-bundle \ ...@@ -76,3 +76,9 @@ gen-bundle \
-har cross-origin.har \ -har cross-origin.har \
-primaryURL $wpt_test_https_origin/web-bundle/resources/wbn/cors/resource.cors.json \ -primaryURL $wpt_test_https_origin/web-bundle/resources/wbn/cors/resource.cors.json \
-o wbn/cors/cross-origin.wbn -o wbn/cors/cross-origin.wbn
gen-bundle \
-version b1 \
-har cross-origin-no-cors.har \
-primaryURL $wpt_test_https_origin/web-bundle/resources/wbn/no-cors/resource.cors.json \
-o wbn/no-cors/cross-origin.wbn
...@@ -8,17 +8,17 @@ ...@@ -8,17 +8,17 @@
<script src="/resources/testharnessreport.js"></script> <script src="/resources/testharnessreport.js"></script>
<body> <body>
<!-- <!--
This wpt should run on an origin which is different than https://web-platform.test:8444/, This wpt should run on an origin different from https://web-platform.test:8444/,
from where cross-orign WebBundles are served. from where cross-orign WebBundles are served.
This test uses the two cross-origin WebBundles: This test uses the two cross-origin WebBundles:
1. https://web-platform.test:8444/web-bundle/resources/wbn/cors/cross-origin.wbn, 1. https://web-platform.test:8444/web-bundle/resources/wbn/cors/cross-origin.wbn,
which is served with an Access-Control-Allow-Origin response header. which is served with an Access-Control-Allow-Origin response header.
2. http://web-platform.test:8444/web-bundle/resources/wbn/subreource.wbn, 2. http://web-platform.test:8444/web-bundle/resources/wbn/no-cors/cross-origin.wbn,
which is served *without* an Access-Control-Allow-Origin response header. which is served *without* an Access-Control-Allow-Origin response header.
`cross-origin.wbn` includes two subresources: Each `cross-origin.wbn` includes two subresources:
a. `resource.cors.json`, which includes an Access-Control-Allow-Origin response header. a. `resource.cors.json`, which includes an Access-Control-Allow-Origin response header.
b. `resource.no-cors.json`, which doesn't include an Access-Control-Allow-Origin response header. b. `resource.no-cors.json`, which doesn't include an Access-Control-Allow-Origin response header.
--> -->
...@@ -34,6 +34,8 @@ ...@@ -34,6 +34,8 @@
"https://web-platform.test:8444/web-bundle/resources/wbn/cors/resource.cors.json" "https://web-platform.test:8444/web-bundle/resources/wbn/cors/resource.cors.json"
); );
assert_true(response.ok); assert_true(response.ok);
const text = await response.text();
assert_equals(text, "{ cors: 1 }");
}, "A subresource which includes an Access-Control-Allow-Origin response header can be fetched"); }, "A subresource which includes an Access-Control-Allow-Origin response header can be fetched");
promise_test(async (t) => { promise_test(async (t) => {
...@@ -46,21 +48,46 @@ ...@@ -46,21 +48,46 @@
); );
}, "A subresource which does not include an Access-Control-Allow-Origin response header can not be fetched"); }, "A subresource which does not include an Access-Control-Allow-Origin response header can not be fetched");
promise_test(async () => { promise_test(async (t) => {
return addLinkAndWaitForError( const prefix =
"http://web-platform.test:8444/web-bundle/resources/wbn/subreource.wbn" "http://web-platform.test:8444/web-bundle/resources/wbn/no-cors/";
); const resources = [
}, "A cross-origin WebBundle which does not include an Access-Control-Allow-Origin response header should fire an error event on load"); prefix + "resource.cors.json",
prefix + "resource.no-cors.json",
]
// Should fire an error event on loading webbundle.
await addLinkAndWaitForError(prefix + "cross-origin.wbn", resources);
// A fetch should fail for any subresource specified in resources attribute.
for (const url of resources) {
await fetchAndWaitForReject(url);
}
}, "A cross-origin WebBundle which does not include an Access-Control-Allow-Origin response header should fire an error event on load, and a fetch should fail for any subresource");
function addLinkAndWaitForError(url) { function addLinkAndWaitForError(url, resources) {
return new Promise((resolve, reject) => { return new Promise((resolve, reject) => {
const link = document.createElement("link"); const link = document.createElement("link");
link.rel = "webbundle"; link.rel = "webbundle";
link.href = url; link.href = url;
for (const resource of resources) {
link.resources.add(resource);
}
link.onload = reject; link.onload = reject;
link.onerror = () => resolve(link); link.onerror = () => resolve(link);
document.body.appendChild(link); document.body.appendChild(link);
}); });
} }
function fetchAndWaitForReject(url) {
return new Promise((resolve, reject) => {
fetch(url)
.then(() => {
reject();
})
.catch(() => {
resolve();
});
});
}
</script> </script>
</body> </body>
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