Bug 1595936: Part 2 - Refresh feature policy when attaching browsing context. r=farre,baku

We go to great lengths to try to avoid initializing FrameLoaders during
document updates. That means that when `BindToTree` is called, the element's
FrameLoader is not initialized, and it has no BrowsingContext. Calling
`GetBrowsingContext()` (which happens as a side-effect of
`HTMLIFrameElement::RefreshFeaturePolicy`), however, forces eager
initialization, which can cause any number of problems.

This patch moves that logic from being triggered by `BindToTree` to being
triggered by `BrowsingContext::Embed`, which happens as soon as the
BrowsingContext is bound to the element, but does not force it to be created
early.

Differential Revision: https://phabricator.services.mozilla.com/D55872
This commit is contained in:
Kris Maglione
2020-01-24 19:03:10 +00:00
parent c02232dc88
commit 04adf714ef
5 changed files with 20 additions and 9 deletions

View File

@@ -66,17 +66,11 @@ HTMLIFrameElement::~HTMLIFrameElement() {}
NS_IMPL_ELEMENT_CLONE(HTMLIFrameElement)
nsresult HTMLIFrameElement::BindToTree(BindContext& aContext,
nsINode& aParent) {
nsresult rv = nsGenericHTMLFrameElement::BindToTree(aContext, aParent);
if (NS_WARN_IF(NS_FAILED(rv))) {
return rv;
}
void HTMLIFrameElement::BindToBrowsingContext(
BrowsingContext* aBrowsingContext) {
if (StaticPrefs::dom_security_featurePolicy_enabled()) {
RefreshFeaturePolicy(true /* parse the feature policy attribute */);
}
return NS_OK;
}
bool HTMLIFrameElement::ParseAttribute(int32_t aNamespaceID, nsAtom* aAttribute,