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

After upgrade to Firefox 56, addCookie function domain will change to current browser url #1025

Open
charlesh21 opened this issue Oct 23, 2017 · 8 comments

Comments

@charlesh21
Copy link

System

  • Version: 0.19.0
  • Platform: Windows 7
  • Firefox: 56
  • Protractor: 5.2.0
  • Selenium: 3.6.0

Testcase

After upgrade to Firefox 56, our automation testing can't add cookie correctly into Firefox.
I found the suspicious part in cookie domain, the add cookie log seems work as expected.
But after add cookie, I try to print all cookie with getCookies method. The domain changed to the browser current url.

AddCookie
"domain":".yahoo.com"

getCookies
"domain":"tw-b2.beta.mall.yahoo.com"

addCookie

1508748645562   webdriver::server       DEBUG   -> POST /session/cdca0bf9-c8bb-9e49-90de-4579c2a2df57/cookie {"cookie":{"path":"/","domain":".yahoo.com","name":"Y","httpOnly":false,"expiry":1540284478,"secure":false,"value":"v=1&n=filf2ka19gjj6&l=og0_jm_ijeh4_58h45en_1ko_qt/o&p=f2729a8412000800&jb=36|32|9&r=110&lg=en-US&intl=us&np=1"}}
1508748645562   geckodriver::marionette TRACE   -> 247:[0,17,"addCookie",{"cookie":{"domain":".yahoo.com","expiry":1540284478,"httpOnly":false,"name":"Y","path":"/","secure":false,"value":"v=1&n=filf2ka19gjj6&l=og0_jm_ijeh4_58h45en_1ko_qt/o&p=f2729a8412000800&jb=36|32|9&r=110&lg=en-US&intl=us&np=1"}}]
1508748645564   Marionette      TRACE   0 -> [0,17,"addCookie",{"cookie":{"domain":".yahoo.com","expiry":1540284478,"httpOnly":false,"name":"Y","path":"/","secure":false,"value":"v=1&n=filf2ka19gjj6&l=og0_jm_ijeh4_58h45en_1ko_qt/o&p=f2729a8412000800&jb=36|32|9&r=110&lg=en-US&intl=us&np=1"}}]
1508748645565   Marionette      TRACE   0 <- [1,17,null,{}]
1508748645568   geckodriver::marionette TRACE   <- [1,17,null,{}]
1508748645568   webdriver::server       DEBUG   <- 200 OK {"value": {}}

getCookies

1508748652055   webdriver::server       DEBUG   -> GET /session/cdca0bf9-c8bb-9e49-90de-4579c2a2df57/cookie
1508748652056   geckodriver::marionette TRACE   -> 22:[0,24,"getCookies",{}]
1508748652057   Marionette      TRACE   0 -> [0,24,"getCookies",{}]
1508748652060   Marionette      TRACE   0 <- [1,24,null,[{"name":"Y","value":"v=1&n=filf2ka19gjj6&l=og0_jm_ijeh4_58h45en_1ko_qt/o&p=f2729a8412000800&jb=36|32|9&r=110&lg=en-US&intl=us&np=1","path":"/","domain":"tw-b2.beta.mall.yahoo.com","secure":false,"httpOnly":false,"expiry":1540284478}]]
@whimboo
Copy link
Collaborator

whimboo commented Nov 1, 2017

@charlesh21 can you please test with a recent Firefox 57 beta, or even 58 nightly build, if the problem still persists for you?

@charlesh21
Copy link
Author

charlesh21 commented Nov 2, 2017

Hi @whimboo,
I tried to do some test as below combination, the addCookie return error "invalid cookie domain".

geckodriver 0.19.0 + firefox 57.0b13
geckodriver 0.19.0 + firefox 58.0a1
geckodriver 0.19.1 + firefox 56.0.2

1509607282748   webdriver::server       DEBUG   -> POST /session/d66935e0-ca03-9d44-957e-c4810ff093da/cookie {"cookie":{"path":"/","domain":".yahoo.com","name":"AO","httpOnly":false,"expiry":2140745802,"secure":false,"value":"u=1"}}
1509607282749   geckodriver::marionette TRACE   -> 142:[0,10,"addCookie",{"cookie":{"domain":".yahoo.com","expiry":2140745802,"httpOnly":false,"name":"AO","path":"/","secure":false,"value":"u=1"}}]
1509607282750   Marionette      TRACE   0 -> [0,10,"addCookie",{"cookie":{"domain":".yahoo.com","expiry":2140745802,"httpOnly":false,"name":"AO","path":"/","secure":false,"value":"u=1"}}]
1509607282751   Marionette      TRACE   0 <- [1,10,{"error":"invalid cookie domain","message":".yahoo.com","stacktrace":"WebDriverError@chrome://marionette/content/error.js:239:5\nInvalidCookieDomainError@chrome://marionette/content/error.js:373:5\ncookie.add@chrome://marionette/content/cookie.js:131:15\nGeckoDriver.prototype.addCookie@chrome://marionette/content/driver.js:2638:3\ndespatch@chrome://marionette/content/server.js:553:20\nexecute@chrome://marionette/content/server.js:527:11\nonPacket/<@chrome://marionette/content/server.js:502:15\nonPacket@chrome://marionette/content/server.js:501:8\n_onJSONObjectReady/<@chrome://marionette/content/transport.js:501:9\n"},null]
1509607282753   geckodriver::marionette TRACE   <- [1,10,{"error":"invalid cookie domain","message":".yahoo.com","stacktrace":"WebDriverError@chrome://marionette/content/error.js:239:5\nInvalidCookieDomainError@chrome://marionette/content/error.js:373:5\ncookie.add@chrome://marionette/content/cookie.js:131:15\nGeckoDriver.prototype.addCookie@chrome://marionette/content/driver.js:2638:3\ndespatch@chrome://marionette/content/server.js:553:20\nexecute@chrome://marionette/content/server.js:527:11\nonPacket/<@chrome://marionette/content/server.js:502:15\nonPacket@chrome://marionette/content/server.js:501:8\n_onJSONObjectReady/<@chrome://marionette/content/transport.js:501:9\n"},null]
1509607282753   webdriver::server       DEBUG   <- 400 Bad Request {"value":{"error":"invalid cookie domain","message":".yahoo.com","stacktrace":"WebDriverError@chrome://marionette/content/error.js:239:5\nInvalidCookieDomainError@chrome://marionette/content/error.js:373:5\ncookie.add@chrome://marionette/content/cookie.js:131:15\nGeckoDriver.prototype.addCookie@chrome://marionette/content/driver.js:2638:3\ndespatch@chrome://marionette/content/server.js:553:20\nexecute@chrome://marionette/content/server.js:527:11\nonPacket/<@chrome://marionette/content/server.js:502:15\nonPacket@chrome://marionette/content/server.js:501:8\n_onJSONObjectReady/<@chrome://marionette/content/transport.js:501:9\n"}}

@charlesh21
Copy link
Author

Hi @whimboo
I saw the ticket #719, so add cookie with domain value ".yahoo.com" will be verified as invalid cookie domain?

@charlesh21
Copy link
Author

I just used the Firefox 57.0b13 and browse the google website.

The cookie domain is ".google.com" with leading dot.

It seems the gecko driver behavior different with the real Firefox browser.

screen shot 2017-11-03 at 4 36 03 pm

@aldaris
Copy link

aldaris commented Nov 8, 2017

I think the webdriver spec is not specific enough about domain representations. RFC6265 states:

If the first character of the attribute-value string is %x2E ("."):
Let cookie-domain be the attribute-value without the leading %x2E
(".") character.

I think the problem in your case is that the cookie domain has a leading dot character which is rejected by marionette as an invalid domain. This is probably because there are no tests currently for domain values with preceding dot characters.

The webdriver spec doesn't spell out whether the leading dot in the cookie domain is an accepted representation of a cookie domain, but I feel that the expectation should be that both works and as long as a domain value is provided to add cookie command it is treated as a cookie domain (and the preceding dot is normalized by the browser).

This feels like a bug that should be addressed in marionette.

@andreastt
Copy link
Contributor

@aldaris Do you mind filing an issue on w3c/webdriver?

@aldaris
Copy link

aldaris commented Nov 9, 2017

@andreastt I have filed a bug for Marionette: https://bugzilla.mozilla.org/show_bug.cgi?id=1415828
and for w3c: w3c/webdriver#1143

@charlesh21
Copy link
Author

@aldaris Thank you very much.

If we can support cookie domain with leading dot, that's really helpful.

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

4 participants