Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: allow payment in amp-consent external ui #39855

Merged
merged 2 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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('; '));
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not doing it via config as commented here #39745 (comment). Should I add any other permission?

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
Loading