commit b6c54c546d7ee108d904310b44255da06dcbae81
parent 754a58c635137c879c4f0a881bcde226c2942c1b
Author: Daniel Minor <dminor@mozilla.com>
Date: Fri, 12 Dec 2025 14:12:35 +0000
Bug 1994828 - Add HasWasmMimeTypeEssence; r=dom-core,smaug
Differential Revision: https://phabricator.services.mozilla.com/D270148
Diffstat:
2 files changed, 15 insertions(+), 0 deletions(-)
diff --git a/dom/base/nsContentUtils.cpp b/dom/base/nsContentUtils.cpp
@@ -8683,6 +8683,15 @@ bool nsContentUtils::HasCssMimeTypeEssence(const nsAString& aMimeType) {
return false;
}
+// https://html.spec.whatwg.org/#fetch-a-single-module-script, 13.6
+bool nsContentUtils::HasWasmMimeTypeEssence(const nsAString& aMimeType) {
+ nsString contentType, contentCharset;
+ if (MimeType::Parse(aMimeType, contentType, contentCharset)) {
+ return contentType.LowerCaseEqualsLiteral("application/wasm");
+ }
+ return false;
+}
+
bool nsContentUtils::PrefetchPreloadEnabled(nsIDocShell* aDocShell) {
//
// SECURITY CHECK: disable prefetching and preloading from mailnews!
diff --git a/dom/base/nsContentUtils.h b/dom/base/nsContentUtils.h
@@ -2747,6 +2747,12 @@ class nsContentUtils {
*/
static bool HasCssMimeTypeEssence(const nsAString& aMimeType);
+ /**
+ * Returns true if the given MIME type string has a wasm MIME type essence,
+ * otherwise false.
+ */
+ static bool HasWasmMimeTypeEssence(const nsAString& aMimeType);
+
static void SplitMimeType(const nsAString& aValue, nsString& aType,
nsString& aParams);