@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/dist/button.js +1 -1
- package/dist/test/button.js +1 -1
- package/package.json +1 -1
- package/src/types.js +1 -0
- package/src/zoid/buttons/component.jsx +18 -11
- package/src/zoid/buttons/component.test.js +32 -0
package/package.json
CHANGED
package/src/types.js
CHANGED
|
@@ -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
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
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
|
+
});
|