diff --git a/dom/html/HTMLScriptElement.cpp b/dom/html/HTMLScriptElement.cpp
index 5dece19b6bf0..0469c1c98399 100644
--- a/dom/html/HTMLScriptElement.cpp
+++ b/dom/html/HTMLScriptElement.cpp
@@ -228,4 +228,11 @@ bool HTMLScriptElement::HasScriptContent() {
nsContentUtils::HasNonEmptyTextContent(this);
}
+// https://html.spec.whatwg.org/multipage/scripting.html#dom-script-supports
+/* static */
+bool HTMLScriptElement::Supports(const GlobalObject& aGlobal,
+ const nsAString& aType) {
+ return aType.EqualsLiteral("classic") || aType.EqualsLiteral("module");
+}
+
} // namespace mozilla::dom
diff --git a/dom/html/HTMLScriptElement.h b/dom/html/HTMLScriptElement.h
index a1e96b9d59ea..ff3018db71d3 100644
--- a/dom/html/HTMLScriptElement.h
+++ b/dom/html/HTMLScriptElement.h
@@ -130,6 +130,9 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
GetEnumAttr(nsGkAtoms::referrerpolicy, "", aReferrerPolicy);
}
+ [[nodiscard]] static bool Supports(const GlobalObject& aGlobal,
+ const nsAString& aType);
+
protected:
virtual ~HTMLScriptElement();
diff --git a/dom/webidl/HTMLScriptElement.webidl b/dom/webidl/HTMLScriptElement.webidl
index a31e07b7b683..f8b7d269dd3a 100644
--- a/dom/webidl/HTMLScriptElement.webidl
+++ b/dom/webidl/HTMLScriptElement.webidl
@@ -30,6 +30,8 @@ interface HTMLScriptElement : HTMLElement {
attribute DOMString referrerPolicy;
[CEReactions, Throws]
attribute DOMString text;
+
+ static boolean supports(DOMString type);
};
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
diff --git a/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/script-supports.html.ini b/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/script-supports.html.ini
deleted file mode 100644
index 6a60c3497ed5..000000000000
--- a/testing/web-platform/meta/html/semantics/scripting-1/the-script-element/script-supports.html.ini
+++ /dev/null
@@ -1,15 +0,0 @@
-[script-supports.html]
- [Type of HTMLScriptElement.supports is function]
- expected: FAIL
-
- [HTMLScriptElement.supports resurns true for 'classic']
- expected: FAIL
-
- [HTMLScriptElement.supports resurns true for 'module']
- expected: FAIL
-
- [HTMLScriptElement.supports returns false for JavaScript MIME types]
- expected: FAIL
-
- [HTMLScriptElement.supports returns false for unsupported types]
- expected: FAIL
diff --git a/testing/web-platform/meta/import-maps/script-supports-importmap.html.ini b/testing/web-platform/meta/import-maps/script-supports-importmap.html.ini
index bc36a1c2e5bd..bc2380bba653 100644
--- a/testing/web-platform/meta/import-maps/script-supports-importmap.html.ini
+++ b/testing/web-platform/meta/import-maps/script-supports-importmap.html.ini
@@ -1,6 +1,3 @@
[script-supports-importmap.html]
[HTMLScriptElement.supports returns true for 'importmap']
expected: FAIL
-
- [HTMLScriptElement.supports returns false for unsupported types]
- expected: FAIL