Bug 1729239 - Implement HTMLScriptElement.supports(type) method. r=smaug

Differential Revision: https://phabricator.services.mozilla.com/D124900
This commit is contained in:
Tom Schuster 2021-09-27 12:49:51 +00:00
parent ef0c6ca163
commit 82e1fab48c
5 changed files with 12 additions and 18 deletions

View File

@ -228,4 +228,11 @@ bool HTMLScriptElement::HasScriptContent() {
nsContentUtils::HasNonEmptyTextContent(this); 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 } // namespace mozilla::dom

View File

@ -130,6 +130,9 @@ class HTMLScriptElement final : public nsGenericHTMLElement,
GetEnumAttr(nsGkAtoms::referrerpolicy, "", aReferrerPolicy); GetEnumAttr(nsGkAtoms::referrerpolicy, "", aReferrerPolicy);
} }
[[nodiscard]] static bool Supports(const GlobalObject& aGlobal,
const nsAString& aType);
protected: protected:
virtual ~HTMLScriptElement(); virtual ~HTMLScriptElement();

View File

@ -30,6 +30,8 @@ interface HTMLScriptElement : HTMLElement {
attribute DOMString referrerPolicy; attribute DOMString referrerPolicy;
[CEReactions, Throws] [CEReactions, Throws]
attribute DOMString text; attribute DOMString text;
static boolean supports(DOMString type);
}; };
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis // http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis

View File

@ -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

View File

@ -1,6 +1,3 @@
[script-supports-importmap.html] [script-supports-importmap.html]
[HTMLScriptElement.supports returns true for 'importmap'] [HTMLScriptElement.supports returns true for 'importmap']
expected: FAIL expected: FAIL
[HTMLScriptElement.supports returns false for unsupported types]
expected: FAIL