@paypal/checkout-components 5.0.437 → 5.0.438-alpha-b1d5950.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@paypal/checkout-components",
3
- "version": "5.0.437",
3
+ "version": "5.0.438-alpha-b1d5950.0",
4
4
  "description": "PayPal Checkout components, for integrating checkout products.",
5
5
  "main": "index.js",
6
6
  "scripts": {
package/src/types.js CHANGED
@@ -71,6 +71,7 @@ export type Experiment = {|
71
71
  isPaylaterCobrandedLabelEnabled?: boolean,
72
72
  isPaylaterCobrandedLabelRandomizationEnabled?: boolean,
73
73
  isBfcacheEnabled?: boolean,
74
+ isWebMCPEnabled?: boolean,
74
75
  |};
75
76
 
76
77
  export type Requires = {|
@@ -236,18 +236,25 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
236
236
  fundingSource = `-${props.fundingSource}`;
237
237
  }
238
238
 
239
+ const baseIframeAttributes = {
240
+ allowpaymentrequest: "allowpaymentrequest",
241
+ // Named origin, not bare "payment": zoid never sets this iframe's `src`
242
+ // attribute (it navigates the frame via window.location/form-POST after
243
+ // creation instead), so the 'src' keyword that bare `allow="payment"`
244
+ // resolves to can never match the actual checkout origin.
245
+ allow: `payment ${getPayPalDomain()}`,
246
+ scrolling: "no",
247
+ title: `${FUNDING_BRAND_LABEL.PAYPAL}${fundingSource}`,
248
+ role: "presentation",
249
+ };
250
+
239
251
  return {
240
- iframe: {
241
- allowpaymentrequest: "allowpaymentrequest",
242
- // Named origin, not bare "payment": zoid never sets this iframe's `src`
243
- // attribute (it navigates the frame via window.location/form-POST after
244
- // creation instead), so the 'src' keyword that bare `allow="payment"`
245
- // resolves to can never match the actual checkout origin.
246
- allow: `payment ${getPayPalDomain()}`,
247
- scrolling: "no",
248
- title: `${FUNDING_BRAND_LABEL.PAYPAL}${fundingSource}`,
249
- role: "presentation",
250
- },
252
+ iframe: props.experiment?.isWebMCPEnabled
253
+ ? {
254
+ ...baseIframeAttributes,
255
+ allow: `${baseIframeAttributes.allow}; tools *`,
256
+ }
257
+ : baseIframeAttributes,
251
258
  };
252
259
  },
253
260
 
@@ -93,3 +93,35 @@ describe("getButtonsComponent iframe payment permissions policy", () => {
93
93
  expect(iframeAttrs.allow).toContain("https://www.paypal.com");
94
94
  });
95
95
  });
96
+
97
+ describe("getButtonsComponent iframe allow attribute", () => {
98
+ it("does not append tools when the WebMCP first-render experiment flag is absent", () => {
99
+ getButtonsComponent();
100
+ const { attributes } = createMock.mock.calls[0][0];
101
+
102
+ const { allow } = attributes({ props: {} }).iframe;
103
+ expect(allow).toBe("payment https://www.paypal.com");
104
+ expect(allow).not.toContain("tools");
105
+ });
106
+
107
+ it("does not append tools when the WebMCP first-render experiment flag is disabled", () => {
108
+ getButtonsComponent();
109
+ const { attributes } = createMock.mock.calls[0][0];
110
+
111
+ const { allow } = attributes({
112
+ props: { experiment: { isWebMCPEnabled: false } },
113
+ }).iframe;
114
+ expect(allow).toBe("payment https://www.paypal.com");
115
+ expect(allow).not.toContain("tools");
116
+ });
117
+
118
+ it("appends 'tools *' alongside the payment permission when the WebMCP first-render experiment flag is enabled", () => {
119
+ getButtonsComponent();
120
+ const { attributes } = createMock.mock.calls[0][0];
121
+
122
+ expect(
123
+ attributes({ props: { experiment: { isWebMCPEnabled: true } } }).iframe
124
+ .allow,
125
+ ).toBe("payment https://www.paypal.com; tools *");
126
+ });
127
+ });