зеркало из https://github.com/mozilla/gecko-dev.git
Bug 1732047 [wpt PR 30893] - Add WPT tests for <script type=webbundle>, a=testonly
Automatic update from web-platform-tests Add WPT tests for <script type=webbundle> This CL refactors some WPT tests for <link rel=webbundle>, and introduces WPT tests for <script type=webbundle> by extracting common codes into -test.js files. Bug: 1245166 Change-Id: I75212f0b7f13f7be13ed8990551c6264ad6f7df8 Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/3167916 Reviewed-by: Hayato Ito <hayato@chromium.org> Reviewed-by: Kunihiko Sakamoto <ksakamoto@chromium.org> Commit-Queue: Tsuyoshi Horo <horo@chromium.org> Cr-Commit-Position: refs/heads/main@{#923295} -- wpt-commits: 2e52f4bc72cd115f9f5409275803436a12bc7ac2 wpt-pr: 30893
This commit is contained in:
Родитель
065dcb4204
Коммит
7afe0d9dc1
|
@ -2,16 +2,16 @@
|
||||||
|
|
||||||
function addElementAndWaitForLoad(element) {
|
function addElementAndWaitForLoad(element) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
element.onload = resolve;
|
element.onload = () => resolve(element);
|
||||||
element.onerror = reject;
|
element.onerror = () => reject(element);
|
||||||
document.body.appendChild(element);
|
document.body.appendChild(element);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
function addElementAndWaitForError(element) {
|
function addElementAndWaitForError(element) {
|
||||||
return new Promise((resolve, reject) => {
|
return new Promise((resolve, reject) => {
|
||||||
element.onload = reject;
|
element.onload = () => reject(element);
|
||||||
element.onerror = resolve;
|
element.onerror = () => resolve(element);
|
||||||
document.body.appendChild(element);
|
document.body.appendChild(element);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
@ -89,3 +89,51 @@ function addScriptAndWaitForError(url) {
|
||||||
document.body.appendChild(script);
|
document.body.appendChild(script);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Currnetly Chrome supports two element types for Subresource Web Bundles
|
||||||
|
// feature, <link rel=webbundle> and <script type=webbundle>.
|
||||||
|
// In order to use the same test js file for the two types, we use
|
||||||
|
// window.TEST_WEB_BUNDLE_ELEMENT_TYPE. When 'link' is set,
|
||||||
|
// createWebBundleElement() will create a <link rel=webbundle> element, and when
|
||||||
|
// 'script' is set, createWebBundleElement() will create a <script
|
||||||
|
// rel=webbundle> element.
|
||||||
|
function isTestBundleElementTypeSet() {
|
||||||
|
return (window.TEST_WEB_BUNDLE_ELEMENT_TYPE == 'link') ||
|
||||||
|
(window.TEST_WEB_BUNDLE_ELEMENT_TYPE == 'script');
|
||||||
|
}
|
||||||
|
|
||||||
|
function createWebBundleElement(url, resources, options) {
|
||||||
|
if (!isTestBundleElementTypeSet()) {
|
||||||
|
throw new Error(
|
||||||
|
'window.TEST_WEB_BUNDLE_ELEMENT_TYPE is not correctly set: ' +
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE);
|
||||||
|
}
|
||||||
|
if (window.TEST_WEB_BUNDLE_ELEMENT_TYPE == 'link') {
|
||||||
|
const link = document.createElement("link");
|
||||||
|
link.rel = "webbundle";
|
||||||
|
link.href = url;
|
||||||
|
if (options && options.crossOrigin) {
|
||||||
|
link.crossOrigin = crossOrigin;
|
||||||
|
}
|
||||||
|
for (const resource of resources) {
|
||||||
|
link.resources.add(resource);
|
||||||
|
}
|
||||||
|
return link;
|
||||||
|
}
|
||||||
|
const script = document.createElement("script");
|
||||||
|
script.type = "webbundle";
|
||||||
|
script.textContent =
|
||||||
|
JSON.stringify({"source": url, "resources": resources});
|
||||||
|
return script;
|
||||||
|
}
|
||||||
|
|
||||||
|
function addWebBundleElementAndWaitForLoad(url, resources, options) {
|
||||||
|
const element = createWebBundleElement(url, resources, options);
|
||||||
|
return addElementAndWaitForLoad(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
function addWebBundleElementAndWaitForError(url, resources, options) {
|
||||||
|
const element = createWebBundleElement(url, resources, options);
|
||||||
|
return addElementAndWaitForError(element);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Accept: request header in webbundle requests</title>
|
||||||
|
<link
|
||||||
|
rel="help"
|
||||||
|
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
||||||
|
/>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/accept-header-test.js"></script>
|
||||||
|
</body>
|
|
@ -1,21 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<title>Accept: request header in webbundle requests</title>
|
|
||||||
<link
|
|
||||||
rel="help"
|
|
||||||
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
|
||||||
/>
|
|
||||||
<script src="/resources/testharness.js"></script>
|
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
|
||||||
<script src="../resources/test-helpers.js"></script>
|
|
||||||
<body>
|
|
||||||
<script>
|
|
||||||
promise_test(async () => {
|
|
||||||
const link = document.createElement("link");
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = "../resources/check-accept-header-and-return-bundle.py";
|
|
||||||
await addElementAndWaitForLoad(link);
|
|
||||||
link.remove();
|
|
||||||
}, '"Accept:" header in a request for a bundle should contain application/webbundle MIME type');
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
|
|
@ -1,22 +1,12 @@
|
||||||
<!DOCTYPE html>
|
<!DOCTYPE html>
|
||||||
<title>On-going subresource loading should fail immediately when a link element is removed</title>
|
<title>On-going subresource loading should fail immediately when the web bundle element is removed</title>
|
||||||
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
|
</script>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script src="resources/element-removal-test.js"></script>
|
||||||
promise_test(async () => {
|
|
||||||
const link = document.createElement("link");
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = "/xhr/resources/delay.py?ms=100000";
|
|
||||||
link.resources.add("https://web-platform.test:8444/xhr/resources/dummy");
|
|
||||||
document.body.appendChild(link);
|
|
||||||
const waitUntilFail = new Promise((resolve) => {
|
|
||||||
fetch("https://web-platform.test:8444/xhr/resources/dummy").then(() => {},
|
|
||||||
resolve);
|
|
||||||
});
|
|
||||||
document.body.removeChild(link);
|
|
||||||
await waitUntilFail;
|
|
||||||
}, "On-going subresource loading should fail immediately when a link element is removed.");
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -3,39 +3,13 @@
|
||||||
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
|
</script>
|
||||||
<body>
|
<body>
|
||||||
<link rel="webbundle" href="https://web-platform.test:8444/web-bundle/resources/wbn/nested-main.wbn"
|
<link rel="webbundle" href="https://web-platform.test:8444/web-bundle/resources/wbn/nested-main.wbn"
|
||||||
resources="https://web-platform.test:8444/web-bundle/resources/wbn/nested-sub.wbn" />
|
resources="https://web-platform.test:8444/web-bundle/resources/wbn/nested-sub.wbn" />
|
||||||
<script>
|
<script src="resources/nested-bundle-test.js"></script>
|
||||||
promise_test(async () => {
|
|
||||||
const response = await fetch(
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/wbn/nested-sub.wbn"
|
|
||||||
);
|
|
||||||
assert_true(response.ok);
|
|
||||||
}, "A nested bundle can be fetched");
|
|
||||||
|
|
||||||
promise_test(async () => {
|
|
||||||
await addLinkAndWaitForError(
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/wbn/nested-sub.wbn",
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/wbn/root.js"
|
|
||||||
);
|
|
||||||
const response = await fetch(
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/wbn/root.js"
|
|
||||||
);
|
|
||||||
assert_false(response.ok);
|
|
||||||
}, "Subresources in a nested bundle should not be loaded");
|
|
||||||
|
|
||||||
function addLinkAndWaitForError(url, resources) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const link = document.createElement("link");
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = url;
|
|
||||||
link.resources = resources;
|
|
||||||
link.onload = reject;
|
|
||||||
link.onerror = () => resolve();
|
|
||||||
document.body.appendChild(link);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Web Bundle fetching failed due to a network error</title>
|
||||||
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/network-error-test.sub.js"></script>
|
||||||
|
</body>
|
|
@ -1,31 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<title>Web Bundle fetching failed due to a network error</title>
|
|
||||||
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
|
||||||
<script src="/resources/testharness.js"></script>
|
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
|
||||||
<script src="../resources/test-helpers.js"></script>
|
|
||||||
|
|
||||||
<body>
|
|
||||||
<!--
|
|
||||||
This test uses a non-existing WebBundle from a non-existent host, which makes
|
|
||||||
Web Bundle fetching fail due to a network error. The intent of is to chech if
|
|
||||||
failing to fetch a WebBundle also makes subresource fetch requests fail.
|
|
||||||
-->
|
|
||||||
<script>
|
|
||||||
promise_test(async () => {
|
|
||||||
const prefix =
|
|
||||||
"https://{{hosts[][nonexistent]}}/";
|
|
||||||
const resources = [
|
|
||||||
prefix + "resource.js",
|
|
||||||
];
|
|
||||||
const link = await addLinkAndWaitForError(
|
|
||||||
prefix + "non-existing.wbn",
|
|
||||||
resources,
|
|
||||||
undefined
|
|
||||||
);
|
|
||||||
|
|
||||||
// Can not fetch a subresource because Web Bundle fetch failed.
|
|
||||||
await fetchAndWaitForReject(prefix + "resource.js");
|
|
||||||
}, "Subresource fetch requests for non-existing Web Bundle should fail.");
|
|
||||||
</script>
|
|
||||||
</body>
|
|
|
@ -5,29 +5,9 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="../resources/test-helpers.js"></script>
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
|
</script>
|
||||||
<body>
|
<body>
|
||||||
<!--
|
<script src="resources/not-found-test.js"></script>
|
||||||
This test uses a non-existing WebBundle,
|
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn/cors/non-existing.wbn.
|
|
||||||
|
|
||||||
The intent of this test is to check if failing to fetch a WebBundle due to not
|
|
||||||
found error also makes subresource fetch requests fail.
|
|
||||||
-->
|
|
||||||
<script>
|
|
||||||
promise_test(async () => {
|
|
||||||
const prefix =
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/wbn/";
|
|
||||||
const resources = [
|
|
||||||
prefix + "resource.js",
|
|
||||||
];
|
|
||||||
const link = await addLinkAndWaitForError(
|
|
||||||
prefix + "non-existing.wbn",
|
|
||||||
resources,
|
|
||||||
undefined
|
|
||||||
);
|
|
||||||
|
|
||||||
// Can not fetch a subresource because Web Bundle fetch failed.
|
|
||||||
await fetchAndWaitForReject(prefix + "resource.js");
|
|
||||||
}, "Subresource fetch requests for non-existing Web Bundle should fail.");
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -6,40 +6,17 @@
|
||||||
/>
|
/>
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<link
|
<link
|
||||||
rel="webbundle"
|
rel="webbundle"
|
||||||
href="../resources/wbn/path-restriction.wbn"
|
href="../resources/wbn/path-restriction.wbn"
|
||||||
resources="https://web-platform.test:8444/web-bundle/resources/wbn/resource.js
|
resources="/web-bundle/resources/wbn/resource.js
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn/sub/resource.js
|
/web-bundle/resources/wbn/sub/resource.js
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn-resource.js
|
/web-bundle/resources/wbn-resource.js
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn1/resource.js
|
/web-bundle/resources/wbn1/resource.js
|
||||||
https://web-platform.test:8444/web-bundle/resources/other/resource.js
|
/web-bundle/resources/other/resource.js
|
||||||
https://web-platform.test:8444/web-bundle/resources/resource.js"
|
/web-bundle/resources/resource.js"
|
||||||
/>
|
/>
|
||||||
<script>
|
<script src="resources/path-restriction-test.js"></script>
|
||||||
promise_test(async () => {
|
|
||||||
const resources = [
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/wbn/resource.js",
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/wbn/sub/resource.js",
|
|
||||||
];
|
|
||||||
for (const resource of resources) {
|
|
||||||
const response = await fetch(resource);
|
|
||||||
assert_true(response.ok, resource + " should be loaded");
|
|
||||||
}
|
|
||||||
}, "Subresources should be loaded.");
|
|
||||||
|
|
||||||
promise_test(async () => {
|
|
||||||
const resources = [
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/wbn-resource.js",
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/wbn1/resource.js",
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/other/resource.js",
|
|
||||||
"https://web-platform.test:8444/web-bundle/resources/resource.js",
|
|
||||||
];
|
|
||||||
for (const resource of resources) {
|
|
||||||
const response = await fetch(resource);
|
|
||||||
assert_false(response.ok, resource + " should not be loaded");
|
|
||||||
}
|
|
||||||
}, "Subresources should not be loaded due to path restriction.");
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -4,7 +4,6 @@
|
||||||
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="../resources/test-helpers.js"></script>
|
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<link
|
<link
|
||||||
|
@ -13,15 +12,5 @@
|
||||||
resources="resources/script.js"/>
|
resources="resources/script.js"/>
|
||||||
<script id="script" src="resources/script.js"></script>
|
<script id="script" src="resources/script.js"></script>
|
||||||
|
|
||||||
<script>
|
<script src="/web-bundle/subresource-loading/resources/relative-url-with-base-test.js"></script>
|
||||||
const onLoadPromise = new Promise((resolve) => {
|
|
||||||
window.addEventListener('load', resolve, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
promise_test(async () => {
|
|
||||||
await onLoadPromise;
|
|
||||||
|
|
||||||
assert_equals(resources_script_result, 'loaded from webbundle');
|
|
||||||
}, "A subresource script.js should be loaded from WebBundle using the relative URL and a base element.");
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
|
@ -5,6 +5,9 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="../resources/test-helpers.js"></script>
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
|
</script>
|
||||||
<body>
|
<body>
|
||||||
<link
|
<link
|
||||||
rel="webbundle"
|
rel="webbundle"
|
||||||
|
@ -12,49 +15,5 @@
|
||||||
resources="/web-bundle/resources/wbn/static-element/resources/script.js"/>
|
resources="/web-bundle/resources/wbn/static-element/resources/script.js"/>
|
||||||
<script id="script" src="/web-bundle/resources/wbn/static-element/resources/script.js"></script>
|
<script id="script" src="/web-bundle/resources/wbn/static-element/resources/script.js"></script>
|
||||||
|
|
||||||
<script>
|
<script src="resources/relative-url-test.js"></script>
|
||||||
const onLoadPromise = new Promise((resolve) => {
|
|
||||||
window.addEventListener('load', resolve, false);
|
|
||||||
});
|
|
||||||
|
|
||||||
/*
|
|
||||||
This test tries to load 'script.js' subresource from a static-element.wbn, using
|
|
||||||
a relative URL instead of an absolute one with a <link> and <script> elements
|
|
||||||
directly in the document (they are used only for this test).
|
|
||||||
*/
|
|
||||||
promise_test(async () => {
|
|
||||||
await onLoadPromise;
|
|
||||||
|
|
||||||
assert_equals(resources_script_result, 'loaded from webbundle');
|
|
||||||
}, "A subresource script.js should be loaded from WebBundle using the relative URL.");
|
|
||||||
|
|
||||||
// Simple load of a root.js subresource from subresource.wbn using a relative URL.
|
|
||||||
promise_test(async () => {
|
|
||||||
const link = document.createElement("link");
|
|
||||||
const resource_url = '/web-bundle/resources/wbn/root.js';
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = "../resources/wbn/subresource.wbn";
|
|
||||||
link.resources.add(resource_url);
|
|
||||||
document.body.appendChild(link);
|
|
||||||
|
|
||||||
const response = await fetch(resource_url);
|
|
||||||
assert_true(response.ok);
|
|
||||||
const root = await response.text();
|
|
||||||
assert_equals(root, "export * from './submodule.js';\n");
|
|
||||||
}, "Subresources with relative URLs should be loaded from the WebBundle.");
|
|
||||||
|
|
||||||
// Simple load of a root.js subresource from subresource.wbn using an
|
|
||||||
// incorrect relative URL leading to a failed fetch.
|
|
||||||
promise_test(async () => {
|
|
||||||
const link = document.createElement("link");
|
|
||||||
const resource_url = 'web-bundle/resources/wbn/root.js';
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = "../resources/wbn/subresource.wbn";
|
|
||||||
link.resources.add(resource_url);
|
|
||||||
document.body.appendChild(link);
|
|
||||||
|
|
||||||
const response = await fetch(resource_url);
|
|
||||||
assert_false(response.ok);
|
|
||||||
}, "Wrong relative URL should result in a failed fetch.");
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Request's destination must be "webbundle" with the link-based API</title>
|
||||||
|
<link
|
||||||
|
rel="help"
|
||||||
|
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
||||||
|
/>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/request-destination-test.sub.js"></script>
|
||||||
|
</body>
|
|
@ -1,44 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<title>Request's destination must be "webbundle" with the link-based API</title>
|
|
||||||
<link
|
|
||||||
rel="help"
|
|
||||||
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
|
||||||
/>
|
|
||||||
<script src="/resources/testharness.js"></script>
|
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
|
||||||
<script src="../resources/test-helpers.js"></script>
|
|
||||||
<body>
|
|
||||||
<script>
|
|
||||||
// check-sec-fetch-dest-header-and-return-bundle.py returns a valid format
|
|
||||||
// bundle only if a "Sec-Fetch-Dest: webbundle" header is present in a request.
|
|
||||||
// Otherwise, returns an empty body with 400 status code.
|
|
||||||
//
|
|
||||||
// In this wpt, we assume that a <link> element fires a load event correctly if
|
|
||||||
// a valid format webbundle is returned.
|
|
||||||
|
|
||||||
const same_origin_bundle =
|
|
||||||
"../resources/check-sec-fetch-dest-header-and-return-bundle.py";
|
|
||||||
const cross_origin_bundle =
|
|
||||||
"https://{{domains[www1]}}:{{ports[https][0]}}/web-bundle/resources/check-sec-fetch-dest-header-and-return-bundle.py";
|
|
||||||
|
|
||||||
promise_test(async () => {
|
|
||||||
for (const bundle of [same_origin_bundle, cross_origin_bundle]) {
|
|
||||||
const link = document.createElement("link");
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = bundle;
|
|
||||||
await addElementAndWaitForLoad(link);
|
|
||||||
link.remove();
|
|
||||||
}
|
|
||||||
}, '"Sec-Fetch-Dest: webbundle" header must be present in a request for a bundle with the <link>-based API.');
|
|
||||||
|
|
||||||
promise_test(async () => {
|
|
||||||
const res = await fetch(same_origin_bundle);
|
|
||||||
assert_false(res.ok);
|
|
||||||
}, '"Sec-Fetch-Dest: webbundle" header must not be present in a fetch request for a same-origin resource.');
|
|
||||||
|
|
||||||
promise_test(async () => {
|
|
||||||
const res = await fetch(cross_origin_bundle);
|
|
||||||
assert_false(res.ok);
|
|
||||||
}, '"Sec-Fetch-Dest: webbundle" header must not be present in a fetch request for a cross-origin resource.');
|
|
||||||
</script>
|
|
||||||
</body>
|
|
|
@ -3,60 +3,12 @@
|
||||||
<title>Resource timing attributes are consistent for the same-origin subresources.</title>
|
<title>Resource timing attributes are consistent for the same-origin subresources.</title>
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<body>
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
promise_test(async t => {
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
const link = document.createElement("link");
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = "../resources/wbn/dynamic1.wbn?pipe=trickle(d0.5)";
|
|
||||||
link.resources.add('https://web-platform.test:8444/web-bundle/resources/wbn/dynamic/resource1.js');
|
|
||||||
const script_id = 'https://web-platform.test:8444/web-bundle/resources/wbn/dynamic/resource1.js';
|
|
||||||
document.body.appendChild(link);
|
|
||||||
var script_entries = 0;
|
|
||||||
var web_bundle_entries = 0;
|
|
||||||
var web_bundle_entry, script_entry;
|
|
||||||
const promise = new Promise(resolve => {
|
|
||||||
new PerformanceObserver(t.step_func(entryList => {
|
|
||||||
var entries = entryList.getEntriesByType("resource");
|
|
||||||
for (var i = 0; i < entries.length; ++i) {
|
|
||||||
if (entries[i].name === script_id) {
|
|
||||||
script_entry = entries[i];
|
|
||||||
script_entries++;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entries[i].name === 'https://web-platform.test:8444/web-bundle/resources/wbn/dynamic1.wbn?pipe=trickle(d0.5)') {
|
|
||||||
web_bundle_entry = entries[i];
|
|
||||||
web_bundle_entries++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (web_bundle_entries > 0 && script_entries > 0) {
|
|
||||||
// Check timestamps.
|
|
||||||
assert_greater_than_equal(script_entry.responseStart, script_entry.requestStart + 500);
|
|
||||||
assert_greater_than_equal(script_entry.responseStart, web_bundle_entry.responseStart);
|
|
||||||
assert_greater_than_equal(script_entry.responseEnd, script_entry.responseStart);
|
|
||||||
assert_greater_than_equal(script_entry.requestStart, script_entry.connectEnd);
|
|
||||||
assert_greater_than_equal(script_entry.responseEnd, script_entry.responseStart);
|
|
||||||
// Check sizes.
|
|
||||||
assert_greater_than(script_entry.encodedBodySize, 0);
|
|
||||||
assert_equals(script_entry.transferSize, script_entry.encodedBodySize + 300);
|
|
||||||
assert_equals(script_entry.encodedBodySize, script_entry.decodedBodySize);
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
})).observe({entryTypes: ["resource"]});
|
|
||||||
});
|
|
||||||
const script = document.createElement("script");
|
|
||||||
script.type = "module";
|
|
||||||
script.src = script_id;
|
|
||||||
document.body.appendChild(script);
|
|
||||||
return promise;
|
|
||||||
}, '"Timestamp attributes filled in resource timing entries should be consistent."');
|
|
||||||
</script>
|
</script>
|
||||||
<h1>Resource timing attributes are consistent</h1>
|
<body>
|
||||||
<p>
|
<script src="resources/resource-timing-attributes-consistent-test.sub.js"></script>
|
||||||
This test verifies that attributes filled in the PerformanceResourceTiming entries for subresources
|
|
||||||
loaded from the WebBundle are consistent.
|
|
||||||
</p>
|
|
||||||
<div id="log"></div>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -3,54 +3,12 @@
|
||||||
<title>Resource timing entries present for urn:uuid resources</title>
|
<title>Resource timing entries present for urn:uuid resources</title>
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<body>
|
<script src="../resources/test-helpers.js"></script>
|
||||||
<script>
|
|
||||||
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 link = document.createElement("link");
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = "../resources/wbn/urn-uuid.wbn";
|
|
||||||
link.resources.add(frame_id, script_id);
|
|
||||||
document.body.appendChild(link);
|
|
||||||
var iframe_entries = 0;
|
|
||||||
var script_entries = 0;
|
|
||||||
// Declare the report_result function as outputting into stderr
|
|
||||||
// because it is used in the WebBundle script to report the script load.
|
|
||||||
window.report_result = console.error;
|
|
||||||
const promise = new Promise(resolve => {
|
|
||||||
new PerformanceObserver(t.step_func(entryList => {
|
|
||||||
var entries = entryList.getEntriesByType("resource");
|
|
||||||
for (var i = 0; i < entries.length; ++i) {
|
|
||||||
// Ignore any entries for the test harness files if present.
|
|
||||||
if (/testharness(report)?\.js/.test(entries[i].name)) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (entries[i].name === frame_id)
|
<script>
|
||||||
++iframe_entries;
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
if (entries[i].name === script_id)
|
|
||||||
++script_entries;
|
|
||||||
}
|
|
||||||
if (iframe_entries == 1 && script_entries == 1) {
|
|
||||||
resolve();
|
|
||||||
}
|
|
||||||
})).observe({entryTypes: ["resource"]});
|
|
||||||
});
|
|
||||||
// Add iframe and the script so we get the ResourceTiming
|
|
||||||
const iframe = document.createElement("iframe");
|
|
||||||
iframe.src = frame_id;
|
|
||||||
document.body.appendChild(iframe);
|
|
||||||
const script = document.createElement("script");
|
|
||||||
script.src = script_id;
|
|
||||||
document.body.appendChild(script);
|
|
||||||
return promise;
|
|
||||||
}, '"Each urn:uuid resource should have exactly 1 ResourceTiming entry."');
|
|
||||||
</script>
|
</script>
|
||||||
<h1>Resource timing entries present for urn:uuid resources</h1>
|
<body>
|
||||||
<p>
|
<script src="resources/resource-timing-test.js"></script>
|
||||||
This test makes sure that ResourceTiming entries (exactly 1 per resource) are created for urn:uuid resources served from a webbundle.
|
|
||||||
</p>
|
|
||||||
<div id="log"></div>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
||||||
|
|
|
@ -5,108 +5,9 @@
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<script src="../resources/test-helpers.js"></script>
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
|
</script>
|
||||||
<body>
|
<body>
|
||||||
<script>
|
<script src="resources/service-worker-controlled-test.js"></script>
|
||||||
async function registerServiceWorkerAndReturnActiveWorker(t, script, scope) {
|
|
||||||
const reg = await navigator.serviceWorker.register(script, {scope: scope});
|
|
||||||
t.add_cleanup(() => reg.unregister());
|
|
||||||
if (reg.active)
|
|
||||||
return reg.active;
|
|
||||||
const worker = reg.installing || reg.waiting;
|
|
||||||
await new Promise((resolve) => {
|
|
||||||
worker.addEventListener('statechange', (event) => {
|
|
||||||
if (event.target.state == 'activated')
|
|
||||||
resolve();
|
|
||||||
});
|
|
||||||
});
|
|
||||||
return worker;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function getRequestedUrls(worker) {
|
|
||||||
return new Promise(resolve => {
|
|
||||||
navigator.serviceWorker.addEventListener(
|
|
||||||
'message',
|
|
||||||
e => {resolve(e.data);},
|
|
||||||
{once: true})
|
|
||||||
worker.postMessage(null);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
promise_test(async (t) => {
|
|
||||||
const iframe_path = './resources/service-worker-controlled-iframe.html';
|
|
||||||
const iframe_url = new URL(iframe_path, location).href
|
|
||||||
|
|
||||||
// Register a service worker.
|
|
||||||
const worker = await registerServiceWorkerAndReturnActiveWorker(
|
|
||||||
t,
|
|
||||||
'./resources/service-worker-for-request-monitor.js',
|
|
||||||
iframe_path);
|
|
||||||
|
|
||||||
// Load an iframe which is controlled by the service worker.
|
|
||||||
const iframe = await new Promise(resolve => {
|
|
||||||
const frame = document.createElement('iframe');
|
|
||||||
t.add_cleanup(() => frame.remove());
|
|
||||||
frame.src = iframe_url;
|
|
||||||
frame.onload = () => { resolve(frame); };
|
|
||||||
document.body.appendChild(frame);
|
|
||||||
});
|
|
||||||
// The iframe request should be intercepted by the service worker.
|
|
||||||
assert_array_equals(await getRequestedUrls(worker), [iframe_url]);
|
|
||||||
|
|
||||||
// Add <link rel=webbundle> 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 link = iframe.contentDocument.createElement("link");
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = "../../resources/wbn/urn-uuid.wbn";
|
|
||||||
link.resources.add(frame_id, script_id);
|
|
||||||
const link_load_promise = new Promise(resolve => {
|
|
||||||
link.addEventListener('load', () => {resolve();});
|
|
||||||
});
|
|
||||||
iframe.contentDocument.body.appendChild(link);
|
|
||||||
await link_load_promise;
|
|
||||||
// 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.
|
|
||||||
const result_promise = new Promise(resolve => {
|
|
||||||
// window.report_result() method will be called by the injected script.
|
|
||||||
iframe.contentWindow.report_result = resolve;
|
|
||||||
});
|
|
||||||
const script = iframe.contentDocument.createElement("script");
|
|
||||||
script.src = script_id;
|
|
||||||
iframe.contentDocument.body.appendChild(script);
|
|
||||||
assert_equals(await result_promise, 'OK');
|
|
||||||
// The urn uuld URL script request should not be intercepted by the
|
|
||||||
// service worker.
|
|
||||||
assert_array_equals(await getRequestedUrls(worker), []);
|
|
||||||
|
|
||||||
// Add an urn uuid URL iframe element in the service worker controlled
|
|
||||||
// iframe.
|
|
||||||
const inner_iframe = iframe.contentDocument.createElement("iframe");
|
|
||||||
inner_iframe.src = frame_id;
|
|
||||||
const load_promise = new Promise(resolve => {
|
|
||||||
inner_iframe.addEventListener('load', () => {resolve();});
|
|
||||||
});
|
|
||||||
iframe.contentDocument.body.appendChild(inner_iframe);
|
|
||||||
await load_promise;
|
|
||||||
// The urn uuld URL iframe request should not intercepted by the service
|
|
||||||
// worker.
|
|
||||||
assert_array_equals(await getRequestedUrls(worker), []);
|
|
||||||
|
|
||||||
// Check if the urn uuid URL iframe element is loaded correctly.
|
|
||||||
const message_promise = new Promise(resolve => {
|
|
||||||
window.addEventListener(
|
|
||||||
'message',
|
|
||||||
e => {resolve(e.data);},
|
|
||||||
{once: true});
|
|
||||||
});
|
|
||||||
// location.href is evaluated in the urn uuid 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.');
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -1,56 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<title>WebBundle subresource loading for static elements with a base element</title>
|
|
||||||
<link
|
|
||||||
rel="help"
|
|
||||||
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
|
||||||
/>
|
|
||||||
<base href="../resources/wbn/static-element/">
|
|
||||||
<script src="/resources/testharness.js"></script>
|
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
|
||||||
<body>
|
|
||||||
<link
|
|
||||||
rel="webbundle"
|
|
||||||
href="../static-element.wbn"
|
|
||||||
resources="
|
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn/static-element/resources/script.js
|
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn/static-element/resources/style.css
|
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn/static-element/resources/style-imported-from-file.css
|
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn/static-element/resources/style-imported-from-tag.css"
|
|
||||||
scopes="https://web-platform.test:8444/web-bundle/resources/wbn/static-element/scopes/"
|
|
||||||
/>
|
|
||||||
<style type="text/css">
|
|
||||||
@import 'resources/style-imported-from-tag.css';
|
|
||||||
@import 'scopes/style-imported-from-tag.css';
|
|
||||||
</style>
|
|
||||||
<link href="resources/style.css" rel=stylesheet>
|
|
||||||
<link href="scopes/style.css" rel=stylesheet>
|
|
||||||
<script src="resources/script.js"></script>
|
|
||||||
<script src="scopes/script.js"></script>
|
|
||||||
<script src="out-of-scope/script.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const onLoadPromise = new Promise((resolve) => {
|
|
||||||
window.addEventListener('load', resolve, false);
|
|
||||||
});
|
|
||||||
promise_test(async () => {
|
|
||||||
await onLoadPromise;
|
|
||||||
|
|
||||||
assert_equals(resources_script_result, 'loaded from webbundle');
|
|
||||||
assert_equals(scopes_script_result, 'loaded from webbundle');
|
|
||||||
assert_equals(out_of_scope_script_result, 'loaded from network');
|
|
||||||
|
|
||||||
['resources_', 'scopes_'].forEach((type) => {
|
|
||||||
['style_target',
|
|
||||||
'style_imported_from_file_target',
|
|
||||||
'style_imported_from_tag_target'].forEach((target) => {
|
|
||||||
const element = document.createElement('div');
|
|
||||||
element.id = type + target;
|
|
||||||
document.body.appendChild(element);
|
|
||||||
assert_equals(window.getComputedStyle(element).color,
|
|
||||||
'rgb(0, 0, 255)',
|
|
||||||
element.id + ' color must be blue');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, "Subresources from static elements should be loaded from web bundle.");
|
|
||||||
</script>
|
|
||||||
</body>
|
|
|
@ -0,0 +1,32 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>WebBundle subresource loading for static elements with a base element</title>
|
||||||
|
<link
|
||||||
|
rel="help"
|
||||||
|
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
||||||
|
/>
|
||||||
|
<base href="../resources/wbn/static-element/">
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<body>
|
||||||
|
<link
|
||||||
|
rel="webbundle"
|
||||||
|
href="../static-element.wbn"
|
||||||
|
resources="
|
||||||
|
https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/script.js
|
||||||
|
https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style.css
|
||||||
|
https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style-imported-from-file.css
|
||||||
|
https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style-imported-from-tag.css"
|
||||||
|
scopes="https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/scopes/"
|
||||||
|
/>
|
||||||
|
<style type="text/css">
|
||||||
|
@import 'resources/style-imported-from-tag.css';
|
||||||
|
@import 'scopes/style-imported-from-tag.css';
|
||||||
|
</style>
|
||||||
|
<link href="resources/style.css" rel=stylesheet>
|
||||||
|
<link href="scopes/style.css" rel=stylesheet>
|
||||||
|
<script src="resources/script.js"></script>
|
||||||
|
<script src="scopes/script.js"></script>
|
||||||
|
<script src="out-of-scope/script.js"></script>
|
||||||
|
|
||||||
|
<script src="/web-bundle/subresource-loading/resources/static-element-with-test.js"></script>
|
||||||
|
</body>
|
|
@ -1,55 +0,0 @@
|
||||||
<!DOCTYPE html>
|
|
||||||
<title>WebBundle subresource loading for static elements</title>
|
|
||||||
<link
|
|
||||||
rel="help"
|
|
||||||
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
|
||||||
/>
|
|
||||||
<script src="/resources/testharness.js"></script>
|
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
|
||||||
<body>
|
|
||||||
<link
|
|
||||||
rel="webbundle"
|
|
||||||
href="../resources/wbn/static-element.wbn"
|
|
||||||
resources="
|
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn/static-element/resources/script.js
|
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn/static-element/resources/style.css
|
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn/static-element/resources/style-imported-from-file.css
|
|
||||||
https://web-platform.test:8444/web-bundle/resources/wbn/static-element/resources/style-imported-from-tag.css"
|
|
||||||
scopes="https://web-platform.test:8444/web-bundle/resources/wbn/static-element/scopes/"
|
|
||||||
/>
|
|
||||||
<style type="text/css">
|
|
||||||
@import '../resources/wbn/static-element/resources/style-imported-from-tag.css';
|
|
||||||
@import '../resources/wbn/static-element/scopes/style-imported-from-tag.css';
|
|
||||||
</style>
|
|
||||||
<link href="../resources/wbn/static-element/resources/style.css" rel=stylesheet>
|
|
||||||
<link href="../resources/wbn/static-element/scopes/style.css" rel=stylesheet>
|
|
||||||
<script src="../resources/wbn/static-element/resources/script.js"></script>
|
|
||||||
<script src="../resources/wbn/static-element/scopes/script.js"></script>
|
|
||||||
<script src="../resources/wbn/static-element/out-of-scope/script.js"></script>
|
|
||||||
|
|
||||||
<script>
|
|
||||||
const onLoadPromise = new Promise((resolve) => {
|
|
||||||
window.addEventListener('load', resolve, false);
|
|
||||||
});
|
|
||||||
promise_test(async () => {
|
|
||||||
await onLoadPromise;
|
|
||||||
|
|
||||||
assert_equals(resources_script_result, 'loaded from webbundle');
|
|
||||||
assert_equals(scopes_script_result, 'loaded from webbundle');
|
|
||||||
assert_equals(out_of_scope_script_result, 'loaded from network');
|
|
||||||
|
|
||||||
['resources_', 'scopes_'].forEach((type) => {
|
|
||||||
['style_target',
|
|
||||||
'style_imported_from_file_target',
|
|
||||||
'style_imported_from_tag_target'].forEach((target) => {
|
|
||||||
const element = document.createElement('div');
|
|
||||||
element.id = type + target;
|
|
||||||
document.body.appendChild(element);
|
|
||||||
assert_equals(window.getComputedStyle(element).color,
|
|
||||||
'rgb(0, 0, 255)',
|
|
||||||
element.id + ' color must be blue');
|
|
||||||
});
|
|
||||||
});
|
|
||||||
}, "Subresources from static elements should be loaded from web bundle.");
|
|
||||||
</script>
|
|
||||||
</body>
|
|
|
@ -0,0 +1,31 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>WebBundle subresource loading for static elements</title>
|
||||||
|
<link
|
||||||
|
rel="help"
|
||||||
|
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
||||||
|
/>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<body>
|
||||||
|
<link
|
||||||
|
rel="webbundle"
|
||||||
|
href="../resources/wbn/static-element.wbn"
|
||||||
|
resources="
|
||||||
|
https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/script.js
|
||||||
|
https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style.css
|
||||||
|
https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style-imported-from-file.css
|
||||||
|
https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style-imported-from-tag.css"
|
||||||
|
scopes="https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/scopes/"
|
||||||
|
/>
|
||||||
|
<style type="text/css">
|
||||||
|
@import '../resources/wbn/static-element/resources/style-imported-from-tag.css';
|
||||||
|
@import '../resources/wbn/static-element/scopes/style-imported-from-tag.css';
|
||||||
|
</style>
|
||||||
|
<link href="../resources/wbn/static-element/resources/style.css" rel=stylesheet>
|
||||||
|
<link href="../resources/wbn/static-element/scopes/style.css" rel=stylesheet>
|
||||||
|
<script src="../resources/wbn/static-element/resources/script.js"></script>
|
||||||
|
<script src="../resources/wbn/static-element/scopes/script.js"></script>
|
||||||
|
<script src="../resources/wbn/static-element/out-of-scope/script.js"></script>
|
||||||
|
|
||||||
|
<script src="resources/static-element-with-test.js"></script>
|
||||||
|
</body>
|
|
@ -6,115 +6,11 @@
|
||||||
/>
|
/>
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
<body>
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
<script>
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'link';
|
||||||
const frame_url = 'urn:uuid:429fcc4e-0696-4bad-b099-ee9175f023ae';
|
|
||||||
|
|
||||||
promise_test(async (t) => {
|
|
||||||
const iframe = await createLinkAndIframe(t);
|
|
||||||
// The urn:uuid URL iframe is cross-origin. So accessing
|
|
||||||
// iframe.contentWindow.location should throws a SecurityError.
|
|
||||||
assert_throws_dom(
|
|
||||||
"SecurityError",
|
|
||||||
() => { iframe.contentWindow.location.href; });
|
|
||||||
}, 'The urn:uuid URL iframe must be cross-origin.');
|
|
||||||
|
|
||||||
urn_uuid_iframe_test(
|
|
||||||
'location.href',
|
|
||||||
frame_url,
|
|
||||||
'location.href in urn uuid iframe.');
|
|
||||||
|
|
||||||
urn_uuid_iframe_test(
|
|
||||||
'(' + (() => {
|
|
||||||
try {
|
|
||||||
let result = window.localStorage;
|
|
||||||
return 'no error';
|
|
||||||
} catch (e) {
|
|
||||||
return e.name;
|
|
||||||
}
|
|
||||||
}).toString() + ')()',
|
|
||||||
'SecurityError',
|
|
||||||
'Accesing window.localStorage should throw a SecurityError.');
|
|
||||||
|
|
||||||
urn_uuid_iframe_test(
|
|
||||||
'(' + (() => {
|
|
||||||
try {
|
|
||||||
let result = window.sessionStorage;
|
|
||||||
return 'no error';
|
|
||||||
} catch (e) {
|
|
||||||
return e.name;
|
|
||||||
}
|
|
||||||
}).toString() + ')()',
|
|
||||||
'SecurityError',
|
|
||||||
'Accesing window.sessionStorage should throw a SecurityError.');
|
|
||||||
|
|
||||||
urn_uuid_iframe_test(
|
|
||||||
'(' + (() => {
|
|
||||||
try {
|
|
||||||
let result = document.cookie;
|
|
||||||
return 'no error';
|
|
||||||
} catch (e) {
|
|
||||||
return e.name;
|
|
||||||
}
|
|
||||||
}).toString() + ')()',
|
|
||||||
'SecurityError',
|
|
||||||
'Accesing document.cookie should throw a SecurityError.');
|
|
||||||
|
|
||||||
urn_uuid_iframe_test(
|
|
||||||
'(' + (() => {
|
|
||||||
try {
|
|
||||||
let request = window.indexedDB.open("db");
|
|
||||||
return 'no error';
|
|
||||||
} catch (e) {
|
|
||||||
return e.name;
|
|
||||||
}
|
|
||||||
}).toString() + ')()',
|
|
||||||
'SecurityError',
|
|
||||||
'Opening an indexedDB should throw a SecurityError.');
|
|
||||||
|
|
||||||
urn_uuid_iframe_test(
|
|
||||||
'window.caches === undefined',
|
|
||||||
true,
|
|
||||||
'window.caches should be undefined.');
|
|
||||||
|
|
||||||
function urn_uuid_iframe_test(code, expected, name) {
|
|
||||||
promise_test(async (t) => {
|
|
||||||
const iframe = await createLinkAndIframe(t);
|
|
||||||
assert_equals(await evalInIframe(iframe, code), expected);
|
|
||||||
}, name);
|
|
||||||
}
|
|
||||||
|
|
||||||
async function createLinkAndIframe(t) {
|
|
||||||
const link = document.createElement('link');
|
|
||||||
link.rel = 'webbundle';
|
|
||||||
link.href = '../resources/wbn/urn-uuid.wbn';
|
|
||||||
link.resources = frame_url;
|
|
||||||
document.body.appendChild(link);
|
|
||||||
const iframe = document.createElement('iframe');
|
|
||||||
t.add_cleanup(() => {
|
|
||||||
document.body.removeChild(link);
|
|
||||||
document.body.removeChild(iframe);
|
|
||||||
});
|
|
||||||
iframe.src = frame_url;
|
|
||||||
const load_promise = new Promise((resolve) => {
|
|
||||||
iframe.addEventListener('load', resolve);
|
|
||||||
});
|
|
||||||
document.body.appendChild(iframe);
|
|
||||||
await load_promise;
|
|
||||||
return iframe;
|
|
||||||
}
|
|
||||||
|
|
||||||
async function evalInIframe(iframe, code) {
|
|
||||||
const message_promise = new Promise((resolve) => {
|
|
||||||
const listener = (e) => {
|
|
||||||
window.removeEventListener('message', listener);
|
|
||||||
resolve(e.data);
|
|
||||||
}
|
|
||||||
window.addEventListener('message', listener);
|
|
||||||
});
|
|
||||||
iframe.contentWindow.postMessage(code,'*');
|
|
||||||
return message_promise;
|
|
||||||
}
|
|
||||||
</script>
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/subframe-from-web-bundle-test.js"></script>
|
||||||
</body>
|
</body>
|
||||||
|
|
|
@ -3,6 +3,7 @@
|
||||||
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
<script src="/resources/testharness.js"></script>
|
<script src="/resources/testharness.js"></script>
|
||||||
<script src="/resources/testharnessreport.js"></script>
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
<body>
|
<body>
|
||||||
<link id="link-web-bundle" rel="webbundle" href="../resources/wbn/subresource.wbn" resources="https://web-platform.test:8444/web-bundle/resources/wbn/root.js
|
<link id="link-web-bundle" rel="webbundle" href="../resources/wbn/subresource.wbn" resources="https://web-platform.test:8444/web-bundle/resources/wbn/root.js
|
||||||
|
@ -165,11 +166,17 @@
|
||||||
}, 'Dynamically loading classic script from web bundle with link.scopes');
|
}, 'Dynamically loading classic script from web bundle with link.scopes');
|
||||||
|
|
||||||
promise_test(() => {
|
promise_test(() => {
|
||||||
return addLinkAndWaitForLoad("../resources/wbn/dynamic1.wbn?test-event");
|
return addLinkAndWaitForLoad(
|
||||||
|
"../resources/wbn/dynamic1.wbn?test-event",
|
||||||
|
/*resources=*/[],
|
||||||
|
/*crossorigin=*/undefined);
|
||||||
}, '<link rel="webbundle"> fires a load event on load success');
|
}, '<link rel="webbundle"> fires a load event on load success');
|
||||||
|
|
||||||
promise_test((t) => {
|
promise_test((t) => {
|
||||||
return addLinkAndWaitForError("../resources/wbn/nonexistent.wbn");
|
return addLinkAndWaitForError(
|
||||||
|
"../resources/wbn/nonexistent.wbn",
|
||||||
|
/*resources=*/[],
|
||||||
|
/*crossorigin=*/undefined);
|
||||||
}, '<link rel="webbundle"> fires an error event on load failure');
|
}, '<link rel="webbundle"> fires an error event on load failure');
|
||||||
|
|
||||||
promise_test(async () => {
|
promise_test(async () => {
|
||||||
|
@ -207,35 +214,15 @@
|
||||||
promise_test(async () => {
|
promise_test(async () => {
|
||||||
const wbn_url = 'https://web-platform.test:8444/web-bundle/resources/wbn/subresource.wbn?test-resources-update';
|
const wbn_url = 'https://web-platform.test:8444/web-bundle/resources/wbn/subresource.wbn?test-resources-update';
|
||||||
const resource_url = 'https://web-platform.test:8444/web-bundle/resources/wbn/submodule.js';
|
const resource_url = 'https://web-platform.test:8444/web-bundle/resources/wbn/submodule.js';
|
||||||
const link = await addLinkAndWaitForLoad(wbn_url);
|
const link = await addLinkAndWaitForLoad(wbn_url,
|
||||||
|
/*resources=*/[],
|
||||||
|
/*crossorigin=*/undefined);
|
||||||
link.resources.add(resource_url);
|
link.resources.add(resource_url);
|
||||||
const resp = await fetch(resource_url, { cache: 'no-store' });
|
const resp = await fetch(resource_url, { cache: 'no-store' });
|
||||||
assert_true(resp.ok);
|
assert_true(resp.ok);
|
||||||
assert_equals(performance.getEntriesByName(wbn_url).length, 1);
|
assert_equals(performance.getEntriesByName(wbn_url).length, 1);
|
||||||
}, 'Updating resource= attribute should not reload the bundle');
|
}, 'Updating resource= attribute should not reload the bundle');
|
||||||
|
|
||||||
function addLinkAndWaitForLoad(url) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const link = document.createElement("link");
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = url;
|
|
||||||
link.onload = () => resolve(link);
|
|
||||||
link.onerror = reject;
|
|
||||||
document.body.appendChild(link);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
function addLinkAndWaitForError(url) {
|
|
||||||
return new Promise((resolve, reject) => {
|
|
||||||
const link = document.createElement("link");
|
|
||||||
link.rel = "webbundle";
|
|
||||||
link.href = url;
|
|
||||||
link.onload = reject;
|
|
||||||
link.onerror = () => resolve(link);
|
|
||||||
document.body.appendChild(link);
|
|
||||||
});
|
|
||||||
}
|
|
||||||
|
|
||||||
async function loadScriptAndWaitReport(script_url) {
|
async function loadScriptAndWaitReport(script_url) {
|
||||||
const result_promise = new Promise((resolve) => {
|
const result_promise = new Promise((resolve) => {
|
||||||
// This function will be called from script.js
|
// This function will be called from script.js
|
||||||
|
|
|
@ -0,0 +1,7 @@
|
||||||
|
promise_test(async () => {
|
||||||
|
await addWebBundleElementAndWaitForLoad(
|
||||||
|
'../resources/check-accept-header-and-return-bundle.py',
|
||||||
|
/*resources=*/[]);
|
||||||
|
},
|
||||||
|
'"Accept:" header in a request for a bundle should contain ' +
|
||||||
|
'application/webbundle MIME type.');
|
|
@ -0,0 +1,13 @@
|
||||||
|
promise_test(async () => {
|
||||||
|
const element = createWebBundleElement(
|
||||||
|
'/xhr/resources/delay.py?ms=100000',
|
||||||
|
['/xhr/resources/dummy']);
|
||||||
|
document.body.appendChild(element);
|
||||||
|
const waitUntilFail = new Promise((resolve) => {
|
||||||
|
fetch("/xhr/resources/dummy").then(() => {}, resolve);
|
||||||
|
});
|
||||||
|
document.body.removeChild(element);
|
||||||
|
await waitUntilFail;
|
||||||
|
},
|
||||||
|
'On-going subresource loading should fail immediately when the element is ' +
|
||||||
|
'removed.');
|
|
@ -0,0 +1,12 @@
|
||||||
|
promise_test(async () => {
|
||||||
|
const response = await fetch('/web-bundle/resources/wbn/nested-sub.wbn');
|
||||||
|
assert_true(response.ok);
|
||||||
|
}, 'A nested bundle can be fetched');
|
||||||
|
|
||||||
|
promise_test(async () => {
|
||||||
|
await addWebBundleElementAndWaitForError(
|
||||||
|
'/web-bundle/resources/wbn/nested-sub.wbn',
|
||||||
|
['/web-bundle/resources/wbn/root.js']);
|
||||||
|
const response = await fetch('/web-bundle/resources/wbn/root.js');
|
||||||
|
assert_false(response.ok);
|
||||||
|
}, 'Subresources in a nested bundle should not be loaded');
|
|
@ -0,0 +1,15 @@
|
||||||
|
// This test uses a non-existing WebBundle from a non-existent host, which makes
|
||||||
|
// Web Bundle fetching fail due to a network error. The intent of is to check if
|
||||||
|
// failing to fetch a WebBundle also makes subresource fetch requests fail.
|
||||||
|
promise_test(async () => {
|
||||||
|
const prefix = 'https://{{hosts[][nonexistent]}}/';
|
||||||
|
const resources = [
|
||||||
|
prefix + 'resource.js',
|
||||||
|
];
|
||||||
|
const link = await addWebBundleElementAndWaitForError(
|
||||||
|
prefix + 'non-existing.wbn',
|
||||||
|
resources);
|
||||||
|
|
||||||
|
// Can not fetch a subresource because Web Bundle fetch failed.
|
||||||
|
await fetchAndWaitForReject(prefix + 'resource.js');
|
||||||
|
}, 'Subresource fetch requests for non-existing Web Bundle should fail.');
|
|
@ -0,0 +1,17 @@
|
||||||
|
// This test uses a non-existing WebBundle,
|
||||||
|
// /web-bundle/resources/wbn/cors/non-existing.wbn.
|
||||||
|
// The intent of this test is to check if failing to fetch a WebBundle due to
|
||||||
|
// not found error also makes subresource fetch requests fail.
|
||||||
|
promise_test(async () => {
|
||||||
|
const prefix = '/web-bundle/resources/wbn/';
|
||||||
|
const resources = [
|
||||||
|
prefix + 'resource.js',
|
||||||
|
];
|
||||||
|
const element = await createWebBundleElement(
|
||||||
|
prefix + 'non-existing.wbn',
|
||||||
|
resources);
|
||||||
|
document.body.appendChild(element);
|
||||||
|
|
||||||
|
// Can not fetch a subresource because Web Bundle fetch failed.
|
||||||
|
await fetchAndWaitForReject(prefix + 'resource.js');
|
||||||
|
}, 'Subresource fetch requests for non-existing Web Bundle should fail.');
|
|
@ -0,0 +1,23 @@
|
||||||
|
promise_test(async () => {
|
||||||
|
const resources = [
|
||||||
|
"/web-bundle/resources/wbn/resource.js",
|
||||||
|
"/web-bundle/resources/wbn/sub/resource.js",
|
||||||
|
];
|
||||||
|
for (const resource of resources) {
|
||||||
|
const response = await fetch(resource);
|
||||||
|
assert_true(response.ok, resource + " should be loaded");
|
||||||
|
}
|
||||||
|
}, "Subresources should be loaded.");
|
||||||
|
|
||||||
|
promise_test(async () => {
|
||||||
|
const resources = [
|
||||||
|
"/web-bundle/resources/wbn-resource.js",
|
||||||
|
"/web-bundle/resources/wbn1/resource.js",
|
||||||
|
"/web-bundle/resources/other/resource.js",
|
||||||
|
"/web-bundle/resources/resource.js",
|
||||||
|
];
|
||||||
|
for (const resource of resources) {
|
||||||
|
const response = await fetch(resource);
|
||||||
|
assert_false(response.ok, resource + " should not be loaded");
|
||||||
|
}
|
||||||
|
}, "Subresources should not be loaded due to path restriction.");
|
|
@ -0,0 +1,38 @@
|
||||||
|
// This test tries to load 'script.js' subresource from a static-element.wbn,
|
||||||
|
// using a relative URL instead of an absolute one with a <link> and <script>
|
||||||
|
// elements directly in the document (they are used only for this test).
|
||||||
|
promise_test(async () => {
|
||||||
|
assert_equals(resources_script_result, 'loaded from webbundle');
|
||||||
|
},
|
||||||
|
'A subresource script.js should be loaded from WebBundle using the relative ' +
|
||||||
|
'URL.');
|
||||||
|
|
||||||
|
// Simple load of a root.js subresource from subresource.wbn using a relative
|
||||||
|
// URL.
|
||||||
|
promise_test(async () => {
|
||||||
|
const resource_url = '/web-bundle/resources/wbn/root.js';
|
||||||
|
|
||||||
|
const element = createWebBundleElement(
|
||||||
|
'../resources/wbn/subresource.wbn',
|
||||||
|
[resource_url]);
|
||||||
|
document.body.appendChild(element);
|
||||||
|
|
||||||
|
const response = await fetch(resource_url);
|
||||||
|
assert_true(response.ok);
|
||||||
|
const root = await response.text();
|
||||||
|
assert_equals(root, 'export * from \'./submodule.js\';\n');
|
||||||
|
}, 'Subresources with relative URLs should be loaded from the WebBundle.');
|
||||||
|
|
||||||
|
// Simple load of a root.js subresource from subresource.wbn using an
|
||||||
|
// incorrect relative URL leading to a failed fetch.
|
||||||
|
promise_test(async () => {
|
||||||
|
const resource_url = 'web-bundle/resources/wbn/root.js';
|
||||||
|
|
||||||
|
const element = createWebBundleElement(
|
||||||
|
'../resources/wbn/subresource.wbn',
|
||||||
|
[resource_url]);
|
||||||
|
document.body.appendChild(element);
|
||||||
|
|
||||||
|
const response = await fetch(resource_url);
|
||||||
|
assert_false(response.ok);
|
||||||
|
}, 'Wrong relative URL should result in a failed fetch.');
|
|
@ -0,0 +1,5 @@
|
||||||
|
test(() => {
|
||||||
|
assert_equals(resources_script_result, 'loaded from webbundle');
|
||||||
|
},
|
||||||
|
'A subresource script.js should be loaded from WebBundle using the relative ' +
|
||||||
|
'URL and a base element.');
|
|
@ -0,0 +1,37 @@
|
||||||
|
// check-sec-fetch-dest-header-and-return-bundle.py returns a valid format
|
||||||
|
// bundle only if a 'Sec-Fetch-Dest: webbundle' header is present in a request.
|
||||||
|
// Otherwise, returns an empty body with 400 status code.
|
||||||
|
//
|
||||||
|
// In this wpt, we assume that a <link> element fires a load event correctly if
|
||||||
|
// a valid format webbundle is returned.
|
||||||
|
|
||||||
|
const same_origin_bundle =
|
||||||
|
'../resources/check-sec-fetch-dest-header-and-return-bundle.py';
|
||||||
|
const cross_origin_bundle =
|
||||||
|
'https://{{domains[www1]}}:{{ports[https][0]}}/web-bundle/resources/check-sec-fetch-dest-header-and-return-bundle.py';
|
||||||
|
|
||||||
|
promise_test(async () => {
|
||||||
|
for (const bundle of [same_origin_bundle, cross_origin_bundle]) {
|
||||||
|
const element = createWebBundleElement(
|
||||||
|
bundle,
|
||||||
|
/*resources=*/[]);
|
||||||
|
await addElementAndWaitForLoad(element);
|
||||||
|
element.remove();
|
||||||
|
}
|
||||||
|
},
|
||||||
|
'"Sec-Fetch-Dest: webbundle" header must be present in a request for a bundle' +
|
||||||
|
' with the <link>-based API.');
|
||||||
|
|
||||||
|
promise_test(async () => {
|
||||||
|
const res = await fetch(same_origin_bundle);
|
||||||
|
assert_false(res.ok);
|
||||||
|
},
|
||||||
|
'"Sec-Fetch-Dest: webbundle" header must not be present in a fetch request' +
|
||||||
|
' for a same-origin resource.');
|
||||||
|
|
||||||
|
promise_test(async () => {
|
||||||
|
const res = await fetch(cross_origin_bundle);
|
||||||
|
assert_false(res.ok);
|
||||||
|
},
|
||||||
|
'"Sec-Fetch-Dest: webbundle" header must not be present in a fetch request' +
|
||||||
|
' for a cross-origin resource.');
|
|
@ -0,0 +1,61 @@
|
||||||
|
promise_test(async t => {
|
||||||
|
const bundle_url = 'https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/dynamic1.wbn?pipe=trickle(d0.5)';
|
||||||
|
const script_url = 'https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/dynamic/resource1.js';
|
||||||
|
const element = createWebBundleElement(
|
||||||
|
'../resources/wbn/dynamic1.wbn?pipe=trickle(d0.5)',
|
||||||
|
/*resources=*/[script_url]);
|
||||||
|
document.body.appendChild(element);
|
||||||
|
var script_entries = 0;
|
||||||
|
var web_bundle_entries = 0;
|
||||||
|
var web_bundle_entry, script_entry;
|
||||||
|
const promise = new Promise(resolve => {
|
||||||
|
new PerformanceObserver(t.step_func(entryList => {
|
||||||
|
var entries = entryList.getEntriesByType('resource');
|
||||||
|
for (var i = 0; i < entries.length; ++i) {
|
||||||
|
if (entries[i].name === script_url) {
|
||||||
|
script_entry = entries[i];
|
||||||
|
script_entries++;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entries[i].name === bundle_url) {
|
||||||
|
web_bundle_entry = entries[i];
|
||||||
|
web_bundle_entries++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (web_bundle_entries > 0 && script_entries > 0) {
|
||||||
|
// Check timestamps.
|
||||||
|
assert_greater_than_equal(
|
||||||
|
script_entry.responseStart,
|
||||||
|
script_entry.requestStart + 500);
|
||||||
|
assert_greater_than_equal(
|
||||||
|
script_entry.responseStart,
|
||||||
|
web_bundle_entry.responseStart);
|
||||||
|
assert_greater_than_equal(
|
||||||
|
script_entry.responseEnd,
|
||||||
|
script_entry.responseStart);
|
||||||
|
assert_greater_than_equal(
|
||||||
|
script_entry.requestStart,
|
||||||
|
script_entry.connectEnd);
|
||||||
|
assert_greater_than_equal(
|
||||||
|
script_entry.responseEnd,
|
||||||
|
script_entry.responseStart);
|
||||||
|
// Check sizes.
|
||||||
|
assert_greater_than(script_entry.encodedBodySize, 0);
|
||||||
|
assert_equals(
|
||||||
|
script_entry.transferSize,
|
||||||
|
script_entry.encodedBodySize + 300);
|
||||||
|
assert_equals(
|
||||||
|
script_entry.encodedBodySize,
|
||||||
|
script_entry.decodedBodySize);
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
})).observe({entryTypes: ['resource']});
|
||||||
|
});
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.type = 'module';
|
||||||
|
script.src = script_url;
|
||||||
|
document.body.appendChild(script);
|
||||||
|
return promise;
|
||||||
|
},
|
||||||
|
'Timestamp attributes filled in resource timing entries should be consistent.');
|
|
@ -0,0 +1,40 @@
|
||||||
|
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 element = createWebBundleElement(
|
||||||
|
'../resources/wbn/urn-uuid.wbn',
|
||||||
|
/*resources=*/[frame_id, script_id]);
|
||||||
|
document.body.appendChild(element);
|
||||||
|
let iframe_entries = 0;
|
||||||
|
let script_entries = 0;
|
||||||
|
// Declare the report_result function as outputting into stderr
|
||||||
|
// because it is used in the WebBundle script to report the script load.
|
||||||
|
window.report_result = console.error;
|
||||||
|
const promise = new Promise(resolve => {
|
||||||
|
new PerformanceObserver(t.step_func(entryList => {
|
||||||
|
let entries = entryList.getEntriesByType('resource');
|
||||||
|
for (let i = 0; i < entries.length; ++i) {
|
||||||
|
// Ignore any entries for the test harness files if present.
|
||||||
|
if (/testharness(report)?\.js/.test(entries[i].name)) {
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (entries[i].name === frame_id)
|
||||||
|
++iframe_entries;
|
||||||
|
if (entries[i].name === script_id)
|
||||||
|
++script_entries;
|
||||||
|
}
|
||||||
|
if (iframe_entries == 1 && script_entries == 1) {
|
||||||
|
resolve();
|
||||||
|
}
|
||||||
|
})).observe({entryTypes: ['resource']});
|
||||||
|
});
|
||||||
|
// Add iframe and the script so we get the ResourceTiming
|
||||||
|
const iframe = document.createElement('iframe');
|
||||||
|
iframe.src = frame_id;
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
const script = document.createElement('script');
|
||||||
|
script.src = script_id;
|
||||||
|
document.body.appendChild(script);
|
||||||
|
return promise;
|
||||||
|
}, 'Each urn:uuid resource should have exactly 1 ResourceTiming entry.');
|
|
@ -0,0 +1,102 @@
|
||||||
|
async function registerServiceWorkerAndReturnActiveWorker(t, script, scope) {
|
||||||
|
const reg = await navigator.serviceWorker.register(script, {scope: scope});
|
||||||
|
t.add_cleanup(() => reg.unregister());
|
||||||
|
if (reg.active)
|
||||||
|
return reg.active;
|
||||||
|
const worker = reg.installing || reg.waiting;
|
||||||
|
await new Promise((resolve) => {
|
||||||
|
worker.addEventListener('statechange', (event) => {
|
||||||
|
if (event.target.state == 'activated')
|
||||||
|
resolve();
|
||||||
|
});
|
||||||
|
});
|
||||||
|
return worker;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function getRequestedUrls(worker) {
|
||||||
|
return new Promise(resolve => {
|
||||||
|
navigator.serviceWorker.addEventListener(
|
||||||
|
'message',
|
||||||
|
e => {resolve(e.data);},
|
||||||
|
{once: true})
|
||||||
|
worker.postMessage(null);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
promise_test(async (t) => {
|
||||||
|
const iframe_path = './resources/service-worker-controlled-iframe.html';
|
||||||
|
const iframe_url = new URL(iframe_path, location).href
|
||||||
|
|
||||||
|
// Register a service worker.
|
||||||
|
const worker = await registerServiceWorkerAndReturnActiveWorker(
|
||||||
|
t,
|
||||||
|
'./resources/service-worker-for-request-monitor.js',
|
||||||
|
iframe_path);
|
||||||
|
|
||||||
|
// Load an iframe which is controlled by the service worker.
|
||||||
|
const iframe = await new Promise(resolve => {
|
||||||
|
const frame = document.createElement('iframe');
|
||||||
|
t.add_cleanup(() => frame.remove());
|
||||||
|
frame.src = iframe_url;
|
||||||
|
frame.onload = () => { resolve(frame); };
|
||||||
|
document.body.appendChild(frame);
|
||||||
|
});
|
||||||
|
// The iframe request should be intercepted by the service worker.
|
||||||
|
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 element = createWebBundleElement(
|
||||||
|
'../../resources/wbn/urn-uuid.wbn',
|
||||||
|
/*resources=*/[frame_id, script_id]);
|
||||||
|
|
||||||
|
const element_load_promise = new Promise(resolve => {
|
||||||
|
element.addEventListener('load', () => {resolve();});
|
||||||
|
});
|
||||||
|
iframe.contentDocument.body.appendChild(element);
|
||||||
|
await element_load_promise;
|
||||||
|
// 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.
|
||||||
|
const result_promise = new Promise(resolve => {
|
||||||
|
// window.report_result() method will be called by the injected script.
|
||||||
|
iframe.contentWindow.report_result = resolve;
|
||||||
|
});
|
||||||
|
const script = iframe.contentDocument.createElement('script');
|
||||||
|
script.src = script_id;
|
||||||
|
iframe.contentDocument.body.appendChild(script);
|
||||||
|
assert_equals(await result_promise, 'OK');
|
||||||
|
// The urn uuld URL script request should not be intercepted by the
|
||||||
|
// service worker.
|
||||||
|
assert_array_equals(await getRequestedUrls(worker), []);
|
||||||
|
|
||||||
|
// Add an urn uuid URL iframe element in the service worker controlled
|
||||||
|
// iframe.
|
||||||
|
const inner_iframe = iframe.contentDocument.createElement('iframe');
|
||||||
|
inner_iframe.src = frame_id;
|
||||||
|
const load_promise = new Promise(resolve => {
|
||||||
|
inner_iframe.addEventListener('load', () => {resolve();});
|
||||||
|
});
|
||||||
|
iframe.contentDocument.body.appendChild(inner_iframe);
|
||||||
|
await load_promise;
|
||||||
|
// The urn uuld URL iframe request should not intercepted by the service
|
||||||
|
// worker.
|
||||||
|
assert_array_equals(await getRequestedUrls(worker), []);
|
||||||
|
|
||||||
|
// Check if the urn uuid URL iframe element is loaded correctly.
|
||||||
|
const message_promise = new Promise(resolve => {
|
||||||
|
window.addEventListener(
|
||||||
|
'message',
|
||||||
|
e => {resolve(e.data);},
|
||||||
|
{once: true});
|
||||||
|
});
|
||||||
|
// location.href is evaluated in the urn uuid 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.');
|
|
@ -0,0 +1,18 @@
|
||||||
|
promise_test(async () => {
|
||||||
|
assert_equals(resources_script_result, 'loaded from webbundle');
|
||||||
|
assert_equals(scopes_script_result, 'loaded from webbundle');
|
||||||
|
assert_equals(out_of_scope_script_result, 'loaded from network');
|
||||||
|
|
||||||
|
['resources_', 'scopes_'].forEach((type) => {
|
||||||
|
['style_target',
|
||||||
|
'style_imported_from_file_target',
|
||||||
|
'style_imported_from_tag_target'].forEach((target) => {
|
||||||
|
const element = document.createElement('div');
|
||||||
|
element.id = type + target;
|
||||||
|
document.body.appendChild(element);
|
||||||
|
assert_equals(window.getComputedStyle(element).color,
|
||||||
|
'rgb(0, 0, 255)',
|
||||||
|
element.id + ' color must be blue');
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}, 'Subresources from static elements should be loaded from web bundle.');
|
|
@ -0,0 +1,106 @@
|
||||||
|
const frame_url = 'urn:uuid:429fcc4e-0696-4bad-b099-ee9175f023ae';
|
||||||
|
|
||||||
|
promise_test(async (t) => {
|
||||||
|
const iframe = await createWebBundleElementAndIframe(t);
|
||||||
|
// The urn:uuid URL iframe is cross-origin. So accessing
|
||||||
|
// iframe.contentWindow.location should throws a SecurityError.
|
||||||
|
assert_throws_dom(
|
||||||
|
"SecurityError",
|
||||||
|
() => { iframe.contentWindow.location.href; });
|
||||||
|
}, 'The urn:uuid URL iframe must be cross-origin.');
|
||||||
|
|
||||||
|
urn_uuid_iframe_test(
|
||||||
|
'location.href',
|
||||||
|
frame_url,
|
||||||
|
'location.href in urn uuid iframe.');
|
||||||
|
|
||||||
|
urn_uuid_iframe_test(
|
||||||
|
'(' + (() => {
|
||||||
|
try {
|
||||||
|
let result = window.localStorage;
|
||||||
|
return 'no error';
|
||||||
|
} catch (e) {
|
||||||
|
return e.name;
|
||||||
|
}
|
||||||
|
}).toString() + ')()',
|
||||||
|
'SecurityError',
|
||||||
|
'Accesing window.localStorage should throw a SecurityError.');
|
||||||
|
|
||||||
|
urn_uuid_iframe_test(
|
||||||
|
'(' + (() => {
|
||||||
|
try {
|
||||||
|
let result = window.sessionStorage;
|
||||||
|
return 'no error';
|
||||||
|
} catch (e) {
|
||||||
|
return e.name;
|
||||||
|
}
|
||||||
|
}).toString() + ')()',
|
||||||
|
'SecurityError',
|
||||||
|
'Accesing window.sessionStorage should throw a SecurityError.');
|
||||||
|
|
||||||
|
urn_uuid_iframe_test(
|
||||||
|
'(' + (() => {
|
||||||
|
try {
|
||||||
|
let result = document.cookie;
|
||||||
|
return 'no error';
|
||||||
|
} catch (e) {
|
||||||
|
return e.name;
|
||||||
|
}
|
||||||
|
}).toString() + ')()',
|
||||||
|
'SecurityError',
|
||||||
|
'Accesing document.cookie should throw a SecurityError.');
|
||||||
|
|
||||||
|
urn_uuid_iframe_test(
|
||||||
|
'(' + (() => {
|
||||||
|
try {
|
||||||
|
let request = window.indexedDB.open("db");
|
||||||
|
return 'no error';
|
||||||
|
} catch (e) {
|
||||||
|
return e.name;
|
||||||
|
}
|
||||||
|
}).toString() + ')()',
|
||||||
|
'SecurityError',
|
||||||
|
'Opening an indexedDB should throw a SecurityError.');
|
||||||
|
|
||||||
|
urn_uuid_iframe_test(
|
||||||
|
'window.caches === undefined',
|
||||||
|
true,
|
||||||
|
'window.caches should be undefined.');
|
||||||
|
|
||||||
|
function urn_uuid_iframe_test(code, expected, name) {
|
||||||
|
promise_test(async (t) => {
|
||||||
|
const iframe = await createWebBundleElementAndIframe(t);
|
||||||
|
assert_equals(await evalInIframe(iframe, code), expected);
|
||||||
|
}, name);
|
||||||
|
}
|
||||||
|
|
||||||
|
async function createWebBundleElementAndIframe(t) {
|
||||||
|
const element = createWebBundleElement(
|
||||||
|
'../resources/wbn/urn-uuid.wbn',
|
||||||
|
[frame_url]);
|
||||||
|
document.body.appendChild(element);
|
||||||
|
const iframe = document.createElement('iframe');
|
||||||
|
t.add_cleanup(() => {
|
||||||
|
document.body.removeChild(element);
|
||||||
|
document.body.removeChild(iframe);
|
||||||
|
});
|
||||||
|
iframe.src = frame_url;
|
||||||
|
const load_promise = new Promise((resolve) => {
|
||||||
|
iframe.addEventListener('load', resolve);
|
||||||
|
});
|
||||||
|
document.body.appendChild(iframe);
|
||||||
|
await load_promise;
|
||||||
|
return iframe;
|
||||||
|
}
|
||||||
|
|
||||||
|
async function evalInIframe(iframe, code) {
|
||||||
|
const message_promise = new Promise((resolve) => {
|
||||||
|
const listener = (e) => {
|
||||||
|
window.removeEventListener('message', listener);
|
||||||
|
resolve(e.data);
|
||||||
|
}
|
||||||
|
window.addEventListener('message', listener);
|
||||||
|
});
|
||||||
|
iframe.contentWindow.postMessage(code,'*');
|
||||||
|
return message_promise;
|
||||||
|
}
|
|
@ -0,0 +1,15 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Accept: request header in webbundle requests</title>
|
||||||
|
<link
|
||||||
|
rel="help"
|
||||||
|
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
||||||
|
/>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/accept-header-test.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,12 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>On-going subresource loading should fail immediately when the web bundle element is removed</title>
|
||||||
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/element-removal-test.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,19 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>A nested bundle is not supported</title>
|
||||||
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script type="webbundle">
|
||||||
|
{
|
||||||
|
"source": "/web-bundle/resources/wbn/nested-main.wbn",
|
||||||
|
"resources": ["/web-bundle/resources/wbn/nested-sub.wbn"]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script src="resources/nested-bundle-test.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Web Bundle fetching failed due to a network error</title>
|
||||||
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/network-error-test.sub.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Web Bundle fetching failed due to not found error</title>
|
||||||
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/not-found-test.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,24 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Path restriction on subresource loading with WebBundles</title>
|
||||||
|
<link
|
||||||
|
rel="help"
|
||||||
|
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
||||||
|
/>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<body>
|
||||||
|
<script type="webbundle">
|
||||||
|
{
|
||||||
|
"source": "../resources/wbn/path-restriction.wbn",
|
||||||
|
"resources": [
|
||||||
|
"/web-bundle/resources/wbn/resource.js",
|
||||||
|
"/web-bundle/resources/wbn/sub/resource.js",
|
||||||
|
"/web-bundle/resources/wbn-resource.js",
|
||||||
|
"/web-bundle/resources/wbn1/resource.js",
|
||||||
|
"/web-bundle/resources/other/resource.js",
|
||||||
|
"/web-bundle/resources/resource.js"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script src="resources/path-restriction-test.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,18 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Subresource loading using relative URLs in the 'resources' attribute with a base element</title>
|
||||||
|
<base href="../resources/wbn/static-element/">
|
||||||
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
|
||||||
|
<body>
|
||||||
|
<script type="webbundle">
|
||||||
|
{
|
||||||
|
"source": "../static-element.wbn",
|
||||||
|
"resources": ["resources/script.js"]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script id="script" src="resources/script.js"></script>
|
||||||
|
|
||||||
|
<script src="/web-bundle/subresource-loading/resources/relative-url-with-base-test.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,21 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Subresource loading using relative URLs in the 'resources' attribute</title>
|
||||||
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script type="webbundle">
|
||||||
|
{
|
||||||
|
"source": "../resources/wbn/static-element.wbn",
|
||||||
|
"resources": ["/web-bundle/resources/wbn/static-element/resources/script.js"]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<script id="script" src="/web-bundle/resources/wbn/static-element/resources/script.js"></script>
|
||||||
|
|
||||||
|
<script src="resources/relative-url-test.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Request's destination must be "webbundle" with the script-based API</title>
|
||||||
|
<link
|
||||||
|
rel="help"
|
||||||
|
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
||||||
|
/>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/request-destination-test.sub.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
<title>Resource timing attributes are consistent for the same-origin subresources.</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/resource-timing-attributes-consistent-test.sub.js"></script>
|
||||||
|
</body>
|
||||||
|
|
|
@ -0,0 +1,14 @@
|
||||||
|
<!DOCTYPE HTML>
|
||||||
|
<meta charset=utf-8>
|
||||||
|
<title>Resource timing entries present for urn:uuid resources</title>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/resource-timing-test.js"></script>
|
||||||
|
</body>
|
||||||
|
|
|
@ -0,0 +1,13 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Web Bundle fetching and the inner resouirce fetching should skip service worker</title>
|
||||||
|
<link rel="help" href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md" />
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/service-worker-controlled-test.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,36 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>WebBundle subresource loading for static elements with a base element</title>
|
||||||
|
<link
|
||||||
|
rel="help"
|
||||||
|
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
||||||
|
/>
|
||||||
|
<base href="../resources/wbn/static-element/">
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<body>
|
||||||
|
<script type="webbundle">
|
||||||
|
{
|
||||||
|
"source": "../static-element.wbn",
|
||||||
|
"resources": [
|
||||||
|
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/script.js",
|
||||||
|
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style.css",
|
||||||
|
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style-imported-from-file.css",
|
||||||
|
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style-imported-from-tag.css"
|
||||||
|
],
|
||||||
|
"scopes": [
|
||||||
|
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/scopes/"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style type="text/css">
|
||||||
|
@import 'resources/style-imported-from-tag.css';
|
||||||
|
@import 'scopes/style-imported-from-tag.css';
|
||||||
|
</style>
|
||||||
|
<link href="resources/style.css" rel=stylesheet>
|
||||||
|
<link href="scopes/style.css" rel=stylesheet>
|
||||||
|
<script src="resources/script.js"></script>
|
||||||
|
<script src="scopes/script.js"></script>
|
||||||
|
<script src="out-of-scope/script.js"></script>
|
||||||
|
|
||||||
|
<script src="/web-bundle/subresource-loading/resources/static-element-with-test.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,35 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>WebBundle subresource loading for static elements</title>
|
||||||
|
<link
|
||||||
|
rel="help"
|
||||||
|
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
||||||
|
/>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<body>
|
||||||
|
<script type="webbundle">
|
||||||
|
{
|
||||||
|
"source": "../resources/wbn/static-element.wbn",
|
||||||
|
"resources": [
|
||||||
|
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/script.js",
|
||||||
|
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style.css",
|
||||||
|
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style-imported-from-file.css",
|
||||||
|
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/resources/style-imported-from-tag.css"
|
||||||
|
],
|
||||||
|
"scopes": [
|
||||||
|
"https://{{domains[]}}:{{ports[https][0]}}/web-bundle/resources/wbn/static-element/scopes/"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
<style type="text/css">
|
||||||
|
@import '../resources/wbn/static-element/resources/style-imported-from-tag.css';
|
||||||
|
@import '../resources/wbn/static-element/scopes/style-imported-from-tag.css';
|
||||||
|
</style>
|
||||||
|
<link href="../resources/wbn/static-element/resources/style.css" rel=stylesheet>
|
||||||
|
<link href="../resources/wbn/static-element/scopes/style.css" rel=stylesheet>
|
||||||
|
<script src="../resources/wbn/static-element/resources/script.js"></script>
|
||||||
|
<script src="../resources/wbn/static-element/scopes/script.js"></script>
|
||||||
|
<script src="../resources/wbn/static-element/out-of-scope/script.js"></script>
|
||||||
|
|
||||||
|
<script src="resources/static-element-with-test.js"></script>
|
||||||
|
</body>
|
|
@ -0,0 +1,16 @@
|
||||||
|
<!DOCTYPE html>
|
||||||
|
<title>Subframe loading from Web Bundles</title>
|
||||||
|
<link
|
||||||
|
rel="help"
|
||||||
|
href="https://github.com/WICG/webpackage/blob/main/explainers/subresource-loading.md"
|
||||||
|
/>
|
||||||
|
<script src="/resources/testharness.js"></script>
|
||||||
|
<script src="/resources/testharnessreport.js"></script>
|
||||||
|
<script src="../resources/test-helpers.js"></script>
|
||||||
|
|
||||||
|
<script>
|
||||||
|
window.TEST_WEB_BUNDLE_ELEMENT_TYPE = 'script';
|
||||||
|
</script>
|
||||||
|
<body>
|
||||||
|
<script src="resources/subframe-from-web-bundle-test.js"></script>
|
||||||
|
</body>
|
Загрузка…
Ссылка в новой задаче