diff --git a/src/features/cookie.js b/src/features/cookie.js index ba488d23a..efcfe52ac 100644 --- a/src/features/cookie.js +++ b/src/features/cookie.js @@ -154,8 +154,8 @@ export default class CookieFeature extends ContentFeature { } else if (isTrackingCookie() || isNonTrackingCookie()) { debugHelper('ignore', '3p frame', getCookieContext) } - // @ts-expect-error - error TS18048: 'cookieSetter' is possibly 'undefined'. - return cookieGetter.call(document) + // @ts-expect-error - error TS18048: 'cookieGetter' is possibly 'undefined'. + return cookieGetter.call(this) } /** @@ -186,7 +186,7 @@ export default class CookieFeature extends ContentFeature { // if the value is valid. We will override this set later if the policy dictates that // the expiry should be changed. // @ts-expect-error - error TS18048: 'cookieSetter' is possibly 'undefined'. - cookieSetter.call(document, argValue) + cookieSetter.call(this, argValue) try { // wait for config before doing same-site tests @@ -225,9 +225,7 @@ export default class CookieFeature extends ContentFeature { } } - this.defineProperty(globalThis.Document.prototype, 'cookie', { - enumerable: true, - configurable: true, + this.wrapProperty(globalThis.Document.prototype, 'cookie', { set: setCookiePolicy, get: getCookiePolicy })