This is an automated email from the git hooks/post-receive script.
richard pushed a commit to branch geckoview-102.3.0esr-12.0-1 in repository tor-browser.
commit e6d3401ad0e316fe2910821842845da408add587 Author: Edgar Chen echen@mozilla.com AuthorDate: Wed Aug 24 20:56:16 2022 +0000
Bug 1782211 - Init feature policy; r=ckerschb, a=RyanVM
Differential Revision: https://phabricator.services.mozilla.com/D154161 --- docshell/base/nsDocShell.cpp | 2 ++ dom/base/Document.cpp | 8 ++++++-- dom/base/Document.h | 1 + 3 files changed, 9 insertions(+), 2 deletions(-)
diff --git a/docshell/base/nsDocShell.cpp b/docshell/base/nsDocShell.cpp index 3c634133e2710..d20c847dd74a0 100644 --- a/docshell/base/nsDocShell.cpp +++ b/docshell/base/nsDocShell.cpp @@ -6791,6 +6791,8 @@ nsresult nsDocShell::CreateAboutBlankContentViewer( // after being set here. blankDoc->SetSandboxFlags(sandboxFlags);
+ blankDoc->InitFeaturePolicy(); + // create a content viewer for us and the new document docFactory->CreateInstanceForDocument( NS_ISUPPORTS_CAST(nsIDocShell*, this), blankDoc, "view", diff --git a/dom/base/Document.cpp b/dom/base/Document.cpp index 5b7e6f79eec7d..3efc8c5e8945e 100644 --- a/dom/base/Document.cpp +++ b/dom/base/Document.cpp @@ -3888,8 +3888,8 @@ already_AddRefeddom::FeaturePolicy Document::GetParentFeaturePolicy() { return do_AddRef(child->GetContainerFeaturePolicy()); }
-nsresult Document::InitFeaturePolicy(nsIChannel* aChannel) { - MOZ_ASSERT(mFeaturePolicy, "we should only call init once"); +void Document::InitFeaturePolicy() { + MOZ_ASSERT(mFeaturePolicy, "we should have FeaturePolicy created");
mFeaturePolicy->ResetDeclaredPolicy();
@@ -3901,6 +3901,10 @@ nsresult Document::InitFeaturePolicy(nsIChannel* aChannel) { mFeaturePolicy->InheritPolicy(parentPolicy); mFeaturePolicy->SetSrcOrigin(parentPolicy->GetSrcOrigin()); } +} + +nsresult Document::InitFeaturePolicy(nsIChannel* aChannel) { + InitFeaturePolicy();
// We don't want to parse the http Feature-Policy header if this pref is off. if (!StaticPrefs::dom_security_featurePolicy_header_enabled()) { diff --git a/dom/base/Document.h b/dom/base/Document.h index a6b2636a07e55..fcaddc6c7bbac 100644 --- a/dom/base/Document.h +++ b/dom/base/Document.h @@ -1525,6 +1525,7 @@ class Document : public nsINode,
void DoNotifyPossibleTitleChange();
+ void InitFeaturePolicy(); nsresult InitFeaturePolicy(nsIChannel* aChannel);
protected: