@paypal/checkout-components 5.0.436 → 5.0.437-alpha-ca07432.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.436",
3
+ "version": "5.0.437-alpha-ca07432.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,13 +236,17 @@ export const getButtonsComponent: () => ButtonsComponent = memoize(() => {
236
236
  fundingSource = `-${props.fundingSource}`;
237
237
  }
238
238
 
239
+ const baseIframeAttributes = {
240
+ allowpaymentrequest: "allowpaymentrequest",
241
+ scrolling: "no",
242
+ title: `${FUNDING_BRAND_LABEL.PAYPAL}${fundingSource}`,
243
+ role: "presentation",
244
+ };
245
+
239
246
  return {
240
- iframe: {
241
- allowpaymentrequest: "allowpaymentrequest",
242
- scrolling: "no",
243
- title: `${FUNDING_BRAND_LABEL.PAYPAL}${fundingSource}`,
244
- role: "presentation",
245
- },
247
+ iframe: props.experiment?.isWebMCPEnabled
248
+ ? { ...baseIframeAttributes, allow: "tools" }
249
+ : baseIframeAttributes,
246
250
  };
247
251
  },
248
252
 
@@ -56,3 +56,32 @@ describe("getButtonsComponent iframe title", () => {
56
56
  );
57
57
  });
58
58
  });
59
+
60
+ describe("getButtonsComponent iframe allow attribute", () => {
61
+ it("does not set allow when the WebMCP first-render experiment flag is absent", () => {
62
+ getButtonsComponent();
63
+ const { attributes } = createMock.mock.calls[0][0];
64
+
65
+ expect(attributes({ props: {} }).iframe.allow).toBeUndefined();
66
+ });
67
+
68
+ it("does not set allow when the WebMCP first-render experiment flag is disabled", () => {
69
+ getButtonsComponent();
70
+ const { attributes } = createMock.mock.calls[0][0];
71
+
72
+ expect(
73
+ attributes({ props: { experiment: { isWebMCPEnabled: false } } }).iframe
74
+ .allow,
75
+ ).toBeUndefined();
76
+ });
77
+
78
+ it("sets allow to 'tools' when the WebMCP first-render experiment flag is enabled", () => {
79
+ getButtonsComponent();
80
+ const { attributes } = createMock.mock.calls[0][0];
81
+
82
+ expect(
83
+ attributes({ props: { experiment: { isWebMCPEnabled: true } } }).iframe
84
+ .allow,
85
+ ).toBe("tools");
86
+ });
87
+ });