Commit 8f84e3b5 authored by Kunihiko Sakamoto's avatar Kunihiko Sakamoto Committed by Chromium LUCI CQ

Subresource WebBundle: Support loading urn:uuid resources from WebBundle

This allows the urn: scheme in WebBundles' inner URLs, in addition to
http and https.

Bug: 1082020
Change-Id: I5582444e6d4f6ab29b83045a3d37a13f078071db
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2578300Reviewed-by: default avatarHayato Ito <hayato@chromium.org>
Reviewed-by: default avatarKinuko Yasuda <kinuko@chromium.org>
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Cr-Commit-Position: refs/heads/master@{#834605}
parent a3984b7e
......@@ -278,10 +278,10 @@ GURL ParseExchangeURL(base::StringPiece str) {
if (url.has_ref() || url.has_username() || url.has_password())
return GURL();
// For now, we allow only http: and https: schemes in Web Bundle URLs.
// For now, we allow only http:, https: and urn: schemes in Web Bundle URLs.
// TODO(crbug.com/966753): Revisit this once
// https://github.com/WICG/webpackage/issues/468 is resolved.
if (!url.SchemeIsHTTPOrHTTPS())
if (!url.SchemeIsHTTPOrHTTPS() && !url.SchemeIs("urn"))
return GURL();
return url;
......
......@@ -211,6 +211,8 @@ bool LinkWebBundle::CanHandleRequest(const KURL& url) const {
return false;
if (!owner_ || !owner_->ValidResourceUrls().Contains(url))
return false;
if (url.Protocol() == "urn")
return true;
DCHECK(bundle_loader_);
if (!bundle_loader_->GetSecurityOrigin()->IsSameOriginWith(
SecurityOrigin::Create(url).get())) {
......@@ -255,10 +257,10 @@ KURL LinkWebBundle::ParseResourceUrl(const AtomicString& str) {
!url.Pass().IsEmpty())
return KURL();
// For now, we allow only http: and https: schemes in Web Bundle URLs.
// For now, we allow only http:, https: and urn: schemes in Web Bundle URLs.
// TODO(crbug.com/966753): Revisit this once
// https://github.com/WICG/webpackage/issues/468 is resolved.
if (!url.ProtocolIsInHTTPFamily())
if (!url.ProtocolIsInHTTPFamily() && !url.ProtocolIs("urn"))
return KURL();
return url;
......
......@@ -64,3 +64,9 @@ gen-bundle \
-primaryURL $wpt_test_http_origin/web-bundle/resources/wbn/resource.js \
-dir nested/ \
-o wbn/nested-main.wbn
gen-bundle \
-version b1 \
-har urn-uuid.har \
-primaryURL urn:uuid:020111b3-437a-4c5c-ae07-adb6bbffb720 \
-o wbn/urn-uuid.wbn
{
"log": {
"entries": [
{
"request": {
"method": "GET",
"url": "urn:uuid:020111b3-437a-4c5c-ae07-adb6bbffb720",
"headers": []
},
"response": {
"status": 200,
"headers": [
{
"name": "Content-type",
"value": "application/javascript"
}
],
"content": {
"text": "window.report_result('OK');"
}
}
}
]
}
}
......@@ -100,6 +100,16 @@
assert_equals(module.result, 'resource1 from network');
}, 'Subresource URL must be same-origin with bundle URL');
promise_test(async () => {
const url = 'urn:uuid:020111b3-437a-4c5c-ae07-adb6bbffb720';
const link = document.createElement('link');
link.rel = 'webbundle';
link.href = '../resources/wbn/urn-uuid.wbn';
link.resources = url;
document.body.appendChild(link);
assert_equals(await loadScriptAndWaitReport(url), 'OK');
}, 'Subresource loading with urn:uuid: URL');
promise_test(async () => {
const wbn_url = 'http://web-platform.test:8001/web-bundle/resources/wbn/subresource.wbn?test-resources-update';
const resource_url = 'http://web-platform.test:8001/web-bundle/resources/wbn/submodule.js';
......
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