diff --git a/CHANGELOG.md b/CHANGELOG.md index 8742d7e51..92e9d389b 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,7 +11,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Added -- new values to `set-cookie` and `set-cookie-reload` scriptlets: `Accept`, `Reject`, `y`, `n`, `N`, `No` +- new values to `set-cookie` and `set-cookie-reload` scriptlets: `Accept`, `Reject`, `y`, `n`, `N`, `No`, `allow`, `deny` [#336](https://github.com/AdguardTeam/Scriptlets/issues/336) - ability to use flags in regular expression scriptlet parameters [#303](https://github.com/AdguardTeam/Scriptlets/issues/303) diff --git a/src/helpers/cookie-utils.ts b/src/helpers/cookie-utils.ts index b2378ce3b..25d326714 100644 --- a/src/helpers/cookie-utils.ts +++ b/src/helpers/cookie-utils.ts @@ -69,6 +69,7 @@ export const getLimitedCookieValue = (value: string): string | number | null => 'n', 'N', 'ok', 'OK', 'Accept', 'Reject', + 'allow', 'deny', ]); let validValue; diff --git a/tests/scriptlets/set-cookie.test.js b/tests/scriptlets/set-cookie.test.js index 5ca594142..d8dc4aebd 100644 --- a/tests/scriptlets/set-cookie.test.js +++ b/tests/scriptlets/set-cookie.test.js @@ -70,6 +70,20 @@ test('Set cookie with valid value', (assert) => { assert.strictEqual(document.cookie.includes(cName) && document.cookie.includes(cValue), true, 'Cookie is set'); clearCookie(cName); + cName = '__test-cookie_allow'; + cValue = 'allow'; + runScriptlet(name, [cName, cValue]); + assert.strictEqual(window.hit, 'FIRED', 'Hit was fired'); + assert.strictEqual(document.cookie.includes(cName) && document.cookie.includes(cValue), true, 'Cookie is set'); + clearCookie(cName); + + cName = '__test-cookie_deny'; + cValue = 'deny'; + runScriptlet(name, [cName, cValue]); + assert.strictEqual(window.hit, 'FIRED', 'Hit was fired'); + assert.strictEqual(document.cookie.includes(cName) && document.cookie.includes(cValue), true, 'Cookie is set'); + clearCookie(cName); + cName = '__test-cookie_0'; cValue = '0'; runScriptlet(name, [cName, cValue]);