diff --git a/core/core.libraries.yml b/core/core.libraries.yml index f57d962fe3f4f20576283b3ccaa47eb94fa31793..c407c0c6d9ef5a6a0ef656d41191fe4c6a5396c4 100644 --- a/core/core.libraries.yml +++ b/core/core.libraries.yml @@ -747,16 +747,6 @@ jquery: js: assets/vendor/jquery/jquery.min.js: { minified: true, weight: -20 } -jquery.cookie: - version: VERSION - js: - misc/jquery.cookie.shim.js: {} - dependencies: - - core/jquery - - core/drupal - - core/js-cookie - deprecated: The %library_id% asset library is deprecated in Drupal 9.0.0 and will be removed in Drupal 10.0.0. Use the core/js-cookie library instead. See https://www.drupal.org/node/3104677 - jquery.farbtastic: remote: https://github.com/mattfarina/farbtastic # @todo Ping @robloach or @mattfarina to retroactively create this release. diff --git a/core/misc/jquery.cookie.shim.es6.js b/core/misc/jquery.cookie.shim.es6.js deleted file mode 100644 index 2bfec70dc4bb11d0218505849b454a33f2cda0a8..0000000000000000000000000000000000000000 --- a/core/misc/jquery.cookie.shim.es6.js +++ /dev/null @@ -1,234 +0,0 @@ -/** - * @file - * Defines a backwards-compatible shim for jquery.cookie. - */ - -/** - * The core/js-cookie library object. - * - * @global - * - * @var {object} Cookies - */ - -(($, Drupal, cookies) => { - const deprecatedMessageSuffix = `is deprecated in Drupal 9.0.0 and will be removed in Drupal 10.0.0. Use the core/js-cookie library instead. See https://www.drupal.org/node/3104677`; - - /** - * Determines if an object is a function. - * - * @param {Object} obj - * The object to check. - * - * @return {boolean} - * True if the object is a function. - */ - const isFunction = (obj) => - Object.prototype.toString.call(obj) === '[object Function]'; - - /** - * Decodes cookie value for compatibility with jquery.cookie. - * - * @param {string} value - * The cookie value to parse. - * @param {boolean} parseJson - * Whether cookie value should be parsed from JSON. - * - * @return {string} - * The cookie value for the reader to return. - */ - const parseCookieValue = (value, parseJson) => { - if (value.indexOf('"') === 0) { - value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); - } - - try { - value = decodeURIComponent(value.replace(/\+/g, ' ')); - return parseJson ? JSON.parse(value) : value; - } catch (e) { - // Exceptions on JSON parsing should be ignored. - } - }; - - /** - * Wraps the cookie value to support unsanitized values. - * - * Decoding strings is the job of the converter when using js-cookie, and - * the shim uses the same decode function as that library when the deprecated - * raw option is not used. - * - * @param {string} cookieValue - * The cookie value. - * @param {string} cookieName - * The cookie name. - * @param {reader~converterCallback} converter - * A function that takes the cookie value for further processing. - * @param {boolean} readUnsanitized - * Uses the unsanitized value when set to true. - * @param {boolean} parseJson - * Whether cookie value should be parsed from JSON. - * - * @return {string} - * The cookie value that js-cookie will return. - */ - const reader = ( - cookieValue, - cookieName, - converter, - readUnsanitized, - parseJson, - ) => { - const value = readUnsanitized - ? cookieValue - : parseCookieValue(cookieValue, parseJson); - - if (converter !== undefined && isFunction(converter)) { - return converter(value, cookieName); - } - - return value; - }; - - /** - * Gets or sets a browser cookie. - * - * @example - * // Returns 'myCookie=myCookieValue'. - * $.cookie('myCookie', 'myCookieValue'); - * @example - * // Returns 'myCookieValue'. - * $.cookie('myCookie'); - * - * @example - * // Returns the literal URI-encoded value of {"key": "value"} as the cookie - * // value along with the path as in the above example. - * $.cookie('myCookie', { key: 'value' }); - * @example - * $.cookie.json = true; - * // Returns { key: 'value' }. - * $.cookie('myCookie'); - * - * @param {string} key - * The name of the cookie. - * @param {string|Object|Function|undefined} value - * A js-cookie converter callback when used as a getter. This callback must - * be a function when using this shim for backwards-compatibility with - * jquery.cookie. When used as a setter, value is the string or JSON object - * to be used as the cookie value. - * @param {Object|undefined} options - * Overrides the default options when used as a setter. See the js-cookie - * library README.md file for details. - * - * @return {string} - * Returns the cookie name, value, and other properties based on the - * return value of the document.cookie setter. - * - * @deprecated in Drupal 9.0.0 and is removed from Drupal 10.0.0. - * Use the core/js-cookie library instead. - * - * @see https://www.drupal.org/node/3104677 - * @see https://github.com/js-cookie/js-cookie/blob/v3.0.1/README.md - */ - $.cookie = (key, value = undefined, options = undefined) => { - Drupal.deprecationError({ - message: `jQuery.cookie() ${deprecatedMessageSuffix}`, - }); - - if (value !== undefined && !isFunction(value)) { - // The caller is setting a cookie value and not trying to retrieve the - // cookie value using a converter callback. - const attributes = { ...$.cookie.defaults, ...options }; - - if (typeof attributes.expires === 'string' && attributes.expires !== '') { - attributes.expires = new Date(attributes.expires); - } - - const cookieSetter = cookies.withConverter({ - write: (cookieValue) => encodeURIComponent(cookieValue), - }); - - value = - $.cookie.json && !$.cookie.raw ? JSON.stringify(value) : String(value); - - return cookieSetter.set(key, value, attributes); - } - - // Use either js-cookie or pass in a converter to get the raw cookie value, - // which has security implications, but remains in place for - // backwards-compatibility. - const userProvidedConverter = value; - const cookiesShim = cookies.withConverter({ - read: (cookieValue, cookieName) => - reader( - cookieValue, - cookieName, - userProvidedConverter, - $.cookie.raw, - $.cookie.json, - ), - }); - - if (key !== undefined) { - return cookiesShim.get(key); - } - - const results = cookiesShim.get(); - Object.keys(results).forEach((resultKey) => { - if (results[resultKey] === undefined) { - delete results[resultKey]; - } - }); - - return results; - }; - - /** - * @prop {Object} defaults - * The default options when setting a cookie. - * @prop {string} defaults.path - * The default path for the cookie is ''. - * @prop {undefined} defaults.expires - * There is no default value for the expires option. The default expiration - * is set to an empty string. - */ - $.cookie.defaults = { path: '', ...cookies.defaults }; - - /** - * @prop {boolean} json - * True if the cookie value should be parsed as JSON. - */ - $.cookie.json = false; - - /** - * @prop {boolean} json - * True if the cookie value should be returned as-is without decoding - * URI entities. In jquery.cookie, this also would not encode the cookie - * name, but js-cookie does not allow this. - */ - $.cookie.raw = false; - - /** - * Removes a browser cookie. - * - * @param {string} key - * The name of the cookie. - * @param {Object} options - * Optional options. See the js-cookie library README.md for more details. - * - * @return {boolean} - * Returns true when the cookie is successfully removed. - * - * @deprecated in Drupal 9.0.0 and is removed from Drupal 10.0.0. - * Use the core/js-cookie library instead. - * - * @see https://www.drupal.org/node/3104677 - * @see https://github.com/js-cookie/js-cookie/blob/v3.0.1/README.md - */ - $.removeCookie = (key, options) => { - Drupal.deprecationError({ - message: `jQuery.removeCookie() ${deprecatedMessageSuffix}`, - }); - cookies.remove(key, { ...$.cookie.defaults, ...options }); - return !cookies.get(key); - }; -})(jQuery, Drupal, window.Cookies); diff --git a/core/misc/jquery.cookie.shim.js b/core/misc/jquery.cookie.shim.js deleted file mode 100644 index 539a4ddc1c10964ca71c014e49d97c2f1bf93704..0000000000000000000000000000000000000000 --- a/core/misc/jquery.cookie.shim.js +++ /dev/null @@ -1,91 +0,0 @@ -/** -* DO NOT EDIT THIS FILE. -* See the following change record for more information, -* https://www.drupal.org/node/2815083 -* @preserve -**/ - -(($, Drupal, cookies) => { - const deprecatedMessageSuffix = `is deprecated in Drupal 9.0.0 and will be removed in Drupal 10.0.0. Use the core/js-cookie library instead. See https://www.drupal.org/node/3104677`; - - const isFunction = obj => Object.prototype.toString.call(obj) === '[object Function]'; - - const parseCookieValue = (value, parseJson) => { - if (value.indexOf('"') === 0) { - value = value.slice(1, -1).replace(/\\"/g, '"').replace(/\\\\/g, '\\'); - } - - try { - value = decodeURIComponent(value.replace(/\+/g, ' ')); - return parseJson ? JSON.parse(value) : value; - } catch (e) {} - }; - - const reader = (cookieValue, cookieName, converter, readUnsanitized, parseJson) => { - const value = readUnsanitized ? cookieValue : parseCookieValue(cookieValue, parseJson); - - if (converter !== undefined && isFunction(converter)) { - return converter(value, cookieName); - } - - return value; - }; - - $.cookie = function (key) { - let value = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : undefined; - let options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : undefined; - Drupal.deprecationError({ - message: `jQuery.cookie() ${deprecatedMessageSuffix}` - }); - - if (value !== undefined && !isFunction(value)) { - const attributes = { ...$.cookie.defaults, - ...options - }; - - if (typeof attributes.expires === 'string' && attributes.expires !== '') { - attributes.expires = new Date(attributes.expires); - } - - const cookieSetter = cookies.withConverter({ - write: cookieValue => encodeURIComponent(cookieValue) - }); - value = $.cookie.json && !$.cookie.raw ? JSON.stringify(value) : String(value); - return cookieSetter.set(key, value, attributes); - } - - const userProvidedConverter = value; - const cookiesShim = cookies.withConverter({ - read: (cookieValue, cookieName) => reader(cookieValue, cookieName, userProvidedConverter, $.cookie.raw, $.cookie.json) - }); - - if (key !== undefined) { - return cookiesShim.get(key); - } - - const results = cookiesShim.get(); - Object.keys(results).forEach(resultKey => { - if (results[resultKey] === undefined) { - delete results[resultKey]; - } - }); - return results; - }; - - $.cookie.defaults = { - path: '', - ...cookies.defaults - }; - $.cookie.json = false; - $.cookie.raw = false; - - $.removeCookie = (key, options) => { - Drupal.deprecationError({ - message: `jQuery.removeCookie() ${deprecatedMessageSuffix}` - }); - cookies.remove(key, { ...$.cookie.defaults, - ...options - }); - return !cookies.get(key); - }; -})(jQuery, Drupal, window.Cookies); \ No newline at end of file diff --git a/core/modules/system/tests/modules/js_cookie_test/js/js_cookie_shim_test.es6.js b/core/modules/system/tests/modules/js_cookie_test/js/js_cookie_shim_test.es6.js deleted file mode 100644 index 4335a6ab5db0dc25fd20aaab0f49f9a171a96c64..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/js_cookie_test/js/js_cookie_shim_test.es6.js +++ /dev/null @@ -1,31 +0,0 @@ -/** - * @file - * Tests adding and removing browser cookies using the jquery_cookie shim. - */ -(({ behaviors }, $) => { - behaviors.jqueryCookie = { - attach: () => { - if (once('js_cookie_test-init', 'body').length) { - $('.js_cookie_test_add_button').on('click', () => { - $.cookie('js_cookie_test', 'red panda'); - }); - $('.js_cookie_test_add_raw_button').on('click', () => { - $.cookie.raw = true; - $.cookie('js_cookie_test_raw', 'red panda'); - }); - $('.js_cookie_test_add_json_button').on('click', () => { - $.cookie.json = true; - $.cookie('js_cookie_test_json', { panda: 'red' }); - $.cookie('js_cookie_test_json_simple', 'red panda'); - }); - $('.js_cookie_test_add_json_string_button').on('click', () => { - $.cookie.json = false; - $.cookie('js_cookie_test_json_string', { panda: 'red' }); - }); - $('.js_cookie_test_remove_button').on('click', () => { - $.removeCookie('js_cookie_test'); - }); - } - }, - }; -})(Drupal, jQuery); diff --git a/core/modules/system/tests/modules/js_cookie_test/js/js_cookie_shim_test.js b/core/modules/system/tests/modules/js_cookie_test/js/js_cookie_shim_test.js deleted file mode 100644 index fdeaac6acee0c8ee78f4f671a9d6071f5a598c2c..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/js_cookie_test/js/js_cookie_shim_test.js +++ /dev/null @@ -1,41 +0,0 @@ -/** -* DO NOT EDIT THIS FILE. -* See the following change record for more information, -* https://www.drupal.org/node/2815083 -* @preserve -**/ - -((_ref, $) => { - let { - behaviors - } = _ref; - behaviors.jqueryCookie = { - attach: () => { - if (once('js_cookie_test-init', 'body').length) { - $('.js_cookie_test_add_button').on('click', () => { - $.cookie('js_cookie_test', 'red panda'); - }); - $('.js_cookie_test_add_raw_button').on('click', () => { - $.cookie.raw = true; - $.cookie('js_cookie_test_raw', 'red panda'); - }); - $('.js_cookie_test_add_json_button').on('click', () => { - $.cookie.json = true; - $.cookie('js_cookie_test_json', { - panda: 'red' - }); - $.cookie('js_cookie_test_json_simple', 'red panda'); - }); - $('.js_cookie_test_add_json_string_button').on('click', () => { - $.cookie.json = false; - $.cookie('js_cookie_test_json_string', { - panda: 'red' - }); - }); - $('.js_cookie_test_remove_button').on('click', () => { - $.removeCookie('js_cookie_test'); - }); - } - } - }; -})(Drupal, jQuery); \ No newline at end of file diff --git a/core/modules/system/tests/modules/js_cookie_test/js_cookie_test.info.yml b/core/modules/system/tests/modules/js_cookie_test/js_cookie_test.info.yml deleted file mode 100644 index d33421d82352db55e1408a01f2c2c65896a95d24..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/js_cookie_test/js_cookie_test.info.yml +++ /dev/null @@ -1,5 +0,0 @@ -name: 'JS Cookie Test' -type: module -description: 'Module for the jsCookieTest.' -package: Testing -version: VERSION diff --git a/core/modules/system/tests/modules/js_cookie_test/js_cookie_test.libraries.yml b/core/modules/system/tests/modules/js_cookie_test/js_cookie_test.libraries.yml deleted file mode 100644 index 8c1667e86e71325332e230d28c95aad28ea8704a..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/js_cookie_test/js_cookie_test.libraries.yml +++ /dev/null @@ -1,9 +0,0 @@ -with_shim_test: - version: VERSION - js: - js/js_cookie_shim_test.js: {} - dependencies: - - core/jquery - - core/drupal - - core/jquery.cookie - - core/once diff --git a/core/modules/system/tests/modules/js_cookie_test/js_cookie_test.routing.yml b/core/modules/system/tests/modules/js_cookie_test/js_cookie_test.routing.yml deleted file mode 100644 index 5ee89b5496595b446be12ca4803952aa3675acad..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/js_cookie_test/js_cookie_test.routing.yml +++ /dev/null @@ -1,7 +0,0 @@ -js_cookie_test.with_shim: - path: '/js_cookie_with_shim_test' - defaults: - _controller: '\Drupal\js_cookie_test\Controller\JsCookieTestController::jqueryCookieShimTest' - _title: 'JQueryCookieShimTest' - requirements: - _access: 'TRUE' diff --git a/core/modules/system/tests/modules/js_cookie_test/src/Controller/JsCookieTestController.php b/core/modules/system/tests/modules/js_cookie_test/src/Controller/JsCookieTestController.php deleted file mode 100644 index 7cce7cbf3bec6cbb9334a6eed9a1abc656b4b5ca..0000000000000000000000000000000000000000 --- a/core/modules/system/tests/modules/js_cookie_test/src/Controller/JsCookieTestController.php +++ /dev/null @@ -1,59 +0,0 @@ -<?php - -namespace Drupal\js_cookie_test\Controller; - -use Drupal\Core\Controller\ControllerBase; - -/** - * Test controller to assert js-cookie library integration. - */ -class JsCookieTestController extends ControllerBase { - - /** - * Provides buttons to add and remove cookies using JavaScript. - * - * @return array - * The render array. - */ - public function jqueryCookieShimTest() { - return [ - 'add' => [ - '#type' => 'button', - '#value' => $this->t('Add cookie'), - '#attributes' => [ - 'class' => ['js_cookie_test_add_button'], - ], - ], - 'add-raw' => [ - '#type' => 'button', - '#value' => $this->t('Add raw cookie'), - '#attributes' => [ - 'class' => ['js_cookie_test_add_raw_button'], - ], - ], - 'add-json' => [ - '#type' => 'button', - '#value' => $this->t('Add JSON cookie'), - '#attributes' => [ - 'class' => ['js_cookie_test_add_json_button'], - ], - ], - 'add-json-string' => [ - '#type' => 'button', - '#value' => $this->t('Add JSON cookie without json option'), - '#attributes' => [ - 'class' => ['js_cookie_test_add_json_string_button'], - ], - ], - 'remove' => [ - '#type' => 'button', - '#value' => $this->t('Remove cookie'), - '#attributes' => [ - 'class' => ['js_cookie_test_remove_button'], - ], - ], - '#attached' => ['library' => ['js_cookie_test/with_shim_test']], - ]; - } - -} diff --git a/core/tests/Drupal/Nightwatch/Tests/jsCookieTest.js b/core/tests/Drupal/Nightwatch/Tests/jsCookieTest.js deleted file mode 100644 index 69d4f59f617c2e973bddb54a3248bc86bb6a30c3..0000000000000000000000000000000000000000 --- a/core/tests/Drupal/Nightwatch/Tests/jsCookieTest.js +++ /dev/null @@ -1,275 +0,0 @@ -const deprecatedMessageSuffix = `is deprecated in Drupal 9.0.0 and will be removed in Drupal 10.0.0. Use the core/js-cookie library instead. See https://www.drupal.org/node/3104677`; -// Nightwatch suggests non-ES6 functions when using the execute method. -// eslint-disable-next-line func-names, prefer-arrow-callback -const getJqueryCookie = function (cookieName) { - return undefined !== cookieName ? jQuery.cookie(cookieName) : jQuery.cookie(); -}; -// eslint-disable-next-line func-names, prefer-arrow-callback -const setJqueryCookieWithOptions = function ( - cookieName, - cookieValue, - options = {}, -) { - return jQuery.cookie(cookieName, cookieValue, options); -}; -module.exports = { - '@tags': ['core'], - before(browser) { - browser.drupalInstall().drupalLoginAsAdmin(() => { - browser - .drupalRelativeURL('/admin/modules') - .setValue('input[type="search"]', 'JS Cookie Test') - .waitForElementVisible( - 'input[name="modules[js_cookie_test][enable]"]', - 1000, - ) - .click('input[name="modules[js_cookie_test][enable]"]') - .click('input[type="submit"]'); // Submit module form. - }); - }, - after(browser) { - browser.drupalUninstall(); - }, - 'Test jquery.cookie Shim Simple Value and jquery.removeCookie': (browser) => { - browser - .drupalRelativeURL('/js_cookie_with_shim_test') - .waitForElementVisible('.js_cookie_test_add_button', 1000) - .click('.js_cookie_test_add_button') - // prettier-ignore - .execute(getJqueryCookie, ['js_cookie_test'], (result) => { - browser.assert.equal( - result.value, - 'red panda', - '$.cookie returns cookie value', - ); - }) - .waitForElementVisible('.js_cookie_test_remove_button', 1000) - .click('.js_cookie_test_remove_button') - .execute(getJqueryCookie, ['js_cookie_test_remove'], (result) => { - browser.assert.equal(result.value, null, 'cookie removed'); - }) - .drupalLogAndEnd({ onlyOnError: false }); - }, - 'Test jquery.cookie Shim Empty Value': (browser) => { - browser - .setCookie({ - name: 'js_cookie_test_empty', - value: '', - }) - // prettier-ignore - .execute(getJqueryCookie, ['js_cookie_test_empty'], (result) => { - browser.assert.equal( - result.value, - '', - '$.cookie returns empty cookie value', - ); - }) - .getCookie('js_cookie_test_empty', (result) => { - browser.assert.equal(result.value, '', 'Cookie value is empty.'); - }) - .drupalLogAndEnd({ onlyOnError: false }); - }, - 'Test jquery.cookie Shim Undefined': (browser) => { - browser - .deleteCookie('js_cookie_test_undefined', () => { - browser.execute( - getJqueryCookie, - ['js_cookie_test_undefined'], - (result) => { - browser.assert.equal( - result.value, - undefined, - '$.cookie returns undefined cookie value', - ); - }, - ); - }) - .drupalLogAndEnd({ onlyOnError: false }); - }, - 'Test jquery.cookie Shim Decode': (browser) => { - browser - .setCookie({ - name: encodeURIComponent(' js_cookie_test_encoded'), - value: encodeURIComponent(' red panda'), - }) - .execute(getJqueryCookie, [' js_cookie_test_encoded'], (result) => { - browser.assert.equal( - result.value, - ' red panda', - '$.cookie returns decoded cookie value', - ); - }) - .setCookie({ - name: 'js_cookie_test_encoded_plus_to_space', - value: 'red+panda', - }) - .execute( - getJqueryCookie, - ['js_cookie_test_encoded_plus_to_space'], - (result) => { - browser.assert.equal( - result.value, - 'red panda', - '$.cookie returns decoded plus to space in cookie value', - ); - }, - ) - .drupalLogAndEnd({ onlyOnError: false }); - }, - 'Test jquery.cookie Shim With raw': (browser) => { - browser - .drupalRelativeURL('/js_cookie_with_shim_test') - .waitForElementVisible('.js_cookie_test_add_raw_button', 1000) - .click('.js_cookie_test_add_raw_button') - .execute(getJqueryCookie, ['js_cookie_test_raw'], (result) => { - browser.assert.equal( - result.value, - 'red%20panda', - '$.cookie returns raw cookie value', - ); - }) - .drupalLogAndEnd({ onlyOnError: false }); - }, - 'Test jquery.cookie Shim With JSON': (browser) => { - browser - .drupalRelativeURL('/js_cookie_with_shim_test') - .waitForElementVisible('.js_cookie_test_add_json_button', 1000) - .click('.js_cookie_test_add_json_button') - .execute(getJqueryCookie, ['js_cookie_test_json'], (result) => { - browser.assert.deepEqual( - result.value, - { panda: 'red' }, - 'Stringified JSON is returned as JSON.', - ); - }) - .getCookie('js_cookie_test_json', (result) => { - browser.assert.equal( - result.value, - '%7B%22panda%22%3A%22red%22%7D', - 'Cookie value is encoded backwards-compatible with jquery.cookie.', - ); - }) - .execute(getJqueryCookie, ['js_cookie_test_json_simple'], (result) => { - browser.assert.equal( - result.value, - 'red panda', - '$.cookie returns simple cookie value with JSON enabled', - ); - }) - .waitForElementVisible('.js_cookie_test_add_json_string_button', 1000) - .click('.js_cookie_test_add_json_string_button') - .execute(getJqueryCookie, ['js_cookie_test_json_string'], (result) => { - browser.assert.deepEqual( - result.value, - '[object Object]', - 'JSON used without json option is return as a string.', - ); - }) - .getCookie('js_cookie_test_json_string', (result) => { - browser.assert.equal( - result.value, - '%5Bobject%20Object%5D', - 'Cookie value is encoded backwards-compatible with jquery.cookie.', - ); - }) - .drupalLogAndEnd({ onlyOnError: false }); - }, - 'Test jquery.cookie Shim invalid URL encoding': (browser) => { - browser - .setCookie({ - name: 'js_cookie_test_bad', - value: 'red panda%', - }) - .execute(getJqueryCookie, ['js_cookie_test_bad'], (result) => { - browser.assert.equal( - result.value, - undefined, - '$.cookie won`t throw exception, returns undefined', - ); - }) - .drupalLogAndEnd({ onlyOnError: false }); - }, - 'Test jquery.cookie Shim Read all when there are cookies or return empty object': - (browser) => { - browser - .getCookie('SIMPLETEST_USER_AGENT', (simpletestCookie) => { - const simpletestCookieValue = simpletestCookie.value; - browser - .drupalRelativeURL('/js_cookie_with_shim_test') - .deleteCookies(() => { - browser - .execute(getJqueryCookie, [], (result) => { - browser.assert.deepEqual( - result.value, - {}, - '$.cookie() returns empty object', - ); - }) - .setCookie({ - name: 'js_cookie_test_first', - value: 'red panda', - }) - .setCookie({ - name: 'js_cookie_test_second', - value: 'second red panda', - }) - .setCookie({ - name: 'js_cookie_test_third', - value: 'third red panda id bad%', - }) - .execute(getJqueryCookie, [], (result) => { - browser.assert.deepEqual( - result.value, - { - js_cookie_test_first: 'red panda', - js_cookie_test_second: 'second red panda', - }, - '$.cookie() returns object containing all cookies', - ); - }) - .setCookie({ - name: 'SIMPLETEST_USER_AGENT', - value: simpletestCookieValue, - }); - }); - }) - .drupalLogAndEnd({ onlyOnError: false }); - }, - 'Test jquery.cookie Shim $.cookie deprecation message': (browser) => { - browser - .drupalRelativeURL('/js_cookie_with_shim_test') - .waitForElementVisible('.js_cookie_test_add_button', 1000) - .click('.js_cookie_test_add_button') - .assert.deprecationErrorExists( - `jQuery.cookie() ${deprecatedMessageSuffix}`, - ) - .drupalLogAndEnd({ onlyOnError: false }); - }, - 'Test jquery.cookie Shim $.removeCookie deprecation message': (browser) => { - browser - .drupalRelativeURL('/js_cookie_with_shim_test') - .waitForElementVisible('.js_cookie_test_remove_button', 1000) - .click('.js_cookie_test_remove_button') - .assert.deprecationErrorExists( - `jQuery.removeCookie() ${deprecatedMessageSuffix}`, - ) - .drupalLogAndEnd({ onlyOnError: false }); - }, - 'Test jquery.cookie Shim expires option as Date instance': (browser) => { - const sevenDaysFromNow = new Date(); - sevenDaysFromNow.setDate(sevenDaysFromNow.getDate() + 7); - browser - .execute( - setJqueryCookieWithOptions, - ['c', 'v', { expires: sevenDaysFromNow }], - (result) => { - browser.assert.equal( - result.value, - `c=v; expires=${sevenDaysFromNow.toUTCString()}`, - 'should write the cookie string with expires', - ); - }, - ) - .drupalLogAndEnd({ onlyOnError: false }); - }, -};