Bug 1665252 - remove allowpaymentrequest attribute from HTMLIFrameElement r=dom-workers-and-storage-reviewers,smaug,asuth

Differential Revision: https://phabricator.services.mozilla.com/D90505
This commit is contained in:
Marcos Cáceres
2020-09-24 03:41:26 +00:00
parent 604116cf00
commit 4dbaa97fdd
12 changed files with 14 additions and 79 deletions

View File

@@ -1292,7 +1292,6 @@ Document::Document(const char* aContentType)
mIsTopLevelContentDocument(false), mIsTopLevelContentDocument(false),
mIsContentDocument(false), mIsContentDocument(false),
mDidCallBeginLoad(false), mDidCallBeginLoad(false),
mAllowPaymentRequest(false),
mEncodingMenuDisabled(false), mEncodingMenuDisabled(false),
mLinksEnabled(true), mLinksEnabled(true),
mIsSVGGlyphsDocument(false), mIsSVGGlyphsDocument(false),
@@ -6387,9 +6386,6 @@ nsresult Document::SetSubDocumentFor(Element* aElement, Document* aSubDoc) {
// aSubDoc is nullptr, remove the mapping // aSubDoc is nullptr, remove the mapping
if (mSubDocuments) { if (mSubDocuments) {
if (Document* subDoc = GetSubDocumentFor(aElement)) {
subDoc->SetAllowPaymentRequest(false);
}
mSubDocuments->Remove(aElement); mSubDocuments->Remove(aElement);
} }
} else { } else {
@@ -6412,7 +6408,6 @@ nsresult Document::SetSubDocumentFor(Element* aElement, Document* aSubDoc) {
} }
if (entry->mSubDocument) { if (entry->mSubDocument) {
entry->mSubDocument->SetAllowPaymentRequest(false);
entry->mSubDocument->SetParentDocument(nullptr); entry->mSubDocument->SetParentDocument(nullptr);
// Release the old sub document // Release the old sub document
@@ -6422,23 +6417,6 @@ nsresult Document::SetSubDocumentFor(Element* aElement, Document* aSubDoc) {
entry->mSubDocument = aSubDoc; entry->mSubDocument = aSubDoc;
NS_ADDREF(entry->mSubDocument); NS_ADDREF(entry->mSubDocument);
// set allowpaymentrequest for the binding subdocument
if (!mAllowPaymentRequest) {
aSubDoc->SetAllowPaymentRequest(false);
} else {
nsresult rv = nsContentUtils::CheckSameOrigin(aElement, aSubDoc);
if (NS_SUCCEEDED(rv)) {
aSubDoc->SetAllowPaymentRequest(true);
} else {
if (aElement->IsHTMLElement(nsGkAtoms::iframe) &&
aElement->GetBoolAttr(nsGkAtoms::allowpaymentrequest)) {
aSubDoc->SetAllowPaymentRequest(true);
} else {
aSubDoc->SetAllowPaymentRequest(false);
}
}
}
aSubDoc->SetParentDocument(this); aSubDoc->SetParentDocument(this);
} }

View File

@@ -2159,10 +2159,6 @@ class Document : public nsINode,
bool IsTopLevelContentDocument() const { return mIsTopLevelContentDocument; } bool IsTopLevelContentDocument() const { return mIsTopLevelContentDocument; }
void SetIsTopLevelContentDocument(bool aIsTopLevelContentDocument) { void SetIsTopLevelContentDocument(bool aIsTopLevelContentDocument) {
mIsTopLevelContentDocument = aIsTopLevelContentDocument; mIsTopLevelContentDocument = aIsTopLevelContentDocument;
// When a document is set as TopLevelContentDocument, it must be
// allowpaymentrequest. We handle the false case while a document is
// appended in SetSubDocumentFor
SetAllowPaymentRequest(aIsTopLevelContentDocument);
} }
bool IsContentDocument() const { return mIsContentDocument; } bool IsContentDocument() const { return mIsContentDocument; }
@@ -3873,12 +3869,6 @@ class Document : public nsINode,
--mIgnoreOpensDuringUnloadCounter; --mIgnoreOpensDuringUnloadCounter;
} }
bool AllowPaymentRequest() const { return mAllowPaymentRequest; }
void SetAllowPaymentRequest(bool aAllowPaymentRequest) {
mAllowPaymentRequest = aAllowPaymentRequest;
}
mozilla::dom::FeaturePolicy* FeaturePolicy() const; mozilla::dom::FeaturePolicy* FeaturePolicy() const;
bool ModuleScriptsEnabled(); bool ModuleScriptsEnabled();
@@ -4502,9 +4492,6 @@ class Document : public nsINode,
// True if we have called BeginLoad and are expecting a paired EndLoad call. // True if we have called BeginLoad and are expecting a paired EndLoad call.
bool mDidCallBeginLoad : 1; bool mDidCallBeginLoad : 1;
// True if the document is allowed to use PaymentRequest.
bool mAllowPaymentRequest : 1;
// True if the encoding menu should be disabled. // True if the encoding menu should be disabled.
bool mEncodingMenuDisabled : 1; bool mEncodingMenuDisabled : 1;

