Skip to content

Commit

Permalink
feat: allow payment in amp-consent external ui (ampproject#39855)
Browse files Browse the repository at this point in the history
  • Loading branch information
marcmrf authored and eszponder committed Apr 22, 2024
1 parent ee8607d commit 9918805
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
3 changes: 3 additions & 0 deletions extensions/amp-consent/0.1/consent-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,8 @@ const ALLOWED_SANDBOX_ATTRIBUTES = [

const IFRAME_RUNNING_TIMEOUT = 1000;

const IFRAME_ALLOWED_PERMISSIONS = ['geolocation', 'payment'];

export const actionState = {
error: 'error',
success: 'success',
Expand Down Expand Up @@ -471,6 +473,7 @@ export class ConsentUI {
const iframe = this.parent_.ownerDocument.createElement('iframe');
const sandbox = this.getSandboxAttribute_(promptUISrc);
iframe.setAttribute('sandbox', sandbox);
iframe.setAttribute('allow', IFRAME_ALLOWED_PERMISSIONS.join('; '));
const {classList} = iframe;
classList.add(consentUiClasses.fill);
// Append iframe lazily to save resources.
Expand Down
3 changes: 3 additions & 0 deletions extensions/amp-consent/0.1/test/test-consent-ui.js
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ describes.realWin(
expect(consentUI.ui_.getAttribute('sandbox')).to.equal(
'allow-scripts allow-popups allow-same-origin'
);
expect(consentUI.ui_.getAttribute('allow')).to.equal(
'geolocation; payment'
);
});

it('should allow additional sandbox restriction to be removed from iframe', function* () {
Expand Down

0 comments on commit 9918805

Please sign in to comment.