Skip to content

Commit

Permalink
Remove urn:uuid: URL support in Subresource WebBundles
Browse files Browse the repository at this point in the history
We are removing old APIs of Subresource Loading with WebBundles. This
patch removes "urn:uuid:" URL support for WebBundles.

Bug: 1257045,1309383
Change-Id: Iadb8f43331ef885fc4a333b27358672293274144
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3560841
Reviewed-by: Hayato Ito <hayato@chromium.org>
Reviewed-by: Takashi Toyoshima <toyoshim@chromium.org>
Reviewed-by: Arthur Sonzogni <arthursonzogni@chromium.org>
Commit-Queue: Kunihiko Sakamoto <ksakamoto@chromium.org>
Cr-Commit-Position: refs/heads/main@{#988825}
  • Loading branch information
irori authored and chromium-wpt-export-bot committed Apr 5, 2022
1 parent 117f23c commit c507b3c
Show file tree
Hide file tree
Showing 14 changed files with 40 additions and 216 deletions.
6 changes: 3 additions & 3 deletions web-bundle/resources/corp.har
Expand Up @@ -69,7 +69,7 @@
{
"request": {
"method": "GET",
"url": "urn:uuid:5eafff38-e0a0-4661-bde0-434255aa9d93",
"url": "uuid-in-package:5eafff38-e0a0-4661-bde0-434255aa9d93",
"headers": []
},
"response": {
Expand All @@ -88,7 +88,7 @@
{
"request": {
"method": "GET",
"url": "urn:uuid:7e13b47a-8b91-4a0e-997c-993a5e2f3a34",
"url": "uuid-in-package:7e13b47a-8b91-4a0e-997c-993a5e2f3a34",
"headers": []
},
"response": {
Expand All @@ -111,7 +111,7 @@
{
"request": {
"method": "GET",
"url": "urn:uuid:86d5b696-8867-4454-8b07-51239a0817f7",
"url": "uuid-in-package:86d5b696-8867-4454-8b07-51239a0817f7",
"headers": []
},
"response": {
Expand Down
11 changes: 0 additions & 11 deletions web-bundle/resources/generate-test-wbns.sh
Expand Up @@ -65,12 +65,6 @@ gen-bundle \
-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-b1.wbn

gen-bundle \
-version b1 \
-har cross-origin.har \
Expand Down Expand Up @@ -137,11 +131,6 @@ gen-bundle \
-dir path-restriction/ \
-o wbn/path-restriction.wbn

gen-bundle \
-version b2 \
-har urn-uuid.har \
-o wbn/urn-uuid.wbn

gen-bundle \
-version b2 \
-har cross-origin.har \
Expand Down
44 changes: 0 additions & 44 deletions web-bundle/resources/urn-uuid.har

This file was deleted.

Binary file modified web-bundle/resources/wbn/cors/corp.wbn
Binary file not shown.
Binary file removed web-bundle/resources/wbn/urn-uuid-b1.wbn
Binary file not shown.
Binary file removed web-bundle/resources/wbn/urn-uuid.wbn
Binary file not shown.
Expand Up @@ -8,25 +8,20 @@
http-equiv="Content-Security-Policy"
content="
script-src
https://web-platform.test:8444/web-bundle/resources/wbn/urn-uuid.wbn
https://web-platform.test:8444/web-bundle/resources/wbn/uuid-in-package.wbn
https://web-platform.test:8444/resources/testharness.js
https://web-platform.test:8444/resources/testharnessreport.js
'unsafe-inline';
img-src
https://web-platform.test:8444/web-bundle/resources/wbn/pass.png;
frame-src
https://web-platform.test:8444/web-bundle/resources/wbn/urn-uuid.wbn
https://web-platform.test:8444/web-bundle/resources/wbn/uuid-in-package.wbn"
>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<body>
<link rel="webbundle" href="../resources/wbn/subresource.wbn"
resources="https://web-platform.test:8444/web-bundle/resources/wbn/pass.png" />
<link rel="webbundle" href="../resources/wbn/urn-uuid.wbn"
resources="urn:uuid:020111b3-437a-4c5c-ae07-adb6bbffb720
urn:uuid:429fcc4e-0696-4bad-b099-ee9175f023ae" />
<link rel="webbundle" href="../resources/wbn/uuid-in-package.wbn"
resources="uuid-in-package:020111b3-437a-4c5c-ae07-adb6bbffb720
uuid-in-package:429fcc4e-0696-4bad-b099-ee9175f023ae" />
Expand All @@ -42,18 +37,6 @@
}, 'URL matching of CSP should be done based on the subresource URL ' +
'when the subresource URL is HTTPS URL.');

promise_test(async () => {
const result = await new Promise((resolve) => {
// This function will be called from the script.
window.report_result = resolve;
const script = document.createElement('script');
script.src = 'urn:uuid:020111b3-437a-4c5c-ae07-adb6bbffb720';
document.body.appendChild(script);
});
assert_equals(result, 'OK');
}, 'URL matching of script-src CSP should be done based on the bundle URL ' +
'when the subresource URL is urn:uuid URL.');

promise_test(async () => {
const result = await new Promise((resolve) => {
// This function will be called from the script.
Expand All @@ -66,21 +49,6 @@
}, 'URL matching of script-src CSP should be done based on the bundle URL ' +
'when the subresource URL is uuid-in-package: URL.');

promise_test(async () => {
const frame_url = 'urn:uuid:429fcc4e-0696-4bad-b099-ee9175f023ae';
const iframe = document.createElement('iframe');
iframe.src = frame_url;
const load_promise = new Promise((resolve) => {
iframe.addEventListener('load', resolve);
});
document.body.appendChild(iframe);
await load_promise;
assert_equals(
await evalInIframe(iframe, 'location.href'),
frame_url);
}, 'URL matching of frame-src CSP should be done based on the bundle URL ' +
'when the frame URL is urn:uuid URL.');

promise_test(async () => {
const frame_url = 'uuid-in-package:429fcc4e-0696-4bad-b099-ee9175f023ae';
const iframe = document.createElement('iframe');
Expand Down
Expand Up @@ -24,14 +24,10 @@
<body>
<link rel="webbundle" href="../resources/wbn/subresource.wbn"
resources="https://web-platform.test:8444/web-bundle/resources/wbn/fail.png" />
<link rel="webbundle" href="../resources/wbn/urn-uuid.wbn"
resources="urn:uuid:020111b3-437a-4c5c-ae07-adb6bbffb720
urn:uuid:429fcc4e-0696-4bad-b099-ee9175f023ae" />
<link rel="webbundle" href="../resources/wbn/uuid-in-package.wbn"
resources="uuid-in-package:020111b3-437a-4c5c-ae07-adb6bbffb720
uuid-in-package:429fcc4e-0696-4bad-b099-ee9175f023ae" />
<script>
const urn_bundle_url = 'https://web-platform.test:8444/web-bundle/resources/wbn/urn-uuid.wbn';
const uuid_bundle_url = 'https://web-platform.test:8444/web-bundle/resources/wbn/uuid-in-package.wbn';

function expect_violation() {
Expand Down Expand Up @@ -76,10 +72,6 @@
'not on the bundle URL, when the subresource URL is HTTPS URL.');

const testCases = [
{
prefix: 'urn:uuid:',
bundle_url: urn_bundle_url
},
{
prefix: 'uuid-in-package:',
bundle_url: uuid_bundle_url
Expand Down Expand Up @@ -137,22 +129,18 @@
const reports = await (await fetch(retrieve_report_url)).json();
sortReportsByEffectiveDirective(reports);

assert_equals(reports.length, 5, "Report count.");
assert_equals(reports.length, 3, "Report count.");

assert_equals(reports[0].body.blockedURL, urn_bundle_url);
assert_equals(reports[0].body.blockedURL, uuid_bundle_url);
assert_equals(reports[0].body.effectiveDirective, 'frame-src');
assert_equals(reports[1].body.blockedURL, uuid_bundle_url);
assert_equals(reports[1].body.effectiveDirective, 'frame-src');

assert_equals(
reports[2].body.blockedURL,
reports[1].body.blockedURL,
'https://web-platform.test:8444/web-bundle/resources/wbn/fail.png');
assert_equals(reports[2].body.effectiveDirective, 'img-src',);
assert_equals(reports[1].body.effectiveDirective, 'img-src',);

assert_equals(reports[3].body.blockedURL, urn_bundle_url);
assert_equals(reports[3].body.effectiveDirective, 'script-src-elem');
assert_equals(reports[4].body.blockedURL, uuid_bundle_url);
assert_equals(reports[4].body.effectiveDirective, 'script-src-elem');
assert_equals(reports[2].body.blockedURL, uuid_bundle_url);
assert_equals(reports[2].body.effectiveDirective, 'script-src-elem');
}, 'Check the CSP violation reports.');
</script>
</body>
18 changes: 9 additions & 9 deletions web-bundle/subresource-loading/script-coep.https.tentative.html
Expand Up @@ -33,9 +33,9 @@
"https://www1.web-platform.test:8444/web-bundle/resources/wbn/cors/no-corp.js",
"https://www1.web-platform.test:8444/web-bundle/resources/wbn/cors/corp-same-origin.js",
"https://www1.web-platform.test:8444/web-bundle/resources/wbn/cors/corp-cross-origin.js",
"urn:uuid:5eafff38-e0a0-4661-bde0-434255aa9d93",
"urn:uuid:7e13b47a-8b91-4a0e-997c-993a5e2f3a34",
"urn:uuid:86d5b696-8867-4454-8b07-51239a0817f7"
"uuid-in-package:5eafff38-e0a0-4661-bde0-434255aa9d93",
"uuid-in-package:7e13b47a-8b91-4a0e-997c-993a5e2f3a34",
"uuid-in-package:86d5b696-8867-4454-8b07-51239a0817f7"
]
}
</script>
Expand Down Expand Up @@ -64,11 +64,11 @@

const prefix =
"https://www1.web-platform.test:8444/web-bundle/resources/wbn/cors/";
const no_corp_url = "urn:uuid:5eafff38-e0a0-4661-bde0-434255aa9d93";
const no_corp_url = "uuid-in-package:5eafff38-e0a0-4661-bde0-434255aa9d93";
const corp_same_origin_url =
"urn:uuid:7e13b47a-8b91-4a0e-997c-993a5e2f3a34";
"uuid-in-package:7e13b47a-8b91-4a0e-997c-993a5e2f3a34";
const corp_cross_origin_url =
"urn:uuid:86d5b696-8867-4454-8b07-51239a0817f7";
"uuid-in-package:86d5b696-8867-4454-8b07-51239a0817f7";

promise_test(async () => {
const report = await expectCOEPReport(async () => {
Expand Down Expand Up @@ -99,7 +99,7 @@
assert_equals(report.body.type, "corp");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.destination, "iframe");
}, "Urn:uuid iframe without Cross-Origin-Resource-Policy: header should be blocked and generate a report.");
}, "uuid-in-package iframe without Cross-Origin-Resource-Policy: header should be blocked and generate a report.");

promise_test(async () => {
const report = await expectCOEPReport(async () => {
Expand All @@ -112,7 +112,7 @@
assert_equals(report.body.type, "corp");
assert_equals(report.body.disposition, "enforce");
assert_equals(report.body.destination, "iframe");
}, "Urn:uuid iframe with Cross-Origin-Resource-Policy: same-origin should be blocked and generate a report.");
}, "uuid-in-package iframe with Cross-Origin-Resource-Policy: same-origin should be blocked and generate a report.");

promise_test(async () => {
const iframe = document.createElement("iframe");
Expand All @@ -122,6 +122,6 @@
await evalInIframe(iframe, "location.href"),
corp_cross_origin_url
);
}, "Urn:uuid iframe with Cross-Origin-Resource-Policy: cross-origin should not be blocked.");
}, "uuid-in-package iframe with Cross-Origin-Resource-Policy: cross-origin should not be blocked.");
</script>
</body>
14 changes: 7 additions & 7 deletions web-bundle/subresource-loading/script-corp.https.tentative.html
Expand Up @@ -33,9 +33,9 @@
"https://www1.web-platform.test:8444/web-bundle/resources/wbn/cors/no-corp.js",
"https://www1.web-platform.test:8444/web-bundle/resources/wbn/cors/corp-same-origin.js",
"https://www1.web-platform.test:8444/web-bundle/resources/wbn/cors/corp-cross-origin.js",
"urn:uuid:5eafff38-e0a0-4661-bde0-434255aa9d93",
"urn:uuid:7e13b47a-8b91-4a0e-997c-993a5e2f3a34",
"urn:uuid:86d5b696-8867-4454-8b07-51239a0817f7"
"uuid-in-package:5eafff38-e0a0-4661-bde0-434255aa9d93",
"uuid-in-package:7e13b47a-8b91-4a0e-997c-993a5e2f3a34",
"uuid-in-package:86d5b696-8867-4454-8b07-51239a0817f7"
]
}
</script>
Expand All @@ -53,15 +53,15 @@
}, "Subresource loading from WebBundles should respect Cross-Origin-Resource-Policy header.");