View File

@@ -1482,14 +1482,6 @@ nsresult nsFrameLoader::SwapWithOtherLoader(nsFrameLoader* aOther,
return NS_ERROR_NOT_IMPLEMENTED; return NS_ERROR_NOT_IMPLEMENTED;
} }
bool ourPaymentRequestAllowed =
ourContent->HasAttr(kNameSpaceID_None, nsGkAtoms::allowpaymentrequest);
bool otherPaymentRequestAllowed =
otherContent->HasAttr(kNameSpaceID_None, nsGkAtoms::allowpaymentrequest);
if (ourPaymentRequestAllowed != otherPaymentRequestAllowed) {
return NS_ERROR_NOT_IMPLEMENTED;
}
nsILoadContext* ourLoadContext = ourContent->OwnerDoc()->GetLoadContext(); nsILoadContext* ourLoadContext = ourContent->OwnerDoc()->GetLoadContext();
nsILoadContext* otherLoadContext = otherContent->OwnerDoc()->GetLoadContext(); nsILoadContext* otherLoadContext = otherContent->OwnerDoc()->GetLoadContext();
MOZ_ASSERT(ourLoadContext && otherLoadContext, MOZ_ASSERT(ourLoadContext && otherLoadContext,

View File

@@ -171,8 +171,7 @@ nsresult HTMLIFrameElement::AfterSetAttr(int32_t aNameSpaceID, nsAtom* aName,
if (aName == nsGkAtoms::allow || aName == nsGkAtoms::src || if (aName == nsGkAtoms::allow || aName == nsGkAtoms::src ||
aName == nsGkAtoms::srcdoc || aName == nsGkAtoms::sandbox) { aName == nsGkAtoms::srcdoc || aName == nsGkAtoms::sandbox) {
RefreshFeaturePolicy(true /* parse the feature policy attribute */); RefreshFeaturePolicy(true /* parse the feature policy attribute */);
} else if (aName == nsGkAtoms::allowfullscreen || } else if (aName == nsGkAtoms::allowfullscreen) {
aName == nsGkAtoms::allowpaymentrequest) {
RefreshFeaturePolicy(false /* parse the feature policy attribute */); RefreshFeaturePolicy(false /* parse the feature policy attribute */);
} }
} }
@@ -296,10 +295,6 @@ void HTMLIFrameElement::RefreshFeaturePolicy(bool aParseAllowAttribute) {
} }
} }
if (AllowPaymentRequest()) {
mFeaturePolicy->MaybeSetAllowedPolicy(u"payment"_ns);
}
if (AllowFullscreen()) { if (AllowFullscreen()) {
mFeaturePolicy->MaybeSetAllowedPolicy(u"fullscreen"_ns); mFeaturePolicy->MaybeSetAllowedPolicy(u"fullscreen"_ns);
} }

View File

