Skip to content

Commit b75d885

Browse files
authored
Add canSetCookie check before attempting to set cookies. (#40292)
1 parent 23942ea commit b75d885

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

ads/google/a4a/cookie-utils.js

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import {setCookie} from 'src/cookies';
1+
import {canSetCookie, setCookie} from 'src/cookies';
22
import {isProxyOrigin} from 'src/url';
33

44
/** @type {string} */
@@ -25,7 +25,10 @@ function getProxySafeDomain(win, domain) {
2525
* @param {!Response} fetchResponse
2626
*/
2727
export function maybeSetCookieFromAdResponse(win, fetchResponse) {
28-
if (!fetchResponse.headers.has(AMP_GFP_SET_COOKIES_HEADER_NAME)) {
28+
if (
29+
!fetchResponse.headers.has(AMP_GFP_SET_COOKIES_HEADER_NAME) ||
30+
!canSetCookie(win)
31+
) {
2932
return;
3033
}
3134
let cookiesToSet = /** @type {!Array<!Object>} */ [];

0 commit comments

Comments
 (0)