promise_test(async () => {
const no_corp_url = "urn:uuid:5eafff38-e0a0-4661-bde0-434255aa9d93";
const no_corp_url = "uuid-in-package:5eafff38-e0a0-4661-bde0-434255aa9d93";
const corp_same_origin_url =
"urn:uuid:7e13b47a-8b91-4a0e-997c-993a5e2f3a34";
"uuid-in-package:7e13b47a-8b91-4a0e-997c-993a5e2f3a34";
const corp_cross_origin_url =
"urn:uuid:86d5b696-8867-4454-8b07-51239a0817f7";
"uuid-in-package:86d5b696-8867-4454-8b07-51239a0817f7";
await iframeLocationTest(no_corp_url);
await iframeLocationTest(corp_same_origin_url);
await iframeLocationTest(corp_cross_origin_url);
}, "Urn:uuid iframes should not be blocked regardless of the Cross-Origin-Resource-Policy header, if Cross-Origin-Embedder-Policy is not set.");
}, "uuid-in-package iframes should not be blocked regardless of the Cross-Origin-Resource-Policy header, if Cross-Origin-Embedder-Policy is not set.");

async function iframeLocationTest(url) {
const iframe = document.createElement("iframe");
Expand Down
@@ -1,6 +1,6 @@
<!DOCTYPE html>
<meta charset="utf-8" />
<title>Resource timing entries present for urn:uuid resources</title>
<title>Resource timing entries present for uuid-in-package resources</title>
<script src="/resources/testharness.js"></script>
<script src="/resources/testharnessreport.js"></script>
<script src="../resources/test-helpers.js"></script>
Expand All @@ -11,10 +11,10 @@
});

