Skip to content

Commit

Permalink
Bug 1514296 - Rename Document.policy to Document.featurePolicy, r=cke…
Browse files Browse the repository at this point in the history
…rschb

Differential Revision: https://phabricator.services.mozilla.com/D35801

--HG--
extra : moz-landing-system : lando
  • Loading branch information
bakulf committed Jul 6, 2019
1 parent 26f5af1 commit e01cab3
Show file tree
Hide file tree
Showing 10 changed files with 116 additions and 114 deletions.
10 changes: 5 additions & 5 deletions dom/base/Document.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2211,7 +2211,7 @@ nsresult Document::Init() {

// we need to create a policy here so getting the policy within
// ::Policy() can *always* return a non null policy
mFeaturePolicy = new FeaturePolicy(this);
mFeaturePolicy = new mozilla::dom::FeaturePolicy(this);
mFeaturePolicy->SetDefaultOrigin(NodePrincipal());

mStyleSet = MakeUnique<ServoStyleSet>(*this);
Expand Down Expand Up @@ -3275,14 +3275,14 @@ nsresult Document::InitFeaturePolicy(nsIChannel* aChannel) {

mFeaturePolicy->SetDefaultOrigin(NodePrincipal());

RefPtr<FeaturePolicy> parentPolicy = nullptr;
RefPtr<mozilla::dom::FeaturePolicy> parentPolicy = nullptr;
if (mDocumentContainer) {
nsPIDOMWindowOuter* containerWindow = mDocumentContainer->GetWindow();
if (containerWindow) {
nsCOMPtr<nsINode> node = containerWindow->GetFrameElementInternal();
HTMLIFrameElement* iframe = HTMLIFrameElement::FromNodeOrNull(node);
if (iframe) {
parentPolicy = iframe->Policy();
parentPolicy = iframe->FeaturePolicy();
}
}
}
Expand Down Expand Up @@ -12573,10 +12573,10 @@ void Document::MaybeResolveReadyForIdle() {
}
}

FeaturePolicy* Document::Policy() const {
mozilla::dom::FeaturePolicy* Document::FeaturePolicy() const {
// The policy is created when the document is initialized. We _must_ have a
// policy here even if the featurePolicy pref is off. If this assertion fails,
// it means that ::Policy() is called before ::StartDocumentLoad().
// it means that ::FeaturePolicy() is called before ::StartDocumentLoad().
MOZ_ASSERT(mFeaturePolicy);
return mFeaturePolicy;
}
Expand Down
4 changes: 2 additions & 2 deletions dom/base/Document.h
Original file line number Diff line number Diff line change
Expand Up @@ -4052,7 +4052,7 @@ class Document : public nsINode,
mAllowPaymentRequest = aAllowPaymentRequest;
}

FeaturePolicy* Policy() const;
mozilla::dom::FeaturePolicy* FeaturePolicy() const;

bool ModuleScriptsEnabled();

Expand Down Expand Up @@ -4474,7 +4474,7 @@ class Document : public nsINode,

RefPtr<Promise> mReadyForIdle;

RefPtr<FeaturePolicy> mFeaturePolicy;
RefPtr<mozilla::dom::FeaturePolicy> mFeaturePolicy;

UniquePtr<ResizeObserverController> mResizeObserverController;

Expand Down
8 changes: 5 additions & 3 deletions dom/html/HTMLIFrameElement.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ HTMLIFrameElement::HTMLIFrameElement(
FromParser aFromParser)
: nsGenericHTMLFrameElement(std::move(aNodeInfo), aFromParser) {
// We always need a featurePolicy, even if not exposed.
mFeaturePolicy = new FeaturePolicy(this);
mFeaturePolicy = new mozilla::dom::FeaturePolicy(this);

nsCOMPtr<nsIPrincipal> origin = GetFeaturePolicyDefaultOrigin();
MOZ_ASSERT(origin);
Expand Down Expand Up @@ -224,7 +224,9 @@ JSObject* HTMLIFrameElement::WrapNode(JSContext* aCx,
return HTMLIFrameElement_Binding::Wrap(aCx, this, aGivenProto);
}

FeaturePolicy* HTMLIFrameElement::Policy() const { return mFeaturePolicy; }
mozilla::dom::FeaturePolicy* HTMLIFrameElement::FeaturePolicy() const {
return mFeaturePolicy;
}

already_AddRefed<nsIPrincipal>
HTMLIFrameElement::GetFeaturePolicyDefaultOrigin() const {
Expand Down Expand Up @@ -268,7 +270,7 @@ void HTMLIFrameElement::RefreshFeaturePolicy(bool aParseAllowAttribute) {
origin);
}

mFeaturePolicy->InheritPolicy(OwnerDoc()->Policy());
mFeaturePolicy->InheritPolicy(OwnerDoc()->FeaturePolicy());
}

if (AllowPaymentRequest()) {
Expand Down
2 changes: 1 addition & 1 deletion dom/html/HTMLIFrameElement.h
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ class HTMLIFrameElement final : public nsGenericHTMLFrameElement {
bool FullscreenFlag() const { return mFullscreenFlag; }
void SetFullscreenFlag(bool aValue) { mFullscreenFlag = aValue; }

FeaturePolicy* Policy() const;
mozilla::dom::FeaturePolicy* FeaturePolicy() const;

protected:
virtual ~HTMLIFrameElement();
Expand Down
2 changes: 1 addition & 1 deletion dom/security/featurepolicy/FeaturePolicy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ void FeaturePolicy::ResetDeclaredPolicy() { mFeatures.Clear(); }

JSObject* FeaturePolicy::WrapObject(JSContext* aCx,
JS::Handle<JSObject*> aGivenProto) {
return Policy_Binding::Wrap(aCx, this, aGivenProto);
return FeaturePolicy_Binding::Wrap(aCx, this, aGivenProto);
}

bool FeaturePolicy::AllowsFeature(const nsAString& aFeatureName,
Expand Down
2 changes: 1 addition & 1 deletion dom/security/featurepolicy/FeaturePolicyUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -92,7 +92,7 @@ bool FeaturePolicyUtils::IsFeatureAllowed(Document* aDocument,
return true;
}

FeaturePolicy* policy = aDocument->Policy();
FeaturePolicy* policy = aDocument->FeaturePolicy();
MOZ_ASSERT(policy);

if (policy->AllowsFeatureInternal(aFeatureName, policy->DefaultOrigin())) {
Expand Down
190 changes: 95 additions & 95 deletions dom/security/featurepolicy/test/mochitest/test_parser.html

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions dom/webidl/Document.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -601,10 +601,10 @@ Document implements GeometryUtils;
Document implements FontFaceSource;
Document implements DocumentOrShadowRoot;

// https://wicg.github.io/feature-policy/#policy
// https://w3c.github.io/webappsec-feature-policy/#idl-index
partial interface Document {
[SameObject, Pref="dom.security.featurePolicy.webidl.enabled"]
readonly attribute Policy policy;
readonly attribute FeaturePolicy featurePolicy;
};

/**
Expand Down
4 changes: 2 additions & 2 deletions dom/webidl/FeaturePolicy.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*
* For more information on this interface, please see
* https://wicg.github.io/feature-policy/#policy
* https://w3c.github.io/webappsec-feature-policy/#idl-index
*/

[NoInterfaceObject]
interface Policy {
interface FeaturePolicy {
boolean allowsFeature(DOMString feature, optional DOMString origin);
sequence<DOMString> allowedFeatures();
sequence<DOMString> getAllowlistForFeature(DOMString feature);
Expand Down
4 changes: 2 additions & 2 deletions dom/webidl/HTMLIFrameElement.webidl
Original file line number Diff line number Diff line change
Expand Up @@ -70,10 +70,10 @@ partial interface HTMLIFrameElement {
HTMLIFrameElement implements MozFrameLoaderOwner;
HTMLIFrameElement implements BrowserElement;

// https://wicg.github.io/feature-policy/#policy
// https://w3c.github.io/webappsec-feature-policy/#idl-index
partial interface HTMLIFrameElement {
[SameObject, Pref="dom.security.featurePolicy.webidl.enabled"]
readonly attribute Policy policy;
readonly attribute FeaturePolicy featurePolicy;

[CEReactions, SetterThrows, Pure, Pref="dom.security.featurePolicy.enabled"]
attribute DOMString allow;
Expand Down

0 comments on commit e01cab3

Please sign in to comment.