@@ -79,12 +79,6 @@ class HTMLIFrameElement final : public nsGenericHTMLFrameElement {
SetHTMLBoolAttr(nsGkAtoms::allowfullscreen, aAllow, aError); SetHTMLBoolAttr(nsGkAtoms::allowfullscreen, aAllow, aError);
} }
bool AllowPaymentRequest() const {
return GetBoolAttr(nsGkAtoms::allowpaymentrequest);
}
void SetAllowPaymentRequest(bool aAllow, ErrorResult& aError) {
SetHTMLBoolAttr(nsGkAtoms::allowpaymentrequest, aAllow, aError);
}
void GetWidth(DOMString& aWidth) { GetHTMLAttr(nsGkAtoms::width, aWidth); } void GetWidth(DOMString& aWidth) { GetHTMLAttr(nsGkAtoms::width, aWidth); }
void SetWidth(const nsAString& aWidth, ErrorResult& aError) { void SetWidth(const nsAString& aWidth, ErrorResult& aError) {
SetHTMLAttr(nsGkAtoms::width, aWidth, aError); SetHTMLAttr(nsGkAtoms::width, aWidth, aError);

View File

@@ -606,14 +606,6 @@ already_AddRefed<PaymentRequest> PaymentRequest::Constructor(
return nullptr; return nullptr;
} }
// Check if AllowPaymentRequest on the owner document
if (!doc->AllowPaymentRequest()) {
aRv.ThrowSecurityError(
"The PaymentRequest API is not enabled in this document, since "
"allowPaymentRequest property is false");
return nullptr;
}
// Get the top level principal // Get the top level principal
nsCOMPtr<Document> topLevelDoc = doc->GetTopLevelContentDocument(); nsCOMPtr<Document> topLevelDoc = doc->GetTopLevelContentDocument();
MOZ_ASSERT(topLevelDoc); MOZ_ASSERT(topLevelDoc);

View File

@@ -23,7 +23,7 @@
} }
} else if (e.data === 'new PaymentRequest in a new iframe') { } else if (e.data === 'new PaymentRequest in a new iframe') {
var ifrr = document.createElement('iframe'); var ifrr = document.createElement('iframe');
ifrr.setAttribute('allowpaymentrequest', 'true'); ifrr.allow = "payment";
ifrr.src = "https://example.com/tests/dom/payments/test/simple_payment_request.html"; ifrr.src = "https://example.com/tests/dom/payments/test/simple_payment_request.html";
document.body.appendChild(ifrr); document.body.appendChild(ifrr);
} else { } else {

View File

@@ -207,12 +207,12 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1408234
await requestChromeAction("test-setup", testName); await requestChromeAction("test-setup", testName);
return new Promise(async (resolve) => { return new Promise(async (resolve) => {
const outer = document.createElement("iframe"); const outer = document.createElement("iframe");
outer.allowPaymentRequest = true; outer.allow = "payment";
document.body.appendChild(outer); document.body.appendChild(outer);
await getLoadedPaymentRequest(outer,"blank_page.html"); await getLoadedPaymentRequest(outer,"blank_page.html");
const inner = outer.contentDocument.createElement("iframe"); const inner = outer.contentDocument.createElement("iframe");
inner.allowPaymentRequest = true; inner.allow = "payment";
outer.contentDocument.body.appendChild(inner); outer.contentDocument.body.appendChild(inner);
const request = await getLoadedPaymentRequest(inner,"blank_page.html"); const request = await getLoadedPaymentRequest(inner,"blank_page.html");

View File

@@ -304,7 +304,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1345361
gScript.sendAsyncMessage("check-cross-origin-top-level-principal"); gScript.sendAsyncMessage("check-cross-origin-top-level-principal");
}); });
ifrr.setAttribute('allowpaymentrequest', ''); ifrr.setAttribute('allow', 'payment');
ifrr.src = "https://test1.example.com:443/tests/dom/payments/test/simple_payment_request.html"; ifrr.src = "https://test1.example.com:443/tests/dom/payments/test/simple_payment_request.html";
document.body.appendChild(ifrr); document.body.appendChild(ifrr);
}); });

View File