promise_test(async (t) => {
const frame_id = "urn:uuid:429fcc4e-0696-4bad-b099-ee9175f023ae";
const script_id = "urn:uuid:020111b3-437a-4c5c-ae07-adb6bbffb720";
const frame_id = "uuid-in-package:429fcc4e-0696-4bad-b099-ee9175f023ae";
const script_id = "uuid-in-package:020111b3-437a-4c5c-ae07-adb6bbffb720";
const element = createWebBundleElement(
"../resources/wbn/urn-uuid.wbn",
"../resources/wbn/uuid-in-package.wbn",
/*resources=*/ [frame_id, script_id]
);
document.body.appendChild(element);
Expand Down Expand Up @@ -50,6 +50,6 @@
script.src = script_id;
document.body.appendChild(script);
return promise;
}, "Each urn:uuid resource should have exactly 1 ResourceTiming entry.");
}, "Each uuid-in-package resource should have exactly 1 ResourceTiming entry.");
</script>
</body>
Expand Up @@ -73,11 +73,11 @@
assert_array_equals(await getRequestedUrls(worker), [iframe_url]);

// Add a web bundle element in the service worker controlled iframe.
const frame_id = "urn:uuid:429fcc4e-0696-4bad-b099-ee9175f023ae";
const script_id = "urn:uuid:020111b3-437a-4c5c-ae07-adb6bbffb720";
const frame_id = "uuid-in-package:429fcc4e-0696-4bad-b099-ee9175f023ae";
const script_id = "uuid-in-package:020111b3-437a-4c5c-ae07-adb6bbffb720";

