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 are leaking from the "should isolate cookies in browser contexts" test #12010

Closed
OrKoN opened this issue Feb 27, 2024 · 7 comments
Closed

Comments

@OrKoN
Copy link
Collaborator

OrKoN commented Feb 27, 2024

Apparently, only in Firefox CDP.

Enable the following two tests:

  Cookie specs
    Page.setCookie
      ✔ should isolate cookies in browser contexts (122ms)

  DefaultBrowserContext
    ✔ page.cookies() should work (58ms)

Run npm run test:firefox:headless

Actual results:

  1) Cookie specs
       Page.setCookie
         should isolate cookies in browser contexts:
     Error: expect(received).toHaveLength(expected)

Expected length: 1
Received length: 2
Received array:  [{"domain": "localhost", "expires": -1, "httpOnly": false, "name": "page1cookie", "path": "/", "secure": false, "session": true, "size": 21, "value": "page1value"}, {"domain": "localhost", "expires": -1, "httpOnly": false, "name": "page2cookie", "path": "/", "secure": false, "session": true, "size": 21, "value": "page2value"}]
      at Context.<anonymous> (test/src/cookies.spec.ts:240:24)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)

  2) DefaultBrowserContext
       page.cookies() should work:
     Error: expect(received).toHaveLength(expected)

Expected length: 1
Received length: 3
Received array:  [{"domain": "localhost", "expires": -1, "httpOnly": false, "name": "page1cookie", "path": "/", "secure": false, "session": true, "size": 21, "value": "page1value"}, {"domain": "localhost", "expires": -1, "httpOnly": false, "name": "page2cookie", "path": "/", "secure": false, "session": true, "size": 21, "value": "page2value"}, {"domain": "localhost", "expires": -1, "httpOnly": false, "name": "username", "path": "/", "secure": false, "session": true, "size": 16, "value": "John Doe"}]
      at expectCookieEquals (test/src/mocha-utils.ts:396:19)
      at Context.<anonymous> (test/src/defaultbrowsercontext.spec.ts:25:29)
      at processTicksAndRejections (node:internal/process/task_queues:95:5)
@OrKoN

This comment was marked as outdated.

@OrKoN OrKoN added the P1 label Feb 28, 2024
@OrKoN
Copy link
Collaborator Author

OrKoN commented Feb 28, 2024

@whimboo it looks like the root cause of this is that Firefox CDP does not isolate the user contexts.

@OrKoN
Copy link
Collaborator Author

OrKoN commented Feb 28, 2024

The context is closed and re-created in getTestState so the second test should have blank state.

@OrKoN OrKoN closed this as not planned Won't fix, can't repro, duplicate, stale Feb 28, 2024
@whimboo
Copy link
Collaborator

whimboo commented Feb 29, 2024

The context is closed and re-created in getTestState so the second test should have blank state.

Not for the page1cookie cookie given that this is added to the default context. In both tests we use the page and not context to set it. As such it will not be removed after removing a given user context. Or do I miss something?

@whimboo whimboo reopened this Feb 29, 2024
@OrKoN
Copy link
Collaborator Author

OrKoN commented Feb 29, 2024

@whimboo the default context is an incognito user context as well (see GetTestState)

@OrKoN OrKoN closed this as not planned Won't fix, can't repro, duplicate, stale Feb 29, 2024
@whimboo
Copy link
Collaborator

whimboo commented Mar 5, 2024

@OrKoN would it be ok with you if we mark [defaultbrowsercontext.spec] DefaultBrowserContext page.cookies() should work as intermittently failing with CDP for Firefox? It's perma failing in our CI when I sync 22.4.0

@OrKoN
Copy link
Collaborator Author

OrKoN commented Mar 5, 2024

@whimboo I have opened a PR to mark it as pass/fail

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants