Bug 1335368 part 5. Stop using IsCallerChrome in nsINode. r=bholley

This commit is contained in:
Boris Zbarsky 2017-02-01 15:43:36 -05:00
parent 4dafb92c93
commit 7583017cd2
4 changed files with 12 additions and 8 deletions

View File

@ -106,6 +106,7 @@
#include "nsIAnimationObserver.h"
#include "nsChildContentList.h"
#include "mozilla/dom/NodeBinding.h"
#include "mozilla/dom/BindingDeclarations.h"
#ifdef ACCESSIBILITY
#include "mozilla/dom/AccessibleNode.h"
@ -719,9 +720,11 @@ nsINode::GetBaseURI(nsAString &aURI) const
}
void
nsINode::GetBaseURIFromJS(nsAString& aURI, ErrorResult& aRv) const
nsINode::GetBaseURIFromJS(nsAString& aURI,
CallerType aCallerType,
ErrorResult& aRv) const
{
nsCOMPtr<nsIURI> baseURI = GetBaseURI(nsContentUtils::IsCallerChrome());
nsCOMPtr<nsIURI> baseURI = GetBaseURI(aCallerType == CallerType::System);
nsAutoCString spec;
if (baseURI) {
nsresult res = baseURI->GetSpec(spec);
@ -2944,7 +2947,7 @@ nsINode::WrapObject(JSContext *aCx, JS::Handle<JSObject*> aGivenProto)
bool hasHadScriptHandlingObject = false;
if (!OwnerDoc()->GetScriptHandlingObject(hasHadScriptHandlingObject) &&
!hasHadScriptHandlingObject &&
!nsContentUtils::IsCallerChrome()) {
!nsContentUtils::IsSystemCaller(aCx)) {
Throw(aCx, NS_ERROR_UNEXPECTED);
return nullptr;
}

View File

@ -83,6 +83,7 @@ class Text;
class TextOrElementOrDocument;
struct DOMPointInit;
struct GetRootNodeOptions;
enum class CallerType : uint32_t;
} // namespace dom
} // namespace mozilla
@ -285,6 +286,7 @@ public:
typedef mozilla::dom::DOMRectReadOnly DOMRectReadOnly;
typedef mozilla::dom::OwningNodeOrString OwningNodeOrString;
typedef mozilla::dom::TextOrElementOrDocument TextOrElementOrDocument;
typedef mozilla::dom::CallerType CallerType;
typedef mozilla::ErrorResult ErrorResult;
template<class T>
@ -1773,7 +1775,9 @@ public:
// The returned value may differ if the document is loaded via XHR, and
// when accessed from chrome privileged script and
// from content privileged script for compatibility.
void GetBaseURIFromJS(nsAString& aBaseURI, mozilla::ErrorResult& aRv) const;
void GetBaseURIFromJS(nsAString& aBaseURI,
CallerType aCallerType,
ErrorResult& aRv) const;
bool HasChildNodes() const
{
return HasChildren();

View File

@ -696,9 +696,6 @@ DOMInterfaces = {
'Node': {
'nativeType': 'nsINode',
'concrete': False,
'binaryNames': {
'baseURI': 'baseURIFromJS'
}
},
'NodeIterator': {

View File

@ -31,7 +31,7 @@ interface Node : EventTarget {
[Pure]
readonly attribute DOMString nodeName;
[Pure, Throws]
[Pure, Throws, NeedsCallerType, BinaryName="baseURIFromJS"]
readonly attribute DOMString? baseURI;
[Pure, BinaryName=getComposedDoc]