Add JSON parsing to JS Validator

Differential Revision: https://phabricator.services.mozilla.com/D166946

bugzilla-url: https://bugzilla.mozilla.org/show_bug.cgi?id=1814478
gecko-commit: 1f3b1e93b0fad0f7ea0300f6ba9741d84223d725
gecko-reviewers: farre, smaug, tcampbell
diff --git a/fetch/orb/resources/data_non_ascii.json b/fetch/orb/resources/data_non_ascii.json
new file mode 100644
index 0000000..64566c5
--- /dev/null
+++ b/fetch/orb/resources/data_non_ascii.json
@@ -0,0 +1 @@
+["你好"]
diff --git a/fetch/orb/tentative/known-mime-type.sub.any.js b/fetch/orb/tentative/known-mime-type.sub.any.js
index d0954c8..919964f 100644
--- a/fetch/orb/tentative/known-mime-type.sub.any.js
+++ b/fetch/orb/tentative/known-mime-type.sub.any.js
@@ -42,6 +42,16 @@
   "ORB should block opaque application/json (empty)"
 );
 
+promise_test(
+  t =>
+    promise_rejects_js(
+      t,
+      TypeError,
+      fetchORB(`${path}/data_non_ascii.json`, null, contentType("application/json"))
+    ),
+  "ORB should block opaque application/json which contains non ascii characters"
+);
+
 promise_test(async () => {
   fetchORB(`${path}/image.png`, null, contentType("image/png"));
 }, "ORB shouldn't block opaque image/png");