Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(214)

Unified Diff: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp

Issue 2029473002: PaymentRequest should throw if not in top context. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 7 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « third_party/WebKit/LayoutTests/payments/payment-request-in-iframe.html ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
diff --git a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
index 77c01005b8f9a30f8e63f05567013cc64196e55b..49ab6bb0cfdf109ef4ecff3aff69c5b059a47e40 100644
--- a/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
+++ b/third_party/WebKit/Source/modules/payments/PaymentRequest.cpp
@@ -301,13 +301,16 @@ PaymentRequest::PaymentRequest(ScriptState* scriptState, const Vector<String>& s
, m_options(options)
, m_clientBinding(this)
{
- // TODO(rouslan): Also check for a top-level browsing context.
- // https://github.com/w3c/browser-payment-api/issues/2
if (!scriptState->getExecutionContext()->isSecureContext()) {
exceptionState.throwSecurityError("Must be in a secure context");
return;
}
+ if (!scriptState->domWindow()->frame() || !scriptState->domWindow()->frame()->isMainFrame()) {
+ exceptionState.throwSecurityError("Must be in a top-level browsing context");
+ return;
+ }
+
if (supportedMethods.isEmpty()) {
exceptionState.throwTypeError("Must specify at least one payment method identifier");
return;
« no previous file with comments | « third_party/WebKit/LayoutTests/payments/payment-request-in-iframe.html ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698