@@ -67,7 +67,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1318988
window.addEventListener("message", listener); window.addEventListener("message", listener);
ifrr.setAttribute('allowpaymentrequest', 'true'); ifrr.setAttribute('allow', 'payment');
ifrr.src = "https://test1.example.com:443/tests/dom/payments/test/simple_payment_request.html"; ifrr.src = "https://test1.example.com:443/tests/dom/payments/test/simple_payment_request.html";
document.body.appendChild(ifrr); document.body.appendChild(ifrr);
@@ -85,7 +85,7 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1318988
ifrr.addEventListener('load', function() { ifrr.addEventListener('load', function() {
if (i === 0) { if (i === 0) {
ifrr.removeAttribute("allowpaymentrequest"); ifrr.removeAttribute("allow");
} }
ifrr.contentWindow.postMessage('new PaymentRequest', '*'); ifrr.contentWindow.postMessage('new PaymentRequest', '*');
}); });
@@ -94,18 +94,18 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1318988
i++; i++;
if (i === 1) { if (i === 1) {
is(event.data, "successful", is(event.data, "successful",
"Expected successful when running with allowpayment attribute."); "Expected successful when running with allow=payment attribute.");
ifrr.contentWindow.location.href = ifrr.src; ifrr.contentWindow.location.href = ifrr.src;
} else { } else {
is(event.data, "SecurityError", is(event.data, "SecurityError",
"Expected SecurityError when running without allowpayment attribute."); "Expected SecurityError when running without allow=payment attribute.");
window.removeEventListener("message", listener); window.removeEventListener("message", listener);
resolve(); resolve();
} }
} }
window.addEventListener("message", listener); window.addEventListener("message", listener);
ifrr.setAttribute('allowpaymentrequest', "true"); ifrr.setAttribute("allow", "payment");
ifrr.src = "https://test1.example.com:443/tests/dom/payments/test/echo_payment_request.html"; ifrr.src = "https://test1.example.com:443/tests/dom/payments/test/echo_payment_request.html";
document.body.appendChild(ifrr); document.body.appendChild(ifrr);
@@ -117,14 +117,14 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1318988
var ifrr = document.createElement('iframe'); var ifrr = document.createElement('iframe');
let listener = function(event) { let listener = function(event) {
if (!ifrr.hasAttribute('allowpaymentrequest')) { if (ifrr.allow =! 'payment') {
is(event.data, "SecurityError", is(event.data, "SecurityError",
"Expected 'SecurityError' without allowpaymentrequest in nested iframe"); "Expected 'SecurityError' without allow=payment in nested iframe");
ifrr.setAttribute('allowpaymentrequest', true); ifrr.setAttribute('allow', "payment");
ifrr.contentWindow.location.href = ifrr.src; ifrr.contentWindow.location.href = ifrr.src;
} else { } else {
is(event.data, "successful", is(event.data, "successful",
"Expected 'successful' with allowpaymentrequest in nested iframe"); "Expected 'successful' with allow='payment' in nested iframe");
window.removeEventListener("message", listener); window.removeEventListener("message", listener);
resolve(); resolve();
} }

View File

@@ -27,8 +27,6 @@ interface HTMLIFrameElement : HTMLElement {
// attribute boolean seamless; // attribute boolean seamless;
[CEReactions, SetterThrows, Pure] [CEReactions, SetterThrows, Pure]
attribute boolean allowFullscreen; attribute boolean allowFullscreen;
[CEReactions, SetterThrows, Pure]
attribute boolean allowPaymentRequest;
[CEReactions, SetterThrows, Pure] [CEReactions, SetterThrows, Pure]
attribute DOMString width; attribute DOMString width;
[CEReactions, SetterThrows, Pure] [CEReactions, SetterThrows, Pure]

View File

@@ -82,7 +82,6 @@ STATIC_ATOMS = [
Atom("allowfullscreen", "allowfullscreen"), Atom("allowfullscreen", "allowfullscreen"),
Atom("allowmodals", "allow-modals"), Atom("allowmodals", "allow-modals"),
Atom("alloworientationlock", "allow-orientation-lock"), Atom("alloworientationlock", "allow-orientation-lock"),
Atom("allowpaymentrequest", "allowpaymentrequest"),
Atom("allowpointerlock", "allow-pointer-lock"), Atom("allowpointerlock", "allow-pointer-lock"),
Atom("allowpopupstoescapesandbox", "allow-popups-to-escape-sandbox"), Atom("allowpopupstoescapesandbox", "allow-popups-to-escape-sandbox"),
Atom("allowpopups", "allow-popups"), Atom("allowpopups", "allow-popups"),