Open Bug 463127 Opened 17 years ago Updated 6 months ago

nsICookieManager/CookieService should allow creation of arbitrary cookies for testing

Categories

(Core :: Networking: Cookies, enhancement, P3)

enhancement

Tracking

()

People

(Reporter: johnath, Unassigned)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Writing tests for bug 453440, I needed to create cookies with arbitrary creation times, so that I could test clear private data's time-based functionality. For downloads I can access the database to do this, with places I can do something similar, but the add/setCookieString functions don't support alternate creation time. If we resolve this bug to provide that mechanism, we should also update the tests added in bug 453440.
easy enough to add a creationtime arg to the add() method, though i'm not sure exactly how we'd do it neatly so consumers who want to use the current time don't have to jump through hoops... (or perhaps a single hoop, since getting the time in ms and multiplying by 1000 isn't that hard in js)
Yeah, and given that it's only really needed for testing, it might make more sense to do something more primitive - expose the dbconnection like nsIDownloadManager does, maybe?
nope, since cookies has its own in-memory store, the db is just the on-disk part of it. so we need the API to provide this specifically. having two methods that do almost exactly the same thing would be a bit weird, but if there are other reasons to do it, then sure...
Status: NEW → RESOLVED
Closed: 9 years ago
Resolution: --- → INCOMPLETE

This still seems worth having! Particularly for the data sanitization tests.

Status: RESOLVED → REOPENED
Resolution: INCOMPLETE → ---
Severity: normal → S3
Type: defect → enhancement
Priority: -- → P3
Whiteboard: [necko-triaged]
Blocks: cookie
Status: REOPENED → NEW

What format/type should this API take?

(In reply to edgul from comment #5)

What format/type should this API take?

Could be an extension of https://searchfox.org/mozilla-central/rev/345ec3c55ddda5f0ce37168f0644dcdcc4834409/netwerk/cookie/nsICookieManager.idl#128 with an optional argument to set the creation time. Or we add a separate test-only method. That might be cleaner.
Hannah tried that a while ago, but we rolled the change back due to some regression in release.

I think the addForTest method added in https://phabricator.services.mozilla.com/D170377#change-HC1mDTCLgPWk was about right.
The problem with the implementation is that it ended up calling AddNative, and passing an invalid timestamp - see regression in bug 1827669.

See Also: → 1819529
You need to log in before you can comment on or make changes to this bug.