const element = createWebBundleElement(
"../../resources/wbn/urn-uuid.wbn",
"../../resources/wbn/uuid-in-package.wbn",
/*resources=*/ [frame_id, script_id]
);

Expand All @@ -91,8 +91,8 @@
// The web bundle request should not be intercepted by the service worker.
assert_array_equals(await getRequestedUrls(worker), []);

// Add an urn uuid URL script element in the service worker controlled
// iframe.
// Add a uuid-in-package URL script element in the service worker
// controlled iframe.
const result_promise = new Promise((resolve) => {
// window.report_result() method will be called by the injected script.
iframe.contentWindow.report_result = resolve;
Expand All @@ -105,7 +105,7 @@
// service worker.
assert_array_equals(await getRequestedUrls(worker), []);

// Add an urn uuid URL iframe element in the service worker controlled
// Add a uuid-in-package URL iframe element in the service worker controlled
// iframe.
const inner_iframe = iframe.contentDocument.createElement("iframe");
inner_iframe.src = frame_id;
Expand All @@ -120,7 +120,7 @@
// worker.
assert_array_equals(await getRequestedUrls(worker), []);

// Check if the urn uuid URL iframe element is loaded correctly.
// Check if the uuid-in-package URL iframe element is loaded correctly.
const message_promise = new Promise((resolve) => {
window.addEventListener(
"message",
Expand All @@ -130,7 +130,7 @@
{ once: true }
);
});
// location.href is evaluated in the urn uuid URL iframe element.
// location.href is evaluated in the uuid-in-package URL iframe element.
inner_iframe.contentWindow.postMessage("location.href", "*");
assert_equals(await message_promise, frame_id);
}, "Both Web Bundle request and Subresource fetch requests inside the Web " + "Bundle should skip the service worker.");
Expand Down

0 comments on commit c507b3c

Please sign in to comment.