Enable subframe navigation to urn:uuid resources in Web Bundles
This implements subframe loading with Web Bundles. Design doc:
https://docs.google.com/document/d/1_AqUBS4Gr45MPPtXGTUl7Q0DMIEw2zUeWO0zo6Sj0z4/edit#heading=h.aay60dv2vzua
blink::FrameLoader::StartNavigation attaches a WebBundleToken to the
request. It is propagated to the (new) web_bundle_token field of
mojom::BeginNavigationParams, and used to construct a navigation request
in NavigationURLLoaderImpl.
Created subframes have opaque-origins, and are hosted by a process for
the Bundle's origin. To achieve these, this CL:
- Adds |origin| field to content::UrlInfo
- For navigation to a urn: URL,
- SiteInstanceImpl::GetSiteForURLInternal() uses the Bundle's origin
- NavigationRequest::GetOriginForURLLoaderFactory() returns an opaque
origin derived from the bundle's origin
Bug: 1082020
Change-Id: I07e03cce9f7da7eb6fd9d4218cf31882585b8463
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2543726
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Reviewed-by: Aaron Colwell <acolwell@chromium.org>
Reviewed-by: Ćukasz Anforowicz <lukasza@chromium.org>
Reviewed-by: Alex Moshchuk <alexmos@chromium.org>
Reviewed-by: Kinuko Yasuda <kinuko@chromium.org>
Reviewed-by: Hayato Ito <hayato@chromium.org>
Cr-Commit-Position: refs/heads/master@{#849014}
diff --git a/web-bundle/resources/urn-uuid.har b/web-bundle/resources/urn-uuid.har
index e0cea36..d821b76 100644
--- a/web-bundle/resources/urn-uuid.har
+++ b/web-bundle/resources/urn-uuid.har
@@ -19,6 +19,25 @@
"text": "window.report_result('OK');"
}
}
+ },
+ {
+ "request": {
+ "method": "GET",
+ "url": "urn:uuid:429fcc4e-0696-4bad-b099-ee9175f023ae",
+ "headers": []
+ },
+ "response": {
+ "status": 200,
+ "headers": [
+ {
+ "name": "Content-type",
+ "value": "text/html"
+ }
+ ],
+ "content": {
+ "text": "<script> window.parent.postMessage('subframe loaded from WBN: location = ' + location.href, '*'); </script>"
+ }
+ }
}
]
}
diff --git a/web-bundle/resources/wbn/urn-uuid.wbn b/web-bundle/resources/wbn/urn-uuid.wbn
index a4bd3ef..45db6fe 100644
--- a/web-bundle/resources/wbn/urn-uuid.wbn
+++ b/web-bundle/resources/wbn/urn-uuid.wbn
Binary files differ
diff --git a/web-bundle/subresource-loading/subframe-from-web-bundle.tentative.html b/web-bundle/subresource-loading/subframe-from-web-bundle.tentative.html
new file mode 100644
index 0000000..1e5cdd6
--- /dev/null
+++ b/web-bundle/subresource-loading/subframe-from-web-bundle.tentative.html
@@ -0,0 +1,35 @@
+<!DOCTYPE html>
+<title>Subframe loading from Web Bundles</title>
+<link
+ rel="help"
+ href="https://github.com/WICG/webpackage/blob/master/explainers/subresource-loading.md"
+/>
+<script src="/resources/testharness.js"></script>
+<script src="/resources/testharnessreport.js"></script>
+<body>
+<script>
+
+promise_test(async () => {
+ const frame_url = 'urn:uuid:429fcc4e-0696-4bad-b099-ee9175f023ae';
+ const link = document.createElement('link');
+ link.rel = 'webbundle';
+ link.href = '../resources/wbn/urn-uuid.wbn';
+ link.resources = frame_url;
+ document.body.appendChild(link);
+ const message_promisse = new Promise((resolve) => {
+ window.addEventListener('message', (e) => {
+ resolve(e.data);
+ });
+ });
+ const iframe = document.createElement('iframe');
+ iframe.src = frame_url;
+ document.body.appendChild(iframe);
+ assert_equals(
+ await message_promisse,
+ 'subframe loaded from WBN: location = ' + frame_url);
+ document.body.removeChild(link);
+ document.body.removeChild(iframe);
+}, "Subframe load from Web Bundle");
+
+</script>
+</body>