diff --git a/common/dummy.json b/common/dummy.json
new file mode 100644
index 00000000000000..0967ef424bce67
--- /dev/null
+++ b/common/dummy.json
@@ -0,0 +1 @@
+{}
diff --git a/content-security-policy/connect-src/connect-src-json-import-allowed.sub.html b/content-security-policy/connect-src/connect-src-json-import-allowed.sub.html
new file mode 100644
index 00000000000000..9991db039c219e
--- /dev/null
+++ b/content-security-policy/connect-src/connect-src-json-import-allowed.sub.html
@@ -0,0 +1,25 @@
+
+
+
+ connect-src-json-import-allowed
+
+
+
+
+
+
+
+
+
diff --git a/content-security-policy/connect-src/connect-src-json-import-blocked.sub.html b/content-security-policy/connect-src/connect-src-json-import-blocked.sub.html
new file mode 100644
index 00000000000000..d1a685e66cceed
--- /dev/null
+++ b/content-security-policy/connect-src/connect-src-json-import-blocked.sub.html
@@ -0,0 +1,31 @@
+
+
+
+ connect-src-json-import-blocked
+
+
+
+
+
+
+
+
+
diff --git a/content-security-policy/style-src/import-style-allowed.sub.html b/content-security-policy/style-src/import-style-allowed.sub.html
new file mode 100644
index 00000000000000..02a2b2eecee8f9
--- /dev/null
+++ b/content-security-policy/style-src/import-style-allowed.sub.html
@@ -0,0 +1,25 @@
+
+
+
+ import-style-allowed
+
+
+
+
+
+
+
+
+
diff --git a/content-security-policy/style-src/import-style-blocked.sub.html b/content-security-policy/style-src/import-style-blocked.sub.html
new file mode 100644
index 00000000000000..c507f415348942
--- /dev/null
+++ b/content-security-policy/style-src/import-style-blocked.sub.html
@@ -0,0 +1,33 @@
+
+
+
+ import-style-disallowed
+
+
+
+
+
+
+
+
+
+
+
diff --git a/content-security-policy/style-src/resources/blocked.css b/content-security-policy/style-src/resources/blocked.css
new file mode 100644
index 00000000000000..46f9774b5f5bff
--- /dev/null
+++ b/content-security-policy/style-src/resources/blocked.css
@@ -0,0 +1,3 @@
+#test {
+ color: red;
+}
diff --git a/fetch/api/request/destination/fetch-destination.https.html b/fetch/api/request/destination/fetch-destination.https.html
index 0094b0b6fe8eac..1b6cf16914116b 100644
--- a/fetch/api/request/destination/fetch-destination.https.html
+++ b/fetch/api/request/destination/fetch-destination.https.html
@@ -194,6 +194,40 @@
});
}, 'HTMLLinkElement with rel=stylesheet fetches with a "style" Request.destination');
+// Import declaration with `type: "css"` - style destination
+promise_test(t => {
+ return new Promise((resolve, reject) => {
+ frame.contentWindow.onerror = reject;
+
+ let node = frame.contentWindow.document.createElement("script");
+ node.onload = resolve;
+ node.onerror = reject;
+ node.src = "import-declaration-type-css.js";
+ node.type = "module";
+ frame.contentWindow.document.body.appendChild(node);
+ }).then(() => {
+ frame.contentWindow.onerror = null;
+ });
+}, 'Import declaration with `type: "css"` fetches with a "style" Request.destination');
+
+// JSON destination
+///////////////////
+
+// Import declaration with `type: "json"` - json destination
+promise_test(t => {
+ return new Promise((resolve, reject) => {
+ frame.contentWindow.onerror = reject;
+ let node = frame.contentWindow.document.createElement("script");
+ node.onload = resolve;
+ node.onerror = reject;
+ node.src = "import-declaration-type-json.js";
+ node.type = "module";
+ frame.contentWindow.document.body.appendChild(node);
+ }).then(() => {
+ frame.contentWindow.onerror = null;
+ });
+}, 'Import declaration with `type: "json"` fetches with a "json" Request.destination');
+
// Preload tests
////////////////
// HTMLLinkElement with rel=preload and as=fetch - empty string destination
@@ -232,6 +266,22 @@
});
}, 'HTMLLinkElement with rel=preload and as=style fetches with a "style" Request.destination');
+// HTMLLinkElement with rel=preload and as=json - json destination
+promise_test(t => {
+ return new Promise((resolve, reject) => {
+ let node = frame.contentWindow.document.createElement("link");
+ node.rel = "preload";
+ node.as = "json";
+ if (node.as != "json") {
+ resolve();
+ }
+ node.onload = resolve;
+ node.onerror = reject;
+ node.href = "dummy.json?t=2&dest=json";
+ frame.contentWindow.document.body.appendChild(node);
+ });
+}, 'HTMLLinkElement with rel=preload and as=json fetches with a "json" Request.destination');
+
// HTMLLinkElement with rel=preload and as=script - script destination
promise_test(async t => {
await new Promise((resolve, reject) => {
diff --git a/fetch/api/request/destination/resources/dummy.css b/fetch/api/request/destination/resources/dummy.css
new file mode 100644
index 00000000000000..e69de29bb2d1d6
diff --git a/fetch/api/request/destination/resources/dummy.json b/fetch/api/request/destination/resources/dummy.json
new file mode 100644
index 00000000000000..0967ef424bce67
--- /dev/null
+++ b/fetch/api/request/destination/resources/dummy.json
@@ -0,0 +1 @@
+{}
diff --git a/fetch/api/request/destination/resources/import-declaration-type-css.js b/fetch/api/request/destination/resources/import-declaration-type-css.js
new file mode 100644
index 00000000000000..3c8cf1f44b7157
--- /dev/null
+++ b/fetch/api/request/destination/resources/import-declaration-type-css.js
@@ -0,0 +1 @@
+import "./dummy.css?dest=style" with { type: "css" };
diff --git a/fetch/api/request/destination/resources/import-declaration-type-json.js b/fetch/api/request/destination/resources/import-declaration-type-json.js
new file mode 100644
index 00000000000000..b2d964dd824053
--- /dev/null
+++ b/fetch/api/request/destination/resources/import-declaration-type-json.js
@@ -0,0 +1 @@
+import "./dummy.json?dest=json" with { type: "json" };
diff --git a/preload/modulepreload-as.html b/preload/modulepreload-as.html
index dd946e454a1fe1..42c2dd91d00fd2 100644
--- a/preload/modulepreload-as.html
+++ b/preload/modulepreload-as.html
@@ -11,6 +11,7 @@
+
diff --git a/preload/preload-csp.sub.html b/preload/preload-csp.sub.html
index 7d367bf846d886..524844df2e094e 100644
--- a/preload/preload-csp.sub.html
+++ b/preload/preload-csp.sub.html
@@ -1,5 +1,5 @@
-
+
Makes sure that preload requests respect CSP
@@ -7,6 +7,7 @@
+
diff --git a/preload/preload-type-match.html b/preload/preload-type-match.html
index 646500f6b38cce..53f12d0ad7f95f 100644
--- a/preload/preload-type-match.html
+++ b/preload/preload-type-match.html
@@ -13,7 +13,8 @@
ttf: '/fonts/Ahem.ttf',
script: 'resources/dummy.js',
css: 'resources/dummy.css',
- track: '/media/foo.vtt'
+ track: '/media/foo.vtt',
+ json: '/common/dummy.json',
}
function test_type_with_destination(type, as, resourceType, expect) {
@@ -68,4 +69,10 @@
test_type_with_destination('text/plain', 'track', 'track', 'timeout');
test_type_with_destination('not-a-mime', 'track', 'track', 'timeout');
+test_type_with_destination('application/json', 'json', 'json', 'load');
+test_type_with_destination('text/json', 'json', 'json', 'load');
+test_type_with_destination('application/geo+json', 'json', 'json', 'load');
+test_type_with_destination('text/plain', 'json', 'json', 'timeout');
+test_type_with_destination('application/javascript', 'json', 'json', 'timeout');
+
\ No newline at end of file
diff --git a/preload/reflected-as-value.html b/preload/reflected-as-value.html
index 93f411742de58a..da8dad7803ff91 100644
--- a/preload/reflected-as-value.html
+++ b/preload/reflected-as-value.html
@@ -14,6 +14,7 @@
"audio": "audio",
"track": "track",
"fetch": "fetch",
+ "json": "json",
};
var link = document.createElement("link");
var keys = Object.keys(values);