From 824d0cad581cf1a6c0b5bdfe25e067634f6486c7 Mon Sep 17 00:00:00 2001 From: Moonchild Date: Sun, 27 Apr 2025 20:42:29 +0200 Subject: [PATCH] Issue #2736 - Part 2: Pass subject principal to SetAttribute and friends. In order to tailor certain security checks to the caller that is attempting to load a particular piece of content, we need to be able to attach an appropriate triggering principal to the corresponding requests. Since most HTML content is loaded based on attribute values, this means capturing the subject principal of the caller who sets those attributes, which in turn means we need to make it available to `AfterSetAttr` hooks on all relevant element types. --- dom/base/AnonymousContent.cpp | 3 +- dom/base/AnonymousContent.h | 1 + dom/base/Attr.cpp | 5 ++- dom/base/Attr.h | 8 +++- dom/base/DocumentFragment.h | 7 +-- dom/base/Element.cpp | 20 ++++++--- dom/base/Element.h | 61 ++++++++++++++++++-------- dom/base/nsGenericDOMDataNode.cpp | 1 + dom/base/nsGenericDOMDataNode.h | 7 +-- dom/base/nsIContent.h | 17 +++++++ dom/base/nsStyledElement.cpp | 3 +- dom/html/HTMLAnchorElement.cpp | 7 ++- dom/html/HTMLAnchorElement.h | 1 + dom/html/HTMLAreaElement.cpp | 6 ++- dom/html/HTMLAreaElement.h | 1 + dom/html/HTMLButtonElement.cpp | 6 ++- dom/html/HTMLButtonElement.h | 1 + dom/html/HTMLCanvasElement.cpp | 6 ++- dom/html/HTMLCanvasElement.h | 1 + dom/html/HTMLFieldSetElement.cpp | 7 ++- dom/html/HTMLFieldSetElement.h | 1 + dom/html/HTMLFormElement.cpp | 6 ++- dom/html/HTMLFormElement.h | 1 + dom/html/HTMLIFrameElement.cpp | 10 +++-- dom/html/HTMLIFrameElement.h | 1 + dom/html/HTMLImageElement.cpp | 13 ++++-- dom/html/HTMLImageElement.h | 2 + dom/html/HTMLInputElement.cpp | 5 ++- dom/html/HTMLInputElement.h | 1 + dom/html/HTMLLinkElement.cpp | 7 ++- dom/html/HTMLLinkElement.h | 1 + dom/html/HTMLMediaElement.cpp | 8 +++- dom/html/HTMLMediaElement.h | 1 + dom/html/HTMLMenuItemElement.cpp | 10 +++-- dom/html/HTMLMenuItemElement.h | 1 + dom/html/HTMLMetaElement.cpp | 10 +++-- dom/html/HTMLMetaElement.h | 1 + dom/html/HTMLObjectElement.cpp | 7 ++- dom/html/HTMLObjectElement.h | 1 + dom/html/HTMLOptGroupElement.cpp | 7 ++- dom/html/HTMLOptGroupElement.h | 1 + dom/html/HTMLOptionElement.cpp | 8 +++- dom/html/HTMLOptionElement.h | 1 + dom/html/HTMLScriptElement.cpp | 10 +++-- dom/html/HTMLScriptElement.h | 1 + dom/html/HTMLSelectElement.cpp | 5 ++- dom/html/HTMLSelectElement.h | 1 + dom/html/HTMLSharedElement.cpp | 7 ++- dom/html/HTMLSharedElement.h | 1 + dom/html/HTMLSharedObjectElement.cpp | 3 +- dom/html/HTMLSharedObjectElement.h | 1 + dom/html/HTMLSlotElement.cpp | 4 +- dom/html/HTMLSlotElement.h | 1 + dom/html/HTMLSourceElement.cpp | 8 +++- dom/html/HTMLSourceElement.h | 1 + dom/html/HTMLStyleElement.cpp | 7 ++- dom/html/HTMLStyleElement.h | 1 + dom/html/HTMLTableElement.cpp | 7 ++- dom/html/HTMLTableElement.h | 1 + dom/html/HTMLTextAreaElement.cpp | 7 ++- dom/html/HTMLTextAreaElement.h | 1 + dom/html/nsGenericHTMLElement.cpp | 16 +++++-- dom/html/nsGenericHTMLElement.h | 6 +++ dom/html/nsGenericHTMLFrameElement.cpp | 7 ++- dom/html/nsGenericHTMLFrameElement.h | 1 + dom/mathml/nsMathMLElement.cpp | 7 ++- dom/mathml/nsMathMLElement.h | 1 + dom/svg/SVGAElement.cpp | 4 +- dom/svg/SVGAElement.h | 8 ++-- dom/svg/SVGAnimationElement.cpp | 7 ++- dom/svg/SVGAnimationElement.h | 1 + dom/svg/SVGFEImageElement.cpp | 8 +++- dom/svg/SVGFEImageElement.h | 1 + dom/svg/SVGGeometryElement.cpp | 8 +++- dom/svg/SVGGeometryElement.h | 1 + dom/svg/SVGImageElement.cpp | 8 +++- dom/svg/SVGImageElement.h | 1 + dom/svg/SVGScriptElement.cpp | 8 +++- dom/svg/SVGScriptElement.h | 1 + dom/svg/SVGStyleElement.cpp | 3 +- dom/svg/SVGStyleElement.h | 8 ++-- dom/svg/nsSVGElement.cpp | 8 ++-- dom/svg/nsSVGElement.h | 1 + dom/webidl/AnonymousContent.webidl | 2 +- dom/webidl/Attr.webidl | 2 +- dom/webidl/Element.webidl | 4 +- dom/xul/nsXULElement.cpp | 6 ++- dom/xul/nsXULElement.h | 1 + 88 files changed, 337 insertions(+), 132 deletions(-) diff --git a/dom/base/AnonymousContent.cpp b/dom/base/AnonymousContent.cpp index ffb7597979..6b9f47be18 100644 --- a/dom/base/AnonymousContent.cpp +++ b/dom/base/AnonymousContent.cpp @@ -74,6 +74,7 @@ void AnonymousContent::SetAttributeForElement(const nsAString& aElementId, const nsAString& aName, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, ErrorResult& aRv) { Element* element = GetElementById(aElementId); @@ -82,7 +83,7 @@ AnonymousContent::SetAttributeForElement(const nsAString& aElementId, return; } - element->SetAttribute(aName, aValue, aRv); + element->SetAttribute(aName, aValue, aSubjectPrincipal, aRv); } void diff --git a/dom/base/AnonymousContent.h b/dom/base/AnonymousContent.h index c1c2b189b6..161c117579 100644 --- a/dom/base/AnonymousContent.h +++ b/dom/base/AnonymousContent.h @@ -42,6 +42,7 @@ public: void SetAttributeForElement(const nsAString& aElementId, const nsAString& aName, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, ErrorResult& aRv); void GetAttributeForElement(const nsAString& aElementId, diff --git a/dom/base/Attr.cpp b/dom/base/Attr.cpp index 91e9c1db23..2abe675a52 100644 --- a/dom/base/Attr.cpp +++ b/dom/base/Attr.cpp @@ -174,7 +174,7 @@ Attr::GetValue(nsAString& aValue) } void -Attr::SetValue(const nsAString& aValue, ErrorResult& aRv) +Attr::SetValue(const nsAString& aValue, nsIPrincipal* aTriggeringPrincipal, ErrorResult& aRv) { Element* element = GetElement(); if (!element) { @@ -187,6 +187,7 @@ Attr::SetValue(const nsAString& aValue, ErrorResult& aRv) nameAtom, mNodeInfo->GetPrefixAtom(), aValue, + aTriggeringPrincipal, true); } @@ -194,7 +195,7 @@ NS_IMETHODIMP Attr::SetValue(const nsAString& aValue) { ErrorResult rv; - SetValue(aValue, rv); + SetValue(aValue, nullptr, rv); return rv.StealNSResult(); } diff --git a/dom/base/Attr.h b/dom/base/Attr.h index 154a83102e..5c6fe895a5 100644 --- a/dom/base/Attr.h +++ b/dom/base/Attr.h @@ -84,9 +84,13 @@ public: virtual JSObject* WrapNode(JSContext* aCx, JS::Handle aGivenProto) override; // XPCOM GetName() is OK - // XPCOM GetValue() is OK - void SetValue(const nsAString& aValue, ErrorResult& aRv); + void GetValue(nsString& val, nsIPrincipal&) + { + GetValue(val); + } + + void SetValue(const nsAString& aValue, nsIPrincipal* aTriggeringPrincipal, ErrorResult& aRv); bool Specified() const; diff --git a/dom/base/DocumentFragment.h b/dom/base/DocumentFragment.h index 3ffc8ac0b8..817d37c9dd 100644 --- a/dom/base/DocumentFragment.h +++ b/dom/base/DocumentFragment.h @@ -69,13 +69,10 @@ public: virtual JSObject* WrapNode(JSContext *aCx, JS::Handle aGivenProto) override; // nsIContent - nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - const nsAString& aValue, bool aNotify) - { - return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); - } + using nsIContent::SetAttr; virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override { return NS_OK; diff --git a/dom/base/Element.cpp b/dom/base/Element.cpp index 7522128d46..b03fdd5fbf 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1254,6 +1254,7 @@ Element::ToggleAttribute(const nsAString& aName, void Element::SetAttribute(const nsAString& aName, const nsAString& aValue, + nsIPrincipal* aTriggeringPrincipal, ErrorResult& aError) { aError = nsContentUtils::CheckQName(aName, false); @@ -1269,12 +1270,12 @@ Element::SetAttribute(const nsAString& aName, aError.Throw(NS_ERROR_OUT_OF_MEMORY); return; } - aError = SetAttr(kNameSpaceID_None, nameAtom, aValue, true); + aError = SetAttr(kNameSpaceID_None, nameAtom, aValue, aTriggeringPrincipal, true); return; } aError = SetAttr(name->NamespaceID(), name->LocalName(), name->GetPrefix(), - aValue, true); + aValue, aTriggeringPrincipal, true); return; } @@ -1357,6 +1358,7 @@ void Element::SetAttributeNS(const nsAString& aNamespaceURI, const nsAString& aQualifiedName, const nsAString& aValue, + nsIPrincipal* aTriggeringPrincipal, ErrorResult& aError) { RefPtr ni; @@ -1370,7 +1372,7 @@ Element::SetAttributeNS(const nsAString& aNamespaceURI, } aError = SetAttr(ni->NamespaceID(), ni->NameAtom(), ni->GetPrefixAtom(), - aValue, true); + aValue, aTriggeringPrincipal, true); } void @@ -2419,6 +2421,7 @@ Element::SetSingleClassFromParser(nsIAtom* aSingleClassName) nullptr, // prefix nullptr, // old value value, + nullptr, // subject principal static_cast(nsIDOMMutationEvent::ADDITION), false, // hasListeners false, // notify @@ -2430,6 +2433,7 @@ Element::SetSingleClassFromParser(nsIAtom* aSingleClassName) nsresult Element::SetAttr(int32_t aNamespaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) { // Keep this in sync with SetParsedAttr below and SetSingleClassFromParser @@ -2489,7 +2493,8 @@ Element::SetAttr(int32_t aNamespaceID, nsIAtom* aName, return SetAttrAndNotify(aNamespaceID, aName, aPrefix, oldValueSet ? &oldValue : nullptr, - attrValue, modType, hasListeners, aNotify, + attrValue, aSubjectPrincipal, modType, + hasListeners, aNotify, kCallAfterSetAttr, document, updateBatch); } @@ -2534,7 +2539,7 @@ Element::SetParsedAttr(int32_t aNamespaceID, nsIAtom* aName, mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify); return SetAttrAndNotify(aNamespaceID, aName, aPrefix, oldValueSet ? &oldValue : nullptr, - aParsedValue, modType, hasListeners, aNotify, + aParsedValue, nullptr, modType, hasListeners, aNotify, kCallAfterSetAttr, document, updateBatch); } @@ -2544,6 +2549,7 @@ Element::SetAttrAndNotify(int32_t aNamespaceID, nsIAtom* aPrefix, const nsAttrValue* aOldValue, nsAttrValue& aParsedValue, + nsIPrincipal* aSubjectPrincipal, uint8_t aModType, bool aFireMutation, bool aNotify, @@ -2650,7 +2656,7 @@ Element::SetAttrAndNotify(int32_t aNamespaceID, if (aCallAfterSetAttr) { rv = AfterSetAttr(aNamespaceID, aName, &valueForAfterSetAttr, oldValue, - aNotify); + aSubjectPrincipal, aNotify); NS_ENSURE_SUCCESS(rv, rv); if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::dir) { @@ -2946,7 +2952,7 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsIAtom* aName, } } - rv = AfterSetAttr(aNameSpaceID, aName, nullptr, &oldValue, aNotify); + rv = AfterSetAttr(aNameSpaceID, aName, nullptr, &oldValue, nullptr, aNotify); NS_ENSURE_SUCCESS(rv, rv); UpdateState(aNotify); diff --git a/dom/base/Element.h b/dom/base/Element.h index 4d4c9284d3..22ec00418b 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -542,12 +542,7 @@ public: already_AddRefed GetExistingAttrNameFromQName(const nsAString& aStr) const; - MOZ_ALWAYS_INLINE // Avoid a crashy hook from Avast 10 Beta (Bug 1058131) - nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - const nsAString& aValue, bool aNotify) - { - return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); - } + using nsIContent::SetAttr; /** * Helper for SetAttr/SetParsedAttr. This method will return true if aNotify @@ -610,7 +605,8 @@ public: nsresult SetSingleClassFromParser(nsIAtom* aSingleClassName); virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, - const nsAString& aValue, bool aNotify) override; + const nsAString& aValue, nsIPrincipal* aSubjectPrincipal, + bool aNotify) override; // aParsedValue receives the old value of the attribute. That's useful if // either the input or output value of aParsedValue is StoresOwnData. nsresult SetParsedAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, @@ -783,11 +779,18 @@ public: bool ToggleAttribute(const nsAString& aName, const Optional& aForce, ErrorResult& aError); void SetAttribute(const nsAString& aName, const nsAString& aValue, - ErrorResult& aError); + nsIPrincipal* aTriggeringPrincipal, ErrorResult& aError); void SetAttributeNS(const nsAString& aNamespaceURI, const nsAString& aLocalName, const nsAString& aValue, + nsIPrincipal* aTriggeringPrincipal, ErrorResult& aError); + void SetAttribute(const nsAString& aName, const nsAString& aValue, + ErrorResult& aError) + { + SetAttribute(aName, aValue, nullptr, aError); + } + void RemoveAttribute(const nsAString& aName, ErrorResult& aError); void RemoveAttributeNS(const nsAString& aNamespaceURI, @@ -1232,6 +1235,11 @@ public: aError = SetAttr(kNameSpaceID_None, aAttr, aValue, true); } + void SetAttr(nsIAtom* aAttr, const nsAString& aValue, nsIPrincipal& aTriggeringPrincipal, ErrorResult& aError) + { + aError = nsIContent::SetAttr(kNameSpaceID_None, aAttr, aValue, &aTriggeringPrincipal, true); + } + /** * Set a content attribute via a reflecting nullable string IDL * attribute (e.g. a CORS attribute). If DOMStringIsNull(aValue), @@ -1309,6 +1317,14 @@ protected: * @param aParsedValue parsed new value of attribute. Replaced by the * old value of the attribute. This old value is only * useful if either it or the new value is StoresOwnData. + * @param aMaybeScriptedPrincipal + * the principal of the scripted caller responsible for + * setting the attribute, or null if no scripted caller + * can be determined. A null value here does not + * guarantee that there is no scripted caller, but a + * non-null value does guarantee that a scripted caller + * with the given principal is directly responsible for + * the attribute change. * @param aModType nsIDOMMutationEvent::MODIFICATION or ADDITION. Only * needed if aFireMutation or aNotify is true. * @param aFireMutation should mutation-events be fired? @@ -1321,6 +1337,7 @@ protected: nsIAtom* aPrefix, const nsAttrValue* aOldValue, nsAttrValue& aParsedValue, + nsIPrincipal* aMaybeScriptedPrincipal, uint8_t aModType, bool aFireMutation, bool aNotify, @@ -1412,13 +1429,21 @@ protected: * the attr was not previously set. This argument may not have the * correct value for SVG elements, or other cases in which the * attribute value doesn't store its own data + * @param aMaybeScriptedPrincipal the principal of the scripted caller + * responsible for setting the attribute, or null if no scripted caller + * can be determined, or the attribute is being unset. A null value + * here does not guarantee that there is no scripted caller, but a + * non-null value does guarantee that a scripted caller with the given + * principal is directly responsible for the attribute change. * @param aNotify Whether we plan to notify document observers. */ // Note that this is inlined so that when subclasses call it it gets // inlined. Those calls don't go through a vtable. virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { return NS_OK; } @@ -1801,7 +1826,7 @@ NS_IMETHOD SetAttribute(const nsAString& name, \ const nsAString& value) override \ { \ mozilla::ErrorResult rv; \ - Element::SetAttribute(name, value, rv); \ + Element::SetAttribute(name, value, nullptr, rv); \ return rv.StealNSResult(); \ } \ NS_IMETHOD SetAttributeNS(const nsAString& namespaceURI, \ @@ -1809,22 +1834,22 @@ NS_IMETHOD SetAttributeNS(const nsAString& namespaceURI, \ const nsAString& value) final override \ { \ mozilla::ErrorResult rv; \ - Element::SetAttributeNS(namespaceURI, qualifiedName, value, rv); \ - return rv.StealNSResult(); \ + Element::SetAttributeNS(namespaceURI, qualifiedName, value, nullptr, rv); \ + return rv.StealNSResult(); \ } \ using Element::RemoveAttribute; \ NS_IMETHOD RemoveAttribute(const nsAString& name) final override \ { \ mozilla::ErrorResult rv; \ RemoveAttribute(name, rv); \ - return rv.StealNSResult(); \ + return rv.StealNSResult(); \ } \ NS_IMETHOD RemoveAttributeNS(const nsAString& namespaceURI, \ const nsAString& localName) final override \ { \ mozilla::ErrorResult rv; \ Element::RemoveAttributeNS(namespaceURI, localName, rv); \ - return rv.StealNSResult(); \ + return rv.StealNSResult(); \ } \ using Element::HasAttribute; \ NS_IMETHOD HasAttribute(const nsAString& name, \ @@ -1860,7 +1885,7 @@ NS_IMETHOD SetAttributeNode(nsIDOMAttr* newAttr, \ mozilla::ErrorResult rv; \ mozilla::dom::Attr* attr = static_cast(newAttr); \ *_retval = Element::SetAttributeNode(*attr, rv).take(); \ - return rv.StealNSResult(); \ + return rv.StealNSResult(); \ } \ NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* oldAttr, \ nsIDOMAttr** _retval) final override \ @@ -1871,7 +1896,7 @@ NS_IMETHOD RemoveAttributeNode(nsIDOMAttr* oldAttr, \ mozilla::ErrorResult rv; \ mozilla::dom::Attr* attr = static_cast(oldAttr); \ *_retval = Element::RemoveAttributeNode(*attr, rv).take(); \ - return rv.StealNSResult(); \ + return rv.StealNSResult(); \ } \ NS_IMETHOD GetAttributeNodeNS(const nsAString& namespaceURI, \ const nsAString& localName, \ @@ -1887,7 +1912,7 @@ NS_IMETHOD SetAttributeNodeNS(nsIDOMAttr* newAttr, \ mozilla::ErrorResult rv; \ mozilla::dom::Attr* attr = static_cast(newAttr); \ *_retval = Element::SetAttributeNodeNS(*attr, rv).take(); \ - return rv.StealNSResult(); \ + return rv.StealNSResult(); \ } \ NS_IMETHOD GetElementsByTagName(const nsAString& name, \ nsIDOMHTMLCollection** _retval) final \ @@ -2055,7 +2080,7 @@ NS_IMETHOD ReleaseCapture(void) final override \ NS_IMETHOD MozRequestFullScreen(void) final override \ { \ mozilla::ErrorResult rv; \ - Element::RequestFullscreen(rv); \ + Element::RequestFullscreen(rv); \ return rv.StealNSResult(); \ } \ NS_IMETHOD MozRequestPointerLock(void) final override \ diff --git a/dom/base/nsGenericDOMDataNode.cpp b/dom/base/nsGenericDOMDataNode.cpp index ebb135d88b..85f8833d00 100644 --- a/dom/base/nsGenericDOMDataNode.cpp +++ b/dom/base/nsGenericDOMDataNode.cpp @@ -625,6 +625,7 @@ nsGenericDOMDataNode::GetChildren(uint32_t aFilter) nsresult nsGenericDOMDataNode::SetAttr(int32_t aNameSpaceID, nsIAtom* aAttr, nsIAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aContentPrincipal, bool aNotify) { return NS_OK; diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h index c3e8ae4740..683528efea 100644 --- a/dom/base/nsGenericDOMDataNode.h +++ b/dom/base/nsGenericDOMDataNode.h @@ -117,13 +117,10 @@ public: virtual already_AddRefed GetChildren(uint32_t aFilter) override; - nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, - const nsAString& aValue, bool aNotify) - { - return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); - } + using nsIContent::SetAttr; virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, nsIAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsIAtom* aAttribute, bool aNotify) override; diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h index 4e2f1e09fb..35451444ac 100644 --- a/dom/base/nsIContent.h +++ b/dom/base/nsIContent.h @@ -363,6 +363,16 @@ public: { return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); } + nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, + const nsAString& aValue, bool aNotify) + { + return SetAttr(aNameSpaceID, aName, aPrefix, aValue, nullptr, aNotify); + } + nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAString& aValue, + nsIPrincipal* aTriggeringPrincipal, bool aNotify) + { + return SetAttr(aNameSpaceID, aName, nullptr, aValue, aTriggeringPrincipal, aNotify); + } /** * Set attribute values. All attribute values are assumed to have a @@ -375,11 +385,18 @@ public: * @param aName the name of the attribute * @param aPrefix the prefix of the attribute * @param aValue the value to set + * @param aMaybeScriptedPrincipal the principal of the scripted caller responsible + * for setting the attribute, or null if no scripted caller can be + * determined. A null value here does not guarantee that there is no + * scripted caller, but a non-null value does guarantee that a scripted + * caller with the given principal is directly responsible for the + * attribute change. * @param aNotify specifies how whether or not the document should be * notified of the attribute change. */ virtual nsresult SetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsIAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) = 0; /** diff --git a/dom/base/nsStyledElement.cpp b/dom/base/nsStyledElement.cpp index 4fd423acc7..01c8856444 100644 --- a/dom/base/nsStyledElement.cpp +++ b/dom/base/nsStyledElement.cpp @@ -110,7 +110,8 @@ nsStyledElement::SetInlineStyleDeclaration(css::Declaration* aDeclaration, nsIDocument* document = GetComposedDoc(); mozAutoDocUpdate updateBatch(document, UPDATE_CONTENT_MODEL, aNotify); return SetAttrAndNotify(kNameSpaceID_None, nsGkAtoms::style, nullptr, - oldValueSet ? &oldValue : nullptr, attrValue, modType, + oldValueSet ? &oldValue : nullptr, attrValue, + nullptr, modType, hasListeners, aNotify, kDontCallAfterSetAttr, document, updateBatch); } diff --git a/dom/html/HTMLAnchorElement.cpp b/dom/html/HTMLAnchorElement.cpp index 2fb5ea4677..01e1ab1759 100644 --- a/dom/html/HTMLAnchorElement.cpp +++ b/dom/html/HTMLAnchorElement.cpp @@ -386,7 +386,9 @@ HTMLAnchorElement::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName, nsresult HTMLAnchorElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::href) { @@ -398,7 +400,8 @@ HTMLAnchorElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aSubjectPrincipal, aNotify); } EventStates diff --git a/dom/html/HTMLAnchorElement.h b/dom/html/HTMLAnchorElement.h index c80c823c72..99c37b9676 100644 --- a/dom/html/HTMLAnchorElement.h +++ b/dom/html/HTMLAnchorElement.h @@ -71,6 +71,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult) const override; diff --git a/dom/html/HTMLAreaElement.cpp b/dom/html/HTMLAreaElement.cpp index 89c25f2902..834c13b9ab 100644 --- a/dom/html/HTMLAreaElement.cpp +++ b/dom/html/HTMLAreaElement.cpp @@ -142,7 +142,9 @@ HTMLAreaElement::UnbindFromTree(bool aDeep, bool aNullParent) nsresult HTMLAreaElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { // This must happen after the attribute is set. We will need the updated @@ -155,7 +157,7 @@ HTMLAreaElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } #define IMPL_URI_PART(_part) \ diff --git a/dom/html/HTMLAreaElement.h b/dom/html/HTMLAreaElement.h index 919ba9d60c..083675824a 100644 --- a/dom/html/HTMLAreaElement.h +++ b/dom/html/HTMLAreaElement.h @@ -178,6 +178,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; RefPtr mRelList; diff --git a/dom/html/HTMLButtonElement.cpp b/dom/html/HTMLButtonElement.cpp index 3e48c09d16..853a9db0f4 100644 --- a/dom/html/HTMLButtonElement.cpp +++ b/dom/html/HTMLButtonElement.cpp @@ -438,7 +438,9 @@ HTMLButtonElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsresult HTMLButtonElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::type) { @@ -454,7 +456,7 @@ HTMLButtonElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, return nsGenericHTMLFormElementWithState::AfterSetAttr(aNameSpaceID, aName, aValue, aOldValue, - aNotify); + aSubjectPrincipal, aNotify); } NS_IMETHODIMP diff --git a/dom/html/HTMLButtonElement.h b/dom/html/HTMLButtonElement.h index 139596ae30..3765ce8d12 100644 --- a/dom/html/HTMLButtonElement.h +++ b/dom/html/HTMLButtonElement.h @@ -88,6 +88,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual bool ParseAttribute(int32_t aNamespaceID, nsIAtom* aAttribute, diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 1d6c008240..b7071079ac 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -443,12 +443,14 @@ NS_IMPL_BOOL_ATTR(HTMLCanvasElement, MozOpaque, moz_opaque) nsresult HTMLCanvasElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { AfterMaybeChangeAttr(aNamespaceID, aName, aNotify); return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } nsresult diff --git a/dom/html/HTMLCanvasElement.h b/dom/html/HTMLCanvasElement.h index b84f2eac92..e647cd43a2 100644 --- a/dom/html/HTMLCanvasElement.h +++ b/dom/html/HTMLCanvasElement.h @@ -361,6 +361,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValueOrString& aValue, diff --git a/dom/html/HTMLFieldSetElement.cpp b/dom/html/HTMLFieldSetElement.cpp index 9052d399eb..8cf87f31bc 100644 --- a/dom/html/HTMLFieldSetElement.cpp +++ b/dom/html/HTMLFieldSetElement.cpp @@ -83,7 +83,9 @@ HTMLFieldSetElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) nsresult HTMLFieldSetElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::disabled && nsINode::GetFirstChild()) { @@ -100,7 +102,8 @@ HTMLFieldSetElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, } return nsGenericHTMLFormElement::AfterSetAttr(aNameSpaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aSubjectPrincipal, aNotify); } // nsIDOMHTMLFieldSetElement diff --git a/dom/html/HTMLFieldSetElement.h b/dom/html/HTMLFieldSetElement.h index e56a279c34..80990dc63b 100644 --- a/dom/html/HTMLFieldSetElement.h +++ b/dom/html/HTMLFieldSetElement.h @@ -44,6 +44,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult InsertChildAt(nsIContent* aChild, uint32_t aIndex, diff --git a/dom/html/HTMLFormElement.cpp b/dom/html/HTMLFormElement.cpp index d2b39461f1..c84c1e752e 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -218,7 +218,9 @@ HTMLFormElement::BeforeSetAttr(int32_t aNamespaceID, nsIAtom* aName, nsresult HTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aName == nsGkAtoms::novalidate && aNameSpaceID == kNameSpaceID_None) { // Update all form elements states because they might be [no longer] @@ -235,7 +237,7 @@ HTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } NS_IMPL_STRING_ATTR(HTMLFormElement, AcceptCharset, acceptcharset) diff --git a/dom/html/HTMLFormElement.h b/dom/html/HTMLFormElement.h index 102e24fdf9..b0d355d5a7 100644 --- a/dom/html/HTMLFormElement.h +++ b/dom/html/HTMLFormElement.h @@ -110,6 +110,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; /** diff --git a/dom/html/HTMLIFrameElement.cpp b/dom/html/HTMLIFrameElement.cpp index 8cf19dc9f4..7468b64023 100644 --- a/dom/html/HTMLIFrameElement.cpp +++ b/dom/html/HTMLIFrameElement.cpp @@ -183,7 +183,9 @@ HTMLIFrameElement::GetAttributeMappingFunction() const nsresult HTMLIFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { AfterMaybeChangeAttr(aNameSpaceID, aName, aNotify); @@ -197,8 +199,10 @@ HTMLIFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, } } } - return nsGenericHTMLFrameElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + return nsGenericHTMLFrameElement::AfterSetAttr(aNameSpaceID, aName, + aValue, aOldValue, + aMaybeScriptedPrincipal, + aNotify); } nsresult diff --git a/dom/html/HTMLIFrameElement.h b/dom/html/HTMLIFrameElement.h index e1240de814..5a06a46a2e 100644 --- a/dom/html/HTMLIFrameElement.h +++ b/dom/html/HTMLIFrameElement.h @@ -184,6 +184,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValueOrString& aValue, diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp index b697dcabea..885e653fa4 100644 --- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -393,10 +393,12 @@ HTMLImageElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsresult HTMLImageElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { if (aValue) { - AfterMaybeChangeAttr(aNameSpaceID, aName, aNotify); + AfterMaybeChangeAttr(aNameSpaceID, aName, aMaybeScriptedPrincipal, aNotify); } if (aNameSpaceID == kNameSpaceID_None && mForm && @@ -439,7 +441,9 @@ HTMLImageElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aMaybeScriptedPrincipal, + aNotify); } nsresult @@ -448,7 +452,7 @@ HTMLImageElement::OnAttrSetButNotChanged(int32_t aNamespaceID, nsIAtom* aName, bool aNotify) { BeforeMaybeChangeAttr(aNamespaceID, aName, aValue, aNotify); - AfterMaybeChangeAttr(aNamespaceID, aName, aNotify); + AfterMaybeChangeAttr(aNamespaceID, aName, nullptr, aNotify); return nsGenericHTMLElement::OnAttrSetButNotChanged(aNamespaceID, aName, aValue, aNotify); @@ -530,6 +534,7 @@ HTMLImageElement::BeforeMaybeChangeAttr(int32_t aNamespaceID, nsIAtom* aName, void HTMLImageElement::AfterMaybeChangeAttr(int32_t aNamespaceID, nsIAtom* aName, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) { // Because we load image synchronously in non-responsive-mode, we need to do diff --git a/dom/html/HTMLImageElement.h b/dom/html/HTMLImageElement.h index 3d3c7c834e..748b922499 100644 --- a/dom/html/HTMLImageElement.h +++ b/dom/html/HTMLImageElement.h @@ -337,6 +337,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsIAtom* aName, @@ -378,6 +379,7 @@ private: * @param aNotify Whether we plan to notify document observers. */ void AfterMaybeChangeAttr(int32_t aNamespaceID, nsIAtom* aName, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify); /** * Used by BeforeMaybeChangeAttr and AfterMaybeChangeAttr to keep track of diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 7d9a4db1cd..5761b12e68 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -1285,7 +1285,9 @@ HTMLInputElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsresult HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { // @@ -1436,6 +1438,7 @@ HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, return nsGenericHTMLFormElementWithState::AfterSetAttr(aNameSpaceID, aName, aValue, aOldValue, + aSubjectPrincipal, aNotify); } diff --git a/dom/html/HTMLInputElement.h b/dom/html/HTMLInputElement.h index 44e1f9c1ca..45464f638b 100644 --- a/dom/html/HTMLInputElement.h +++ b/dom/html/HTMLInputElement.h @@ -966,6 +966,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual void ResultForDialogSubmit(nsAString& aResult) override; diff --git a/dom/html/HTMLLinkElement.cpp b/dom/html/HTMLLinkElement.cpp index 8fe317cec0..7b6379ae3f 100644 --- a/dom/html/HTMLLinkElement.cpp +++ b/dom/html/HTMLLinkElement.cpp @@ -357,7 +357,9 @@ HTMLLinkElement::BeforeSetAttr(int32_t aNameSpaceID, nsIAtom* aName, nsresult HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { // It's safe to call ResetLinkState here because our new attr value has // already been set or unset. ResetLinkState needs the updated attribute @@ -451,7 +453,8 @@ HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, + aNotify); } nsresult diff --git a/dom/html/HTMLLinkElement.h b/dom/html/HTMLLinkElement.h index c7742478e3..7eb6b78e18 100644 --- a/dom/html/HTMLLinkElement.h +++ b/dom/html/HTMLLinkElement.h @@ -66,6 +66,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual bool IsLink(nsIURI** aURI) const override; virtual already_AddRefed GetHrefURI() const override; diff --git a/dom/html/HTMLMediaElement.cpp b/dom/html/HTMLMediaElement.cpp index ab93ddff8a..ffd643124f 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -3727,7 +3727,9 @@ int32_t HTMLMediaElement::TabIndexDefault() nsresult HTMLMediaElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::src) { @@ -3769,7 +3771,9 @@ HTMLMediaElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aMaybeScriptedPrincipal, + aNotify); } nsresult diff --git a/dom/html/HTMLMediaElement.h b/dom/html/HTMLMediaElement.h index bda9924a6f..9cdc376e82 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -1301,6 +1301,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValueOrString& aValue, diff --git a/dom/html/HTMLMenuItemElement.cpp b/dom/html/HTMLMenuItemElement.cpp index 42cee132e6..fbd9377298 100644 --- a/dom/html/HTMLMenuItemElement.cpp +++ b/dom/html/HTMLMenuItemElement.cpp @@ -389,7 +389,9 @@ HTMLMenuItemElement::GetText(nsAString& aText) nsresult HTMLMenuItemElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if ((aName == nsGkAtoms::radiogroup || aName == nsGkAtoms::type) && @@ -412,8 +414,10 @@ HTMLMenuItemElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, } } - return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, + aValue, aOldValue, + aSubjectPrincipal, + aNotify); } void diff --git a/dom/html/HTMLMenuItemElement.h b/dom/html/HTMLMenuItemElement.h index 1c738187ce..e3a877a313 100644 --- a/dom/html/HTMLMenuItemElement.h +++ b/dom/html/HTMLMenuItemElement.h @@ -126,6 +126,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; void WalkRadioGroup(Visitor* aVisitor); diff --git a/dom/html/HTMLMetaElement.cpp b/dom/html/HTMLMetaElement.cpp index f0a66b52c1..2a07dad968 100644 --- a/dom/html/HTMLMetaElement.cpp +++ b/dom/html/HTMLMetaElement.cpp @@ -61,7 +61,9 @@ HTMLMetaElement::SetMetaReferrer(nsIDocument* aDocument) nsresult HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { nsIDocument *document = GetUncomposedDoc(); @@ -82,8 +84,10 @@ HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, } } - return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, + aValue, aOldValue, + aSubjectPrincipal, + aNotify); } nsresult diff --git a/dom/html/HTMLMetaElement.h b/dom/html/HTMLMetaElement.h index 649ea11cf1..9fabe36d40 100644 --- a/dom/html/HTMLMetaElement.h +++ b/dom/html/HTMLMetaElement.h @@ -34,6 +34,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; void CreateAndDispatchEvent(nsIDocument* aDoc, const nsAString& aEventName); diff --git a/dom/html/HTMLObjectElement.cpp b/dom/html/HTMLObjectElement.cpp index a77cd6fe57..7dc60949d2 100644 --- a/dom/html/HTMLObjectElement.cpp +++ b/dom/html/HTMLObjectElement.cpp @@ -299,13 +299,16 @@ HTMLObjectElement::UnbindFromTree(bool aDeep, nsresult HTMLObjectElement::AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { nsresult rv = AfterMaybeChangeAttr(aNamespaceID, aName, aNotify); NS_ENSURE_SUCCESS(rv, rv); return nsGenericHTMLFormElement::AfterSetAttr(aNamespaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, + aNotify); } nsresult diff --git a/dom/html/HTMLObjectElement.h b/dom/html/HTMLObjectElement.h index 6f0990918f..6c982b2b19 100644 --- a/dom/html/HTMLObjectElement.h +++ b/dom/html/HTMLObjectElement.h @@ -245,6 +245,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsIAtom* aName, const nsAttrValueOrString& aValue, diff --git a/dom/html/HTMLOptGroupElement.cpp b/dom/html/HTMLOptGroupElement.cpp index a65a79ecf5..49645ad933 100644 --- a/dom/html/HTMLOptGroupElement.cpp +++ b/dom/html/HTMLOptGroupElement.cpp @@ -106,7 +106,9 @@ HTMLOptGroupElement::RemoveChildAt(uint32_t aIndex, bool aNotify) nsresult HTMLOptGroupElement::AfterSetAttr(int32_t aNameSpaceID, nsIAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::disabled) { // All our children