WebDriver:AddCookie fails for a singlepart domains
Categories
(Remote Protocol :: Marionette, defect, P3)
Tracking
(Not tracked)
People
(Reporter: barancev, Unassigned)
References
(Blocks 2 open bugs)
Details
Attachments
(1 file)
23.69 KB,
text/plain
|
Details |
Reporter | ||
Comment 1•6 years ago
|
||
Updated•6 years ago
|
Comment 2•6 years ago
|
||
Updated•6 years ago
|
Updated•6 years ago
|
Comment 3•6 years ago
|
||
Comment 4•6 years ago
|
||
Comment 5•6 years ago
|
||
Comment 6•6 years ago
|
||
Comment 7•5 years ago
|
||
I did some digging around this issue, here's my understanding of the problem:
The cookie creation with a single component domain currently fails, because Marionette's internal processing determines that the cookie is meant to be a domain cookie, and as such it should have a leading dot character (because that's how the Firefox cookie manager differentiates domain cookies from host-only cookies). The browser's cookie manager then does its own processing of the domain value and determines that a single component domain is not valid for a domain cookie, and it throws an error.
A workaround to get things rolling with released versions of Firefox would be to not set the domain for the webdriver request, with Selenium and Java this would look something like:
driver.manage().addCookie(new Cookie("xxx", "yyy", null, "/", null));
The restriction to have at least two subdomain parts for domain cookies seems to be a Firefox design decision, but quite possibly there are other restrictions as well (like ensuring that the domain is not an exact match with a public suffix, like co.uk).
Marionette's current cookie implementation currently works like this:
- if the domain attribute is not present in the AddCookie request, treat the cookie as a host-only cookie (i.e. extract the domain from the current browsing context and ensure that it does not have a leading dot)
- if the domain attribute is present AND it's not an IP address, treat the cookie as a domain cookie (i.e. ensure the domain value has a leading dot)
The IP address caveat above was added to resolve Bug 1407675, which was quite similar to this issue really (not setting the domain attribute in that request could have been considered a valid fix for that issue just as well).
One possible way to resolve this inconsistency would be to update the hostOnly detection:
if (typeof newCookie.domain == "undefined") {
hostOnly = true;
newCookie.domain = restrictToHost;
} else if (newCookie.domain.indexOf(".") == -1) {
hostOnly = true;
}
This leaves behind only one edge-case: user submitting domain .localhost
, which I'm not really sure we need to handle.
At the end of the day some of the pain around host only cookie handling is coming from the fact that the spec doesn't really explain how host only and domain cookies should be differentiated from each other in webdriver requests/responses, see:
https://github.com/w3c/webdriver/issues/1143
Updated•2 years ago
|
Updated•2 years ago
|
Description
•