diff --git a/src/utils/cookieJar.js b/src/utils/cookieJar.js index f83f3b43e..ce1a8beff 100644 --- a/src/utils/cookieJar.js +++ b/src/utils/cookieJar.js @@ -12,9 +12,10 @@ governing permissions and limitations under the License. import cookie from "js-cookie"; + export default { - get: cookie.get, - set: cookie.set, - remove: cookie.remove, - withConverter: cookie.withConverter + get: cookie.get.bind(cookie), + set: cookie.set.bind(cookie), + remove: cookie.remove.bind(cookie), + withConverter: cookie.withConverter.bind(cookie) }; diff --git a/test/functional/specs/Audiences/C12412.js b/test/functional/specs/Audiences/C12412.js index 18224f10a..7895402c7 100644 --- a/test/functional/specs/Audiences/C12412.js +++ b/test/functional/specs/Audiences/C12412.js @@ -57,3 +57,18 @@ test(`Verify cookie destinations are returned in the response when turned on in await t.expect(setCookieAttributes[0].sameSite).eql("none"); await t.expect(setCookieAttributes[0].secure).eql(true); }); + +test(`Verify cookie is set on the / path `, async () => { + const alloy = createAlloyProxy(); + + await alloy.configure(compose(orgMainConfigMain, debugEnabled)); + await alloy.sendEvent(); + + const cookies = await t.getCookies("C12412"); + + // In Firefox, the t.getCookies method returns an empty array even if the cookie is present. + // The if condition below is to handle this issue. + if (cookies.length > 0) { + await t.expect(cookies[0].path).eql("/"); + } +});