[DOM] Add missing IDL definitions for CSP .nonce attributes.

Apparently Mozilla completely spaced out on this when adding the CSP nonce
mechanism, potentially causing web compat issues if scripting relies on
being able to get/set nonces through DOM and/or causing CSP policy check
issues if websites try to "hide" nonces.
This commit is contained in:
Moonchild
2021-04-19 20:47:29 +00:00
committed by roytam1
parent 700f7804bd
commit 7e02267fd3
6 changed files with 32 additions and 6 deletions
+8
View File
@@ -109,6 +109,14 @@ public:
SetHTMLAttr(nsGkAtoms::rel, aRel, aRv);
}
nsDOMTokenList* RelList();
void GetNonce(nsAString& aNonce) const
{
GetHTMLAttr(nsGkAtoms::nonce, aNonce);
}
void SetNonce(const nsAString& aNonce, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::nonce, aNonce, aRv);
}
// XPCOM GetMedia is fine.
void SetMedia(const nsAString& aMedia, ErrorResult& aRv)
{
+8
View File
@@ -80,6 +80,14 @@ public:
{
SetOrRemoveNullableStringAttr(nsGkAtoms::crossorigin, aCrossOrigin, aError);
}
void GetNonce(nsAString& aNonce) const
{
GetHTMLAttr(nsGkAtoms::nonce, aNonce);
}
void SetNonce(const nsAString& aNonce, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::nonce, aNonce, aRv);
}
void GetIntegrity(nsAString& aIntegrity)
{
GetHTMLAttr(nsGkAtoms::integrity, aIntegrity);
+8
View File
@@ -60,6 +60,14 @@ public:
bool Disabled() const;
void SetDisabled(bool aDisabled);
void GetNonce(nsAString& aNonce) const
{
GetHTMLAttr(nsGkAtoms::nonce, aNonce);
}
void SetNonce(const nsAString& aNonce, ErrorResult& aRv)
{
SetHTMLAttr(nsGkAtoms::nonce, aNonce, aRv);
}
void SetMedia(const nsAString& aMedia, ErrorResult& aError)
{
SetHTMLAttr(nsGkAtoms::media, aMedia, aError);
+2
View File
@@ -26,6 +26,8 @@ interface HTMLLinkElement : HTMLElement {
readonly attribute DOMTokenList relList;
[CEReactions, SetterThrows, Pure]
attribute DOMString media;
[CEReactions, SetterThrows, Pure]
attribute DOMString nonce;
[CEReactions, SetterThrows, Pure]
attribute DOMString hreflang;
[CEReactions, SetterThrows, Pure]
+4 -6
View File
@@ -26,6 +26,10 @@ interface HTMLScriptElement : HTMLElement {
attribute DOMString? crossOrigin;
[CEReactions, SetterThrows]
attribute DOMString text;
[CEReactions, SetterThrows, Pure]
attribute DOMString nonce;
[CEReactions, SetterThrows, Pure]
attribute DOMString integrity;
};
// http://www.whatwg.org/specs/web-apps/current-work/#other-elements,-attributes-and-apis
@@ -35,9 +39,3 @@ partial interface HTMLScriptElement {
[CEReactions, SetterThrows]
attribute DOMString htmlFor;
};
// https://w3c.github.io/webappsec/specs/subresourceintegrity/#htmlscriptelement-1
partial interface HTMLScriptElement {
[CEReactions, SetterThrows]
attribute DOMString integrity;
};
+2
View File
@@ -15,6 +15,8 @@ interface HTMLStyleElement : HTMLElement {
[CEReactions, SetterThrows, Pure]
attribute DOMString media;
[CEReactions, SetterThrows, Pure]
attribute DOMString nonce;
[CEReactions, SetterThrows, Pure]
attribute DOMString type;
[SetterThrows, Pure]
attribute boolean scoped;