Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cookies with 'expires' values in the past aren't deleted properly and are still sent with requests #7432

Closed
andrewh-agl opened this issue Dec 21, 2022 · 2 comments · Fixed by DevExpress/testcafe-hammerhead#2830
Labels
TYPE: bug The described behavior is considered as wrong (bug).

Comments

@andrewh-agl
Copy link

What is your Scenario?

Cookies deleted using an 'expires' date in the past, without setting any 'max-age' property, aren't deleted properly and are still sent with requests.

This is almost exactly the same issue to the one recently fixed in DevExpress/testcafe-hammerhead#2818, but that PR focused on cookies that used only 'max-age', rather than only 'expires'.

What is the Current behavior?

We use a 3rd party Javascript library on our website that deletes its cookies using past dated expiry values like this:

document.cookie = "MY_COOKIE=; path=/; expires=Sun, 18 Dec 2022 22:53:55 GMT;" // date is in the past

They do not set any 'max-age' values.

Testcafe is not deleting these past dated cookies and is still sending them with http requests

What is the Expected behavior?

Cookies with past dated expiry values should be deleted and not sent with http requests even if the cookie is not set with a max-age property

What is your public website URL? (or attach your complete example)

I used localhost - see 'Steps to Reproduce'

What is your TestCafe test code?

see: cookie.test.js

Your complete configuration file

No response

Your complete test report

✖ expect a deleted cookie to be gone

  1. AssertionError: expected 'MY_COOKIE=' to deeply equal ''

    • expected - actual

    -MY_COOKIE=
    +''

    Browser: Chrome 108.0.0.0 / macOS 10.15.7

    13 | await t.navigateTo("/");
    14 | await t.expect(await getCookie()).eql("MY_COOKIE=Hello");
    15 |
    16 | await t.click(clearCookieButton);
    17 | await t.navigateTo("/");

    18 | await t.expect(await getCookie()).eql("");
    19 |}).disablePageCaching;

Screenshots

No response

Steps to Reproduce

  1. git clone https://github.com/andrewh-agl/testcafe-cookie-test
  2. run npm install and npm run serve in one terminal
  3. run npm run test in a second terminal

The crux of the issue is the deletion of the cookie using a past dated expiry in the index.html

TestCafe version

2.2.0-rc.1

Node.js version

v14.18.1

Command-line arguments

chrome test/cookie.test.js

Browser name(s) and version(s)

Chrome 108

Platform(s) and version(s)

macOS 12.6

Other

No response

@andrewh-agl andrewh-agl added the TYPE: bug The described behavior is considered as wrong (bug). label Dec 21, 2022
@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Dec 21, 2022
@Aleksey28
Copy link
Collaborator

Hi @andrewh-agl,

There is a PR with a fix. It will be merged and published in the nearest release after 2.2.0.

@need-response-app need-response-app bot removed the STATE: Need response An issue that requires a response or attention from the team. label Dec 26, 2022
@andrewh-agl
Copy link
Author

Thanks @Aleksey28 for addressing this issue, I'll try it out when the new release is published

@need-response-app need-response-app bot added the STATE: Need response An issue that requires a response or attention from the team. label Jan 8, 2023
@Aleksey28 Aleksey28 removed the STATE: Need response An issue that requires a response or attention from the team. label Jan 9, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
TYPE: bug The described behavior is considered as wrong (bug).
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants