From 4275cd1039e87d19bb3f0b7035cc36f23f656953 Mon Sep 17 00:00:00 2001 From: Kris Maglione Date: Mon, 9 Oct 2017 14:33:38 -0700 Subject: [PATCH] Bug 1406278: Part 1 - Pass subject principal to SetAttribute and friends. r=bz 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, that means capturing the subject principal of the caller who sets those attributes, which means making it available to AfterSetAttr hooks. MozReview-Commit-ID: BMDL2Uepg0X --HG-- extra : rebase_source : 25e438c243700a9368c393e40e3a6002d968d6c8 --- 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 | 45 ++++++++++++++++++++------ dom/base/nsGenericDOMDataNode.cpp | 1 + dom/base/nsGenericDOMDataNode.h | 7 ++-- dom/base/nsIContent.h | 17 ++++++++++ dom/base/nsStyledElement.cpp | 3 +- dom/html/HTMLAnchorElement.cpp | 6 ++-- dom/html/HTMLAnchorElement.h | 1 + dom/html/HTMLAreaElement.cpp | 6 ++-- dom/html/HTMLAreaElement.h | 1 + dom/html/HTMLBodyElement.cpp | 6 ++-- dom/html/HTMLBodyElement.h | 1 + dom/html/HTMLButtonElement.cpp | 6 ++-- dom/html/HTMLButtonElement.h | 1 + dom/html/HTMLCanvasElement.cpp | 6 ++-- dom/html/HTMLCanvasElement.h | 1 + dom/html/HTMLContentElement.cpp | 6 ++-- dom/html/HTMLContentElement.h | 1 + dom/html/HTMLEmbedElement.cpp | 3 +- dom/html/HTMLEmbedElement.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 | 15 ++++++--- dom/html/HTMLImageElement.h | 2 ++ dom/html/HTMLInputElement.cpp | 5 ++- dom/html/HTMLInputElement.h | 1 + dom/html/HTMLLinkElement.cpp | 6 ++-- dom/html/HTMLLinkElement.h | 1 + dom/html/HTMLMediaElement.cpp | 8 +++-- dom/html/HTMLMediaElement.h | 1 + dom/html/HTMLMenuElement.cpp | 6 ++-- dom/html/HTMLMenuElement.h | 1 + dom/html/HTMLMenuItemElement.cpp | 6 ++-- dom/html/HTMLMenuItemElement.h | 1 + dom/html/HTMLMetaElement.cpp | 6 ++-- dom/html/HTMLMetaElement.h | 1 + dom/html/HTMLObjectElement.cpp | 6 ++-- dom/html/HTMLObjectElement.h | 1 + dom/html/HTMLOptGroupElement.cpp | 6 ++-- dom/html/HTMLOptGroupElement.h | 1 + dom/html/HTMLOptionElement.cpp | 6 ++-- 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 | 6 ++-- dom/html/HTMLSharedElement.h | 1 + dom/html/HTMLSourceElement.cpp | 8 +++-- dom/html/HTMLSourceElement.h | 1 + dom/html/HTMLStyleElement.cpp | 6 ++-- dom/html/HTMLStyleElement.h | 1 + dom/html/HTMLTableElement.cpp | 6 ++-- dom/html/HTMLTableElement.h | 1 + dom/html/HTMLTextAreaElement.cpp | 6 ++-- dom/html/HTMLTextAreaElement.h | 1 + dom/html/nsGenericHTMLElement.cpp | 16 ++++++--- dom/html/nsGenericHTMLElement.h | 6 ++++ dom/html/nsGenericHTMLFrameElement.cpp | 6 ++-- dom/html/nsGenericHTMLFrameElement.h | 1 + dom/mathml/nsMathMLElement.cpp | 6 ++-- dom/mathml/nsMathMLElement.h | 1 + dom/svg/SVGAElement.cpp | 3 +- dom/svg/SVGAElement.h | 7 ++-- dom/svg/SVGAnimationElement.cpp | 6 ++-- 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 | 7 ++-- dom/svg/SVGImageElement.h | 1 + dom/svg/SVGScriptElement.cpp | 7 ++-- dom/svg/SVGScriptElement.h | 1 + dom/svg/SVGStyleElement.cpp | 3 +- dom/svg/SVGStyleElement.h | 7 ++-- 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 + 92 files changed, 317 insertions(+), 128 deletions(-) diff --git a/dom/base/AnonymousContent.cpp b/dom/base/AnonymousContent.cpp index 40a5ffe1c36e..fc4fa4128213 100644 --- a/dom/base/AnonymousContent.cpp +++ b/dom/base/AnonymousContent.cpp @@ -75,6 +75,7 @@ void AnonymousContent::SetAttributeForElement(const nsAString& aElementId, const nsAString& aName, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, ErrorResult& aRv) { Element* element = GetElementById(aElementId); @@ -83,7 +84,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 b56c145956f6..0ef3ce467edc 100644 --- a/dom/base/AnonymousContent.h +++ b/dom/base/AnonymousContent.h @@ -43,6 +43,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 ebd48d03e1fa..d61c5275cb90 100644 --- a/dom/base/Attr.cpp +++ b/dom/base/Attr.cpp @@ -175,7 +175,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) { @@ -188,6 +188,7 @@ Attr::SetValue(const nsAString& aValue, ErrorResult& aRv) nameAtom, mNodeInfo->GetPrefixAtom(), aValue, + aTriggeringPrincipal, true); } @@ -195,7 +196,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 017aa6f80a1a..43c7ef964964 100644 --- a/dom/base/Attr.h +++ b/dom/base/Attr.h @@ -85,9 +85,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 bc5c4f2ccf09..541c1c3b42cf 100644 --- a/dom/base/DocumentFragment.h +++ b/dom/base/DocumentFragment.h @@ -70,13 +70,10 @@ public: virtual JSObject* WrapNode(JSContext *aCx, JS::Handle aGivenProto) override; // nsIContent - nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, - const nsAString& aValue, bool aNotify) - { - return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); - } + using nsIContent::SetAttr; virtual nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, nsAtom* 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 2bf2a24a0676..8672d8ec5185 100644 --- a/dom/base/Element.cpp +++ b/dom/base/Element.cpp @@ -1297,6 +1297,7 @@ Element::GetAttribute(const nsAString& aName, DOMString& aReturn) void Element::SetAttribute(const nsAString& aName, const nsAString& aValue, + nsIPrincipal* aTriggeringPrincipal, ErrorResult& aError) { aError = nsContentUtils::CheckQName(aName, false); @@ -1312,12 +1313,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); } void @@ -1393,6 +1394,7 @@ void Element::SetAttributeNS(const nsAString& aNamespaceURI, const nsAString& aQualifiedName, const nsAString& aValue, + nsIPrincipal* aTriggeringPrincipal, ErrorResult& aError) { RefPtr ni; @@ -1406,7 +1408,7 @@ Element::SetAttributeNS(const nsAString& aNamespaceURI, } aError = SetAttr(ni->NamespaceID(), ni->NameAtom(), ni->GetPrefixAtom(), - aValue, true); + aValue, aTriggeringPrincipal, true); } void @@ -2462,6 +2464,7 @@ Element::SetSingleClassFromParser(nsAtom* aSingleClassName) nullptr, // prefix nullptr, // old value value, + nullptr, static_cast(nsIDOMMutationEvent::ADDITION), false, // hasListeners false, // notify @@ -2473,6 +2476,7 @@ Element::SetSingleClassFromParser(nsAtom* aSingleClassName) nsresult Element::SetAttr(int32_t aNamespaceID, nsAtom* aName, nsAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) { // Keep this in sync with SetParsedAttr below and SetSingleClassFromParser @@ -2532,7 +2536,8 @@ Element::SetAttr(int32_t aNamespaceID, nsAtom* aName, return SetAttrAndNotify(aNamespaceID, aName, aPrefix, oldValueSet ? &oldValue : nullptr, - attrValue, modType, hasListeners, aNotify, + attrValue, aSubjectPrincipal, modType, + hasListeners, aNotify, kCallAfterSetAttr, document, updateBatch); } @@ -2577,7 +2582,7 @@ Element::SetParsedAttr(int32_t aNamespaceID, nsAtom* 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); } @@ -2587,6 +2592,7 @@ Element::SetAttrAndNotify(int32_t aNamespaceID, nsAtom* aPrefix, const nsAttrValue* aOldValue, nsAttrValue& aParsedValue, + nsIPrincipal* aSubjectPrincipal, uint8_t aModType, bool aFireMutation, bool aNotify, @@ -2689,7 +2695,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) { @@ -2982,7 +2988,7 @@ Element::UnsetAttr(int32_t aNameSpaceID, nsAtom* 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 eba168de510d..cdf50f0c67a4 100644 --- a/dom/base/Element.h +++ b/dom/base/Element.h @@ -691,12 +691,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, nsAtom* 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 @@ -758,7 +753,8 @@ public: nsresult SetSingleClassFromParser(nsAtom* aSingleClassName); virtual nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, nsAtom* 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, nsAtom* aName, nsAtom* aPrefix, @@ -929,11 +925,18 @@ public: const nsAString& aLocalName, nsAString& aReturn); 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, @@ -1399,6 +1402,11 @@ public: aError = SetAttr(kNameSpaceID_None, aAttr, aValue, true); } + void SetAttr(nsAtom* 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), @@ -1478,6 +1486,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? @@ -1490,6 +1506,7 @@ protected: nsAtom* aPrefix, const nsAttrValue* aOldValue, nsAttrValue& aParsedValue, + nsIPrincipal* aMaybeScriptedPrincipal, uint8_t aModType, bool aFireMutation, bool aNotify, @@ -1579,13 +1596,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, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { return NS_OK; } @@ -1968,7 +1993,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(); \ } \ using Element::HasAttribute; \ diff --git a/dom/base/nsGenericDOMDataNode.cpp b/dom/base/nsGenericDOMDataNode.cpp index 23e79f017a82..6d2391818d55 100644 --- a/dom/base/nsGenericDOMDataNode.cpp +++ b/dom/base/nsGenericDOMDataNode.cpp @@ -639,6 +639,7 @@ nsGenericDOMDataNode::GetChildren(uint32_t aFilter) nsresult nsGenericDOMDataNode::SetAttr(int32_t aNameSpaceID, nsAtom* aAttr, nsAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aContentPrincipal, bool aNotify) { return NS_OK; diff --git a/dom/base/nsGenericDOMDataNode.h b/dom/base/nsGenericDOMDataNode.h index 3832bc10464d..d2442a63630e 100644 --- a/dom/base/nsGenericDOMDataNode.h +++ b/dom/base/nsGenericDOMDataNode.h @@ -127,13 +127,10 @@ public: virtual already_AddRefed GetChildren(uint32_t aFilter) override; - nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, - const nsAString& aValue, bool aNotify) - { - return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); - } + using nsIContent::SetAttr; virtual nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aAttribute, nsAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsAtom* aAttribute, bool aNotify) override; diff --git a/dom/base/nsIContent.h b/dom/base/nsIContent.h index 01fd9c81f597..a3365c5e7f03 100644 --- a/dom/base/nsIContent.h +++ b/dom/base/nsIContent.h @@ -373,6 +373,16 @@ public: { return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); } + nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, nsAtom* aPrefix, + const nsAString& aValue, bool aNotify) + { + return SetAttr(aNameSpaceID, aName, aPrefix, aValue, nullptr, aNotify); + } + nsresult SetAttr(int32_t aNameSpaceID, nsAtom* 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 @@ -385,11 +395,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, nsAtom* aName, nsAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) = 0; /** diff --git a/dom/base/nsStyledElement.cpp b/dom/base/nsStyledElement.cpp index 497358bd83fa..158994252b03 100644 --- a/dom/base/nsStyledElement.cpp +++ b/dom/base/nsStyledElement.cpp @@ -109,7 +109,8 @@ nsStyledElement::SetInlineStyleDeclaration(DeclarationBlock* 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 49bc4bf01c2b..f51c3c8b7216 100644 --- a/dom/html/HTMLAnchorElement.cpp +++ b/dom/html/HTMLAnchorElement.cpp @@ -315,7 +315,9 @@ HTMLAnchorElement::BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName, nsresult HTMLAnchorElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::href) { @@ -327,7 +329,7 @@ HTMLAnchorElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* 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 72b2e40015dd..33ecff0088a2 100644 --- a/dom/html/HTMLAnchorElement.h +++ b/dom/html/HTMLAnchorElement.h @@ -69,6 +69,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult, diff --git a/dom/html/HTMLAreaElement.cpp b/dom/html/HTMLAreaElement.cpp index ccd2eea3b68e..87223ef58a1c 100644 --- a/dom/html/HTMLAreaElement.cpp +++ b/dom/html/HTMLAreaElement.cpp @@ -120,7 +120,9 @@ HTMLAreaElement::UnbindFromTree(bool aDeep, bool aNullParent) nsresult HTMLAreaElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* 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 @@ -133,7 +135,7 @@ HTMLAreaElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } void diff --git a/dom/html/HTMLAreaElement.h b/dom/html/HTMLAreaElement.h index adb039977fb0..61e13876fc0b 100644 --- a/dom/html/HTMLAreaElement.h +++ b/dom/html/HTMLAreaElement.h @@ -202,6 +202,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; RefPtr mRelList; diff --git a/dom/html/HTMLBodyElement.cpp b/dom/html/HTMLBodyElement.cpp index 5c28047c868b..baf8634295dc 100644 --- a/dom/html/HTMLBodyElement.cpp +++ b/dom/html/HTMLBodyElement.cpp @@ -340,11 +340,13 @@ HTMLBodyElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsresult HTMLBodyElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { nsresult rv = nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, aOldValue, - aNotify); + aSubjectPrincipal, aNotify); NS_ENSURE_SUCCESS(rv, rv); // if the last mapped attribute was removed, don't clear the // nsMappedAttributes, our style can still depend on the containing frame element diff --git a/dom/html/HTMLBodyElement.h b/dom/html/HTMLBodyElement.h index d824530d4dbf..475b5088e936 100644 --- a/dom/html/HTMLBodyElement.h +++ b/dom/html/HTMLBodyElement.h @@ -145,6 +145,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; protected: diff --git a/dom/html/HTMLButtonElement.cpp b/dom/html/HTMLButtonElement.cpp index 5a87e089d60a..4605193a8d30 100644 --- a/dom/html/HTMLButtonElement.cpp +++ b/dom/html/HTMLButtonElement.cpp @@ -412,7 +412,9 @@ HTMLButtonElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName, nsresult HTMLButtonElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::type) { @@ -436,7 +438,7 @@ HTMLButtonElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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 ca6d92fb38fe..4ff8780e0a8b 100644 --- a/dom/html/HTMLButtonElement.h +++ b/dom/html/HTMLButtonElement.h @@ -84,6 +84,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute, diff --git a/dom/html/HTMLCanvasElement.cpp b/dom/html/HTMLCanvasElement.cpp index 866fb0136320..da91cc9b7576 100644 --- a/dom/html/HTMLCanvasElement.cpp +++ b/dom/html/HTMLCanvasElement.cpp @@ -460,12 +460,14 @@ HTMLCanvasElement::GetWidthHeight() nsresult HTMLCanvasElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* 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 41996a470378..9758d97b3651 100644 --- a/dom/html/HTMLCanvasElement.h +++ b/dom/html/HTMLCanvasElement.h @@ -363,6 +363,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, diff --git a/dom/html/HTMLContentElement.cpp b/dom/html/HTMLContentElement.cpp index f51866394670..0ec38176b841 100644 --- a/dom/html/HTMLContentElement.cpp +++ b/dom/html/HTMLContentElement.cpp @@ -209,7 +209,9 @@ IsValidContentSelectors(nsCSSSelector* aSelector) nsresult HTMLContentElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNamespaceID == kNameSpaceID_None && aName == nsGkAtoms::select) { if (aValue) { @@ -263,7 +265,7 @@ HTMLContentElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } bool diff --git a/dom/html/HTMLContentElement.h b/dom/html/HTMLContentElement.h index 6d4f8de4b0b5..beb583da8b25 100644 --- a/dom/html/HTMLContentElement.h +++ b/dom/html/HTMLContentElement.h @@ -92,6 +92,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; /** diff --git a/dom/html/HTMLEmbedElement.cpp b/dom/html/HTMLEmbedElement.cpp index b7c6c5e048c4..a21c5d94bef2 100644 --- a/dom/html/HTMLEmbedElement.cpp +++ b/dom/html/HTMLEmbedElement.cpp @@ -135,6 +135,7 @@ nsresult HTMLEmbedElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) { if (aValue) { @@ -143,7 +144,7 @@ HTMLEmbedElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } nsresult diff --git a/dom/html/HTMLEmbedElement.h b/dom/html/HTMLEmbedElement.h index a885c3398809..63bd33fcc003 100644 --- a/dom/html/HTMLEmbedElement.h +++ b/dom/html/HTMLEmbedElement.h @@ -135,6 +135,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, diff --git a/dom/html/HTMLFieldSetElement.cpp b/dom/html/HTMLFieldSetElement.cpp index 08b1d623b8ec..3a9a533e4eab 100644 --- a/dom/html/HTMLFieldSetElement.cpp +++ b/dom/html/HTMLFieldSetElement.cpp @@ -70,7 +70,9 @@ HTMLFieldSetElement::GetEventTargetParent(EventChainPreVisitor& aVisitor) nsresult HTMLFieldSetElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::disabled) { // This *has* to be called *before* calling FieldSetDisabledChanged on our @@ -92,7 +94,8 @@ HTMLFieldSetElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLFormElement::AfterSetAttr(aNameSpaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aSubjectPrincipal, aNotify); } NS_IMETHODIMP diff --git a/dom/html/HTMLFieldSetElement.h b/dom/html/HTMLFieldSetElement.h index 60040f3debe3..4f429b404825 100644 --- a/dom/html/HTMLFieldSetElement.h +++ b/dom/html/HTMLFieldSetElement.h @@ -38,6 +38,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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 f997499e855d..9fdc8165ed86 100644 --- a/dom/html/HTMLFormElement.cpp +++ b/dom/html/HTMLFormElement.cpp @@ -211,7 +211,9 @@ HTMLFormElement::BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName, nsresult HTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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] @@ -228,7 +230,7 @@ HTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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 39c329bef85e..6012cd55b046 100644 --- a/dom/html/HTMLFormElement.h +++ b/dom/html/HTMLFormElement.h @@ -113,6 +113,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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 9bbde4742e9f..096cc06186fe 100644 --- a/dom/html/HTMLIFrameElement.cpp +++ b/dom/html/HTMLIFrameElement.cpp @@ -136,7 +136,9 @@ HTMLIFrameElement::GetAttributeMappingFunction() const nsresult HTMLIFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { AfterMaybeChangeAttr(aNameSpaceID, aName, aNotify); @@ -150,8 +152,10 @@ HTMLIFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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 b9f19e9ce635..a45780dbe622 100644 --- a/dom/html/HTMLIFrameElement.h +++ b/dom/html/HTMLIFrameElement.h @@ -195,6 +195,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, diff --git a/dom/html/HTMLImageElement.cpp b/dom/html/HTMLImageElement.cpp index ce71793d85b6..b2a6f8be3ab8 100644 --- a/dom/html/HTMLImageElement.cpp +++ b/dom/html/HTMLImageElement.cpp @@ -318,13 +318,15 @@ HTMLImageElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName, nsresult HTMLImageElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { nsAttrValueOrString attrVal(aValue); if (aValue) { - AfterMaybeChangeAttr(aNameSpaceID, aName, attrVal, aOldValue, true, - aNotify); + AfterMaybeChangeAttr(aNameSpaceID, aName, attrVal, aOldValue, + aMaybeScriptedPrincipal, true, aNotify); } if (aNameSpaceID == kNameSpaceID_None && mForm && @@ -377,7 +379,9 @@ HTMLImageElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aMaybeScriptedPrincipal, + aNotify); } nsresult @@ -385,7 +389,7 @@ HTMLImageElement::OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, bool aNotify) { - AfterMaybeChangeAttr(aNamespaceID, aName, aValue, nullptr, false, aNotify); + AfterMaybeChangeAttr(aNamespaceID, aName, aValue, nullptr, nullptr, false, aNotify); return nsGenericHTMLElement::OnAttrSetButNotChanged(aNamespaceID, aName, aValue, aNotify); @@ -395,6 +399,7 @@ void HTMLImageElement::AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aValueMaybeChanged, bool aNotify) { bool forceReload = false; diff --git a/dom/html/HTMLImageElement.h b/dom/html/HTMLImageElement.h index 04e1e719209d..a387d8c1ce1d 100644 --- a/dom/html/HTMLImageElement.h +++ b/dom/html/HTMLImageElement.h @@ -379,6 +379,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, @@ -420,6 +421,7 @@ private: void AfterMaybeChangeAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aValueMaybeChanged, bool aNotify); bool mInDocResponsiveContent; diff --git a/dom/html/HTMLInputElement.cpp b/dom/html/HTMLInputElement.cpp index 06fa857dfbe3..096bf2395601 100644 --- a/dom/html/HTMLInputElement.cpp +++ b/dom/html/HTMLInputElement.cpp @@ -1376,7 +1376,9 @@ HTMLInputElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName, nsresult HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { // @@ -1520,6 +1522,7 @@ HTMLInputElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, return nsGenericHTMLFormElementWithState::AfterSetAttr(aNameSpaceID, aName, aValue, aOldValue, + aSubjectPrincipal, aNotify); } diff --git a/dom/html/HTMLInputElement.h b/dom/html/HTMLInputElement.h index 3ed43e7102d8..e27430aa451e 100644 --- a/dom/html/HTMLInputElement.h +++ b/dom/html/HTMLInputElement.h @@ -1075,6 +1075,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual void BeforeSetForm(bool aBindToTree) override; diff --git a/dom/html/HTMLLinkElement.cpp b/dom/html/HTMLLinkElement.cpp index dd5c1a3171ae..a47ec80b2273 100644 --- a/dom/html/HTMLLinkElement.cpp +++ b/dom/html/HTMLLinkElement.cpp @@ -267,7 +267,9 @@ HTMLLinkElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName, nsresult HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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 @@ -338,7 +340,7 @@ HTMLLinkElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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 de2b992bfb96..daa6bcf33680 100644 --- a/dom/html/HTMLLinkElement.h +++ b/dom/html/HTMLLinkElement.h @@ -60,6 +60,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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 c19b8a6ed383..1c695f7c553b 100644 --- a/dom/html/HTMLMediaElement.cpp +++ b/dom/html/HTMLMediaElement.cpp @@ -4449,7 +4449,9 @@ int32_t HTMLMediaElement::TabIndexDefault() nsresult HTMLMediaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::src) { @@ -4495,7 +4497,9 @@ HTMLMediaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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 5f6c63de4145..5db1cbb3de4a 100644 --- a/dom/html/HTMLMediaElement.h +++ b/dom/html/HTMLMediaElement.h @@ -1332,6 +1332,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, diff --git a/dom/html/HTMLMenuElement.cpp b/dom/html/HTMLMenuElement.cpp index 046b2cb1fa82..598995817562 100644 --- a/dom/html/HTMLMenuElement.cpp +++ b/dom/html/HTMLMenuElement.cpp @@ -108,7 +108,9 @@ HTMLMenuElement::Build(nsIMenuBuilder* aBuilder) nsresult HTMLMenuElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::type) { if (aValue) { @@ -119,7 +121,7 @@ HTMLMenuElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } bool diff --git a/dom/html/HTMLMenuElement.h b/dom/html/HTMLMenuElement.h index 7134e70cf96f..fce9170eb5e1 100644 --- a/dom/html/HTMLMenuElement.h +++ b/dom/html/HTMLMenuElement.h @@ -28,6 +28,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute, diff --git a/dom/html/HTMLMenuItemElement.cpp b/dom/html/HTMLMenuItemElement.cpp index 122d6f1f5d14..16c36174ca79 100644 --- a/dom/html/HTMLMenuItemElement.cpp +++ b/dom/html/HTMLMenuItemElement.cpp @@ -375,7 +375,9 @@ HTMLMenuItemElement::GetText(nsAString& aText) nsresult HTMLMenuItemElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { // Handle type changes first, since some of the later conditions in this @@ -409,7 +411,7 @@ HTMLMenuItemElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } void diff --git a/dom/html/HTMLMenuItemElement.h b/dom/html/HTMLMenuItemElement.h index d85da6c87311..5ecc84be1595 100644 --- a/dom/html/HTMLMenuItemElement.h +++ b/dom/html/HTMLMenuItemElement.h @@ -128,6 +128,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* 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 b069cf6fc4ea..b03b58162181 100644 --- a/dom/html/HTMLMetaElement.cpp +++ b/dom/html/HTMLMetaElement.cpp @@ -55,7 +55,9 @@ HTMLMetaElement::SetMetaReferrer(nsIDocument* aDocument) nsresult HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { nsIDocument *document = GetUncomposedDoc(); @@ -77,7 +79,7 @@ HTMLMetaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } nsresult diff --git a/dom/html/HTMLMetaElement.h b/dom/html/HTMLMetaElement.h index e754fb25fc22..793bb363df3e 100644 --- a/dom/html/HTMLMetaElement.h +++ b/dom/html/HTMLMetaElement.h @@ -30,6 +30,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* 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 73581dde24e7..9e343387fe7e 100644 --- a/dom/html/HTMLObjectElement.cpp +++ b/dom/html/HTMLObjectElement.cpp @@ -283,13 +283,15 @@ HTMLObjectElement::UnbindFromTree(bool aDeep, nsresult HTMLObjectElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* 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 d1259eafb807..10e2cddfd162 100644 --- a/dom/html/HTMLObjectElement.h +++ b/dom/html/HTMLObjectElement.h @@ -253,6 +253,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, diff --git a/dom/html/HTMLOptGroupElement.cpp b/dom/html/HTMLOptGroupElement.cpp index 00921ab506cb..a988aa62e1f4 100644 --- a/dom/html/HTMLOptGroupElement.cpp +++ b/dom/html/HTMLOptGroupElement.cpp @@ -98,7 +98,9 @@ HTMLOptGroupElement::RemoveChildAt(uint32_t aIndex, bool aNotify) nsresult HTMLOptGroupElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None && aName == nsGkAtoms::disabled) { @@ -127,7 +129,7 @@ HTMLOptGroupElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } JSObject* diff --git a/dom/html/HTMLOptGroupElement.h b/dom/html/HTMLOptGroupElement.h index 4cc9068c4f7a..0da1e827dba0 100644 --- a/dom/html/HTMLOptGroupElement.h +++ b/dom/html/HTMLOptGroupElement.h @@ -39,6 +39,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsIDOMNode* AsDOMNode() override { return this; } diff --git a/dom/html/HTMLOptionElement.cpp b/dom/html/HTMLOptionElement.cpp index 1f47c52cc7a0..6855c5d5c72a 100644 --- a/dom/html/HTMLOptionElement.cpp +++ b/dom/html/HTMLOptionElement.cpp @@ -265,7 +265,9 @@ HTMLOptionElement::BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName, nsresult HTMLOptionElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::disabled) { @@ -284,7 +286,7 @@ HTMLOptionElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, aSubjectPrincipal, aNotify); } NS_IMETHODIMP diff --git a/dom/html/HTMLOptionElement.h b/dom/html/HTMLOptionElement.h index 7c5b7b67cd26..7cc208e703f3 100644 --- a/dom/html/HTMLOptionElement.h +++ b/dom/html/HTMLOptionElement.h @@ -58,6 +58,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; void SetSelectedInternal(bool aValue, bool aNotify); diff --git a/dom/html/HTMLScriptElement.cpp b/dom/html/HTMLScriptElement.cpp index 06835f4c7e7a..b74871160143 100644 --- a/dom/html/HTMLScriptElement.cpp +++ b/dom/html/HTMLScriptElement.cpp @@ -235,13 +235,17 @@ HTMLScriptElement::SetNoModule(bool aValue, ErrorResult& aRv) nsresult HTMLScriptElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { if (nsGkAtoms::async == aName && kNameSpaceID_None == aNamespaceID) { mForceAsync = false; } - return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, aValue, - aOldValue, aNotify); + return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, + aValue, aOldValue, + aMaybeScriptedPrincipal, + aNotify); } NS_IMETHODIMP diff --git a/dom/html/HTMLScriptElement.h b/dom/html/HTMLScriptElement.h index e89814e664e3..f6edf5397ffc 100644 --- a/dom/html/HTMLScriptElement.h +++ b/dom/html/HTMLScriptElement.h @@ -59,6 +59,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override; // WebIDL diff --git a/dom/html/HTMLSelectElement.cpp b/dom/html/HTMLSelectElement.cpp index a70feac56a37..80d76e60a768 100644 --- a/dom/html/HTMLSelectElement.cpp +++ b/dom/html/HTMLSelectElement.cpp @@ -1316,7 +1316,9 @@ HTMLSelectElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName, nsresult HTMLSelectElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::disabled) { @@ -1349,6 +1351,7 @@ HTMLSelectElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, return nsGenericHTMLFormElementWithState::AfterSetAttr(aNameSpaceID, aName, aValue, aOldValue, + aSubjectPrincipal, aNotify); } diff --git a/dom/html/HTMLSelectElement.h b/dom/html/HTMLSelectElement.h index 13d937a2064f..778882820e66 100644 --- a/dom/html/HTMLSelectElement.h +++ b/dom/html/HTMLSelectElement.h @@ -386,6 +386,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual void DoneAddingChildren(bool aHaveNotified) override; diff --git a/dom/html/HTMLSharedElement.cpp b/dom/html/HTMLSharedElement.cpp index 0b8ae1eaeea1..f013f594e6bf 100644 --- a/dom/html/HTMLSharedElement.cpp +++ b/dom/html/HTMLSharedElement.cpp @@ -228,7 +228,9 @@ SetBaseTargetUsingFirstBaseWithTarget(nsIDocument* aDocument, nsresult HTMLSharedElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::href) { @@ -252,7 +254,7 @@ HTMLSharedElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNamespaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } nsresult diff --git a/dom/html/HTMLSharedElement.h b/dom/html/HTMLSharedElement.h index aa74cde92738..b429ea71c289 100644 --- a/dom/html/HTMLSharedElement.h +++ b/dom/html/HTMLSharedElement.h @@ -167,6 +167,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; }; diff --git a/dom/html/HTMLSourceElement.cpp b/dom/html/HTMLSourceElement.cpp index cc97a5a9cbce..829178f023e9 100644 --- a/dom/html/HTMLSourceElement.cpp +++ b/dom/html/HTMLSourceElement.cpp @@ -96,7 +96,9 @@ HTMLSourceElement::UpdateMediaList(const nsAttrValue* aValue) nsresult HTMLSourceElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { // If we are associated with a with a valid , notify it of // responsive parameter changes @@ -141,7 +143,9 @@ HTMLSourceElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aMaybeScriptedPrincipal, + aNotify); } nsresult diff --git a/dom/html/HTMLSourceElement.h b/dom/html/HTMLSourceElement.h index c15c5c52035c..a3a164f36f75 100644 --- a/dom/html/HTMLSourceElement.h +++ b/dom/html/HTMLSourceElement.h @@ -113,6 +113,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override; private: diff --git a/dom/html/HTMLStyleElement.cpp b/dom/html/HTMLStyleElement.cpp index 08f000019ecf..471280a597d4 100644 --- a/dom/html/HTMLStyleElement.cpp +++ b/dom/html/HTMLStyleElement.cpp @@ -143,7 +143,9 @@ HTMLStyleElement::UnbindFromTree(bool aDeep, bool aNullParent) nsresult HTMLStyleElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::title || @@ -158,7 +160,7 @@ HTMLStyleElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } NS_IMETHODIMP diff --git a/dom/html/HTMLStyleElement.h b/dom/html/HTMLStyleElement.h index 8ee9dabbef2f..6154f6e13513 100644 --- a/dom/html/HTMLStyleElement.h +++ b/dom/html/HTMLStyleElement.h @@ -44,6 +44,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult Clone(mozilla::dom::NodeInfo *aNodeInfo, nsINode **aResult, diff --git a/dom/html/HTMLTableElement.cpp b/dom/html/HTMLTableElement.cpp index 542d6d828b46..9fc0a9550c93 100644 --- a/dom/html/HTMLTableElement.cpp +++ b/dom/html/HTMLTableElement.cpp @@ -1196,13 +1196,15 @@ HTMLTableElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName, nsresult HTMLTableElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aName == nsGkAtoms::cellpadding && aNameSpaceID == kNameSpaceID_None) { BuildInheritedAttributes(); } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } } // namespace dom diff --git a/dom/html/HTMLTableElement.h b/dom/html/HTMLTableElement.h index 428cff1d1e90..b3a3f7892940 100644 --- a/dom/html/HTMLTableElement.h +++ b/dom/html/HTMLTableElement.h @@ -209,6 +209,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; NS_DECL_CYCLE_COLLECTION_CLASS_INHERITED(HTMLTableElement, diff --git a/dom/html/HTMLTextAreaElement.cpp b/dom/html/HTMLTextAreaElement.cpp index b898888946eb..a11ce27f3ba0 100644 --- a/dom/html/HTMLTextAreaElement.cpp +++ b/dom/html/HTMLTextAreaElement.cpp @@ -1072,7 +1072,9 @@ HTMLTextAreaElement::ContentChanged(nsIContent* aContent) nsresult HTMLTextAreaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::required || aName == nsGkAtoms::disabled || @@ -1105,7 +1107,7 @@ HTMLTextAreaElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLFormElementWithState::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } nsresult diff --git a/dom/html/HTMLTextAreaElement.h b/dom/html/HTMLTextAreaElement.h index a96725d22e43..5e001fd0b79c 100644 --- a/dom/html/HTMLTextAreaElement.h +++ b/dom/html/HTMLTextAreaElement.h @@ -371,6 +371,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom *aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; /** diff --git a/dom/html/nsGenericHTMLElement.cpp b/dom/html/nsGenericHTMLElement.cpp index 3bd3dbd92748..40ff3dc009f2 100644 --- a/dom/html/nsGenericHTMLElement.cpp +++ b/dom/html/nsGenericHTMLElement.cpp @@ -699,7 +699,9 @@ nsGenericHTMLElement::BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName, nsresult nsGenericHTMLElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { if (IsEventAttributeName(aName) && aValue) { @@ -790,7 +792,9 @@ nsGenericHTMLElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, } return nsGenericHTMLElementBase::AfterSetAttr(aNamespaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aMaybeScriptedPrincipal, + aNotify); } EventListenerManager* @@ -1995,7 +1999,9 @@ nsGenericHTMLFormElement::BeforeSetAttr(int32_t aNameSpaceID, nsAtom* aName, nsresult nsGenericHTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, + bool aNotify) { if (aNameSpaceID == kNameSpaceID_None) { // add the control to the hashtable as needed @@ -2044,7 +2050,9 @@ nsGenericHTMLFormElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aMaybeScriptedPrincipal, + aNotify); } nsresult diff --git a/dom/html/nsGenericHTMLElement.h b/dom/html/nsGenericHTMLElement.h index 00031bcfa71c..1c5043bf72e2 100644 --- a/dom/html/nsGenericHTMLElement.h +++ b/dom/html/nsGenericHTMLElement.h @@ -764,6 +764,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override; virtual mozilla::EventListenerManager* @@ -809,6 +810,10 @@ protected: { mozilla::dom::Element::SetAttr(aName, aValue, aError); } + void SetHTMLAttr(nsAtom* aName, const nsAString& aValue, nsIPrincipal& aTriggeringPrincipal, mozilla::ErrorResult& aError) + { + mozilla::dom::Element::SetAttr(aName, aValue, aTriggeringPrincipal, aError); + } void UnsetHTMLAttr(nsAtom* aName, mozilla::ErrorResult& aError) { mozilla::dom::Element::UnsetAttr(aName, aError); @@ -1137,6 +1142,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aMaybeScriptedPrincipal, bool aNotify) override; virtual void BeforeSetForm(bool aBindToTree) {} diff --git a/dom/html/nsGenericHTMLFrameElement.cpp b/dom/html/nsGenericHTMLFrameElement.cpp index 3c2e305376e4..f773f063a9c7 100644 --- a/dom/html/nsGenericHTMLFrameElement.cpp +++ b/dom/html/nsGenericHTMLFrameElement.cpp @@ -331,7 +331,9 @@ PrincipalAllowsBrowserFrame(nsIPrincipal* aPrincipal) /* virtual */ nsresult nsGenericHTMLFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aValue) { nsAttrValueOrString value(aValue); @@ -370,7 +372,7 @@ nsGenericHTMLFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsGenericHTMLElement::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } nsresult diff --git a/dom/html/nsGenericHTMLFrameElement.h b/dom/html/nsGenericHTMLFrameElement.h index 9979455f7f97..ee807ab4180a 100644 --- a/dom/html/nsGenericHTMLFrameElement.h +++ b/dom/html/nsGenericHTMLFrameElement.h @@ -103,6 +103,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult OnAttrSetButNotChanged(int32_t aNamespaceID, nsAtom* aName, const nsAttrValueOrString& aValue, diff --git a/dom/mathml/nsMathMLElement.cpp b/dom/mathml/nsMathMLElement.cpp index a4dd08270dfd..b276d7a14916 100644 --- a/dom/mathml/nsMathMLElement.cpp +++ b/dom/mathml/nsMathMLElement.cpp @@ -1085,7 +1085,9 @@ nsMathMLElement::GetHrefURI() const nsresult nsMathMLElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { // It is important that this be done after the attribute is set/unset. // We will need the updated attribute value because notifying the document @@ -1103,7 +1105,7 @@ nsMathMLElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, } return nsMathMLElementBase::AfterSetAttr(aNameSpaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); } JSObject* diff --git a/dom/mathml/nsMathMLElement.h b/dom/mathml/nsMathMLElement.h index e5fbe9cac1f6..8b26a25c7f6f 100644 --- a/dom/mathml/nsMathMLElement.h +++ b/dom/mathml/nsMathMLElement.h @@ -111,6 +111,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; private: diff --git a/dom/svg/SVGAElement.cpp b/dom/svg/SVGAElement.cpp index 89dcad5563fe..69f5bf8c408c 100644 --- a/dom/svg/SVGAElement.cpp +++ b/dom/svg/SVGAElement.cpp @@ -335,10 +335,11 @@ SVGAElement::IntrinsicState() const nsresult SVGAElement::SetAttr(int32_t aNameSpaceID, nsAtom* aName, nsAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) { nsresult rv = SVGAElementBase::SetAttr(aNameSpaceID, aName, aPrefix, - aValue, aNotify); + aValue, aSubjectPrincipal, aNotify); // The ordering of the parent class's SetAttr call and Link::ResetLinkState // is important here! The attribute is not set until SetAttr returns, and diff --git a/dom/svg/SVGAElement.h b/dom/svg/SVGAElement.h index 5a4c0ecbcd89..4ba0a0588fd1 100644 --- a/dom/svg/SVGAElement.h +++ b/dom/svg/SVGAElement.h @@ -56,13 +56,10 @@ public: virtual void GetLinkTarget(nsAString& aTarget) override; virtual already_AddRefed GetHrefURI() const override; virtual EventStates IntrinsicState() const override; - nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, - const nsAString& aValue, bool aNotify) - { - return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); - } + using nsIContent::SetAttr; virtual nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, nsAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsAtom* aAttribute, bool aNotify) override; diff --git a/dom/svg/SVGAnimationElement.cpp b/dom/svg/SVGAnimationElement.cpp index 867b619055ea..484021be2656 100644 --- a/dom/svg/SVGAnimationElement.cpp +++ b/dom/svg/SVGAnimationElement.cpp @@ -284,11 +284,13 @@ SVGAnimationElement::ParseAttribute(int32_t aNamespaceID, nsresult SVGAnimationElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { nsresult rv = SVGAnimationElementBase::AfterSetAttr(aNamespaceID, aName, aValue, - aOldValue, aNotify); + aOldValue, aSubjectPrincipal, aNotify); if (SVGTests::IsConditionalProcessingAttribute(aName)) { bool isDisabled = !SVGTests::PassesConditionalProcessingTests(); diff --git a/dom/svg/SVGAnimationElement.h b/dom/svg/SVGAnimationElement.h index 9aca747865bf..d4fb8d80ee42 100644 --- a/dom/svg/SVGAnimationElement.h +++ b/dom/svg/SVGAnimationElement.h @@ -61,6 +61,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; const nsAttrValue* GetAnimAttr(nsAtom* aName) const; diff --git a/dom/svg/SVGFEImageElement.cpp b/dom/svg/SVGFEImageElement.cpp index 56dbd94901bf..ccbffabf48e0 100644 --- a/dom/svg/SVGFEImageElement.cpp +++ b/dom/svg/SVGFEImageElement.cpp @@ -124,7 +124,9 @@ SVGFEImageElement::IsAttributeMapped(const nsAtom* name) const nsresult SVGFEImageElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aName == nsGkAtoms::href && (aNamespaceID == kNameSpaceID_XLink || @@ -138,7 +140,9 @@ SVGFEImageElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, } return SVGFEImageElementBase::AfterSetAttr(aNamespaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aSubjectPrincipal, + aNotify); } void diff --git a/dom/svg/SVGFEImageElement.h b/dom/svg/SVGFEImageElement.h index efafd3946560..977e0b32a4c0 100644 --- a/dom/svg/SVGFEImageElement.h +++ b/dom/svg/SVGFEImageElement.h @@ -61,6 +61,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, diff --git a/dom/svg/SVGGeometryElement.cpp b/dom/svg/SVGGeometryElement.cpp index 48f4c76095c3..6a2b2e201c36 100644 --- a/dom/svg/SVGGeometryElement.cpp +++ b/dom/svg/SVGGeometryElement.cpp @@ -37,7 +37,9 @@ SVGGeometryElement::GetNumberInfo() nsresult SVGGeometryElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (mCachedPath && aNamespaceID == kNameSpaceID_None && @@ -45,7 +47,9 @@ SVGGeometryElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, mCachedPath = nullptr; } return SVGGeometryElementBase::AfterSetAttr(aNamespaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aSubjectPrincipal, + aNotify); } bool diff --git a/dom/svg/SVGGeometryElement.h b/dom/svg/SVGGeometryElement.h index a952bfd4ce7b..877490e498f3 100644 --- a/dom/svg/SVGGeometryElement.h +++ b/dom/svg/SVGGeometryElement.h @@ -54,6 +54,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; /** diff --git a/dom/svg/SVGImageElement.cpp b/dom/svg/SVGImageElement.cpp index 1940bf3b5501..2e9b5b472b85 100644 --- a/dom/svg/SVGImageElement.cpp +++ b/dom/svg/SVGImageElement.cpp @@ -156,7 +156,9 @@ SVGImageElement::AsyncEventRunning(AsyncEventDispatcher* aEvent) nsresult SVGImageElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aName == nsGkAtoms::href && (aNamespaceID == kNameSpaceID_None || @@ -169,7 +171,8 @@ SVGImageElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, } } return SVGImageElementBase::AfterSetAttr(aNamespaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aSubjectPrincipal, aNotify); } void diff --git a/dom/svg/SVGImageElement.h b/dom/svg/SVGImageElement.h index 8fcb93526e3d..e515fc617f22 100644 --- a/dom/svg/SVGImageElement.h +++ b/dom/svg/SVGImageElement.h @@ -48,6 +48,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsIContent* aBindingParent, diff --git a/dom/svg/SVGScriptElement.cpp b/dom/svg/SVGScriptElement.cpp index 9f9f3034c890..01a78e816cd0 100644 --- a/dom/svg/SVGScriptElement.cpp +++ b/dom/svg/SVGScriptElement.cpp @@ -234,7 +234,9 @@ SVGScriptElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsresult SVGScriptElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if ((aNamespaceID == kNameSpaceID_XLink || aNamespaceID == kNameSpaceID_None) && @@ -242,7 +244,8 @@ SVGScriptElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, MaybeProcessScript(); } return SVGScriptElementBase::AfterSetAttr(aNamespaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, + aSubjectPrincipal, aNotify); } bool diff --git a/dom/svg/SVGScriptElement.h b/dom/svg/SVGScriptElement.h index e898958af4de..5e2d6fe5a96f 100644 --- a/dom/svg/SVGScriptElement.h +++ b/dom/svg/SVGScriptElement.h @@ -57,6 +57,7 @@ public: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute, diff --git a/dom/svg/SVGStyleElement.cpp b/dom/svg/SVGStyleElement.cpp index 96313369125a..391d16fa9eaf 100644 --- a/dom/svg/SVGStyleElement.cpp +++ b/dom/svg/SVGStyleElement.cpp @@ -92,10 +92,11 @@ SVGStyleElement::UnbindFromTree(bool aDeep, bool aNullParent) nsresult SVGStyleElement::SetAttr(int32_t aNameSpaceID, nsAtom* aName, nsAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) { nsresult rv = SVGStyleElementBase::SetAttr(aNameSpaceID, aName, aPrefix, - aValue, aNotify); + aValue, aSubjectPrincipal, aNotify); if (NS_SUCCEEDED(rv) && aNameSpaceID == kNameSpaceID_None) { if (aName == nsGkAtoms::title || aName == nsGkAtoms::media || diff --git a/dom/svg/SVGStyleElement.h b/dom/svg/SVGStyleElement.h index 737dbea41a7c..1a03ca689fba 100644 --- a/dom/svg/SVGStyleElement.h +++ b/dom/svg/SVGStyleElement.h @@ -44,13 +44,10 @@ public: bool aCompileEventHandlers) override; virtual void UnbindFromTree(bool aDeep = true, bool aNullParent = true) override; - nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, - const nsAString& aValue, bool aNotify) - { - return SetAttr(aNameSpaceID, aName, nullptr, aValue, aNotify); - } + using nsIContent::SetAttr; virtual nsresult SetAttr(int32_t aNameSpaceID, nsAtom* aName, nsAtom* aPrefix, const nsAString& aValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual nsresult UnsetAttr(int32_t aNameSpaceID, nsAtom* aAttribute, bool aNotify) override; diff --git a/dom/svg/nsSVGElement.cpp b/dom/svg/nsSVGElement.cpp index b2419ab39fca..43a860739a04 100644 --- a/dom/svg/nsSVGElement.cpp +++ b/dom/svg/nsSVGElement.cpp @@ -301,7 +301,9 @@ nsSVGElement::BindToTree(nsIDocument* aDocument, nsIContent* aParent, nsresult nsSVGElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { // We don't currently use nsMappedAttributes within SVG. If this changes, we // need to be very careful because some nsAttrValues used by SVG point to @@ -332,7 +334,7 @@ nsSVGElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, } return nsSVGElementBase::AfterSetAttr(aNamespaceID, aName, aValue, aOldValue, - aNotify); + aSubjectPrincipal, aNotify); } bool @@ -1495,7 +1497,7 @@ nsSVGElement::DidChangeValue(nsAtom* aName, // attribute, but currently SVG elements do not even use the old attribute // value in |AfterSetAttr|, so this should be ok. SetAttrAndNotify(kNameSpaceID_None, aName, nullptr, &aEmptyOrOldValue, - aNewValue, modType, hasListeners, kNotifyDocumentObservers, + aNewValue, nullptr, modType, hasListeners, kNotifyDocumentObservers, kCallAfterSetAttr, document, updateBatch); } diff --git a/dom/svg/nsSVGElement.h b/dom/svg/nsSVGElement.h index 49db2fde24d9..8c4c256e1ec2 100644 --- a/dom/svg/nsSVGElement.h +++ b/dom/svg/nsSVGElement.h @@ -351,6 +351,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual bool ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute, const nsAString& aValue, nsAttrValue& aResult) override; diff --git a/dom/webidl/AnonymousContent.webidl b/dom/webidl/AnonymousContent.webidl index 8be69cd26f8e..40a7bdfae9a4 100644 --- a/dom/webidl/AnonymousContent.webidl +++ b/dom/webidl/AnonymousContent.webidl @@ -42,7 +42,7 @@ interface AnonymousContent { * Set the value of an attribute of an element inside this custom anonymous * content. */ - [Throws] + [NeedsSubjectPrincipal, Throws] void setAttributeForElement(DOMString elementId, DOMString attributeName, DOMString value); diff --git a/dom/webidl/Attr.webidl b/dom/webidl/Attr.webidl index 763ed02ef205..e7de335e469f 100644 --- a/dom/webidl/Attr.webidl +++ b/dom/webidl/Attr.webidl @@ -12,7 +12,7 @@ interface Attr : Node { readonly attribute DOMString localName; - [CEReactions, SetterThrows] + [CEReactions, NeedsSubjectPrincipal, SetterThrows] attribute DOMString value; [Constant] diff --git a/dom/webidl/Element.webidl b/dom/webidl/Element.webidl index 32fcbc407569..a7cb77e5fc02 100644 --- a/dom/webidl/Element.webidl +++ b/dom/webidl/Element.webidl @@ -40,9 +40,9 @@ interface Element : Node { DOMString? getAttribute(DOMString name); [Pure] DOMString? getAttributeNS(DOMString? namespace, DOMString localName); - [CEReactions, Throws] + [CEReactions, NeedsSubjectPrincipal, Throws] void setAttribute(DOMString name, DOMString value); - [CEReactions, Throws] + [CEReactions, NeedsSubjectPrincipal, Throws] void setAttributeNS(DOMString? namespace, DOMString name, DOMString value); [CEReactions, Throws] void removeAttribute(DOMString name); diff --git a/dom/xul/nsXULElement.cpp b/dom/xul/nsXULElement.cpp index 735249e3dd28..2d449c8d3002 100644 --- a/dom/xul/nsXULElement.cpp +++ b/dom/xul/nsXULElement.cpp @@ -1030,7 +1030,9 @@ nsXULElement::BeforeSetAttr(int32_t aNamespaceID, nsAtom* aName, nsresult nsXULElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, - const nsAttrValue* aOldValue, bool aNotify) + const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, + bool aNotify) { if (aNamespaceID == kNameSpaceID_None) { if (aValue) { @@ -1151,7 +1153,7 @@ nsXULElement::AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, } return nsStyledElement::AfterSetAttr(aNamespaceID, aName, - aValue, aOldValue, aNotify); + aValue, aOldValue, aSubjectPrincipal, aNotify); } bool diff --git a/dom/xul/nsXULElement.h b/dom/xul/nsXULElement.h index 285ddb9bb5c1..2b911793a436 100644 --- a/dom/xul/nsXULElement.h +++ b/dom/xul/nsXULElement.h @@ -744,6 +744,7 @@ protected: virtual nsresult AfterSetAttr(int32_t aNamespaceID, nsAtom* aName, const nsAttrValue* aValue, const nsAttrValue* aOldValue, + nsIPrincipal* aSubjectPrincipal, bool aNotify) override; virtual void UpdateEditableState(bool aNotify) override;