diff --git a/components/script/dom/htmlscriptelement.rs b/components/script/dom/htmlscriptelement.rs index 421ff11d189..b3005b181da 100644 --- a/components/script/dom/htmlscriptelement.rs +++ b/components/script/dom/htmlscriptelement.rs @@ -70,6 +70,7 @@ use crate::dom::performanceresourcetiming::InitiatorType; use crate::dom::trustedscript::TrustedScript; use crate::dom::trustedscripturl::TrustedScriptURL; use crate::dom::virtualmethods::VirtualMethods; +use crate::dom::window::Window; use crate::fetch::create_a_potential_cors_request; use crate::network_listener::{self, NetworkListener, PreInvoke, ResourceTimingListener}; use crate::realms::enter_realm; @@ -1526,6 +1527,13 @@ impl HTMLScriptElementMethods for HTMLScriptElement { .SetTextContent(Some(DOMString::from(value)), can_gc); Ok(()) } + + /// + fn Supports(_window: &Window, type_: DOMString) -> bool { + // The type argument has to exactly match these values, + // we do not perform an ASCII case-insensitive match. + matches!(type_.str(), "classic" | "module" | "importmap") + } } #[derive(Clone, Copy)] diff --git a/components/script_bindings/webidls/HTMLScriptElement.webidl b/components/script_bindings/webidls/HTMLScriptElement.webidl index 2c7b398b7e3..a21ae6007c4 100644 --- a/components/script_bindings/webidls/HTMLScriptElement.webidl +++ b/components/script_bindings/webidls/HTMLScriptElement.webidl @@ -32,6 +32,8 @@ interface HTMLScriptElement : HTMLElement { [CEReactions] attribute DOMString referrerPolicy; + static boolean supports(DOMString type); + // also has obsolete members }; diff --git a/tests/wpt/meta/html/dom/idlharness.https.html.ini b/tests/wpt/meta/html/dom/idlharness.https.html.ini index b2ea5b118c1..ed387df6221 100644 --- a/tests/wpt/meta/html/dom/idlharness.https.html.ini +++ b/tests/wpt/meta/html/dom/idlharness.https.html.ini @@ -6913,18 +6913,12 @@ [HTMLScriptElement interface: attribute fetchPriority] expected: FAIL - [HTMLScriptElement interface: operation supports(DOMString)] - expected: FAIL - [HTMLScriptElement interface: document.createElement("script") must inherit property "blocking" with the proper type] expected: FAIL [HTMLScriptElement interface: document.createElement("script") must inherit property "fetchPriority" with the proper type] expected: FAIL - [HTMLScriptElement interface: calling supports(DOMString) on document.createElement("script") with too few arguments must throw TypeError] - expected: FAIL - [HTMLMarqueeElement interface: existence and properties of interface object] expected: FAIL diff --git a/tests/wpt/meta/html/semantics/scripting-1/the-script-element/script-supports.html.ini b/tests/wpt/meta/html/semantics/scripting-1/the-script-element/script-supports.html.ini deleted file mode 100644 index 6a60c3497ed..00000000000 --- a/tests/wpt/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