diff --git a/java/client/test/org/openqa/selenium/CookieImplementationTest.java b/java/client/test/org/openqa/selenium/CookieImplementationTest.java index 136b5dceb46ce..3fcb18f66b8c3 100644 --- a/java/client/test/org/openqa/selenium/CookieImplementationTest.java +++ b/java/client/test/org/openqa/selenium/CookieImplementationTest.java @@ -40,11 +40,15 @@ import static org.openqa.selenium.testing.Ignore.Driver.ALL; import static org.openqa.selenium.testing.Ignore.Driver.ANDROID; import static org.openqa.selenium.testing.Ignore.Driver.CHROME; +import static org.openqa.selenium.testing.Ignore.Driver.FIREFOX; import static org.openqa.selenium.testing.Ignore.Driver.HTMLUNIT; import static org.openqa.selenium.testing.Ignore.Driver.IE; import static org.openqa.selenium.testing.Ignore.Driver.IPHONE; import static org.openqa.selenium.testing.Ignore.Driver.OPERA; +import static org.openqa.selenium.testing.Ignore.Driver.OPERA_MOBILE; +import static org.openqa.selenium.testing.Ignore.Driver.PHANTOMJS; import static org.openqa.selenium.testing.Ignore.Driver.REMOTE; +import static org.openqa.selenium.testing.Ignore.Driver.SAFARI; public class CookieImplementationTest extends JUnit4TestBase { @@ -359,6 +363,21 @@ public void testRetainsCookieExpiry() { assertEquals(addedCookie.getExpiry(), retrieved.getExpiry()); } + @Ignore(value = {ANDROID, CHROME, FIREFOX, HTMLUNIT, IE, OPERA, OPERA_MOBILE, PHANTOMJS, SAFARI}) + @Test + public void testRetainsHttpOnlyFlag() { + Cookie addedCookie = + new Cookie.Builder("fish", "cod") + .path("/common/animals") + .isHttpOnly(true) + .build(); + driver.manage().addCookie(addedCookie); + + Cookie retrieved = driver.manage().getCookieNamed("fish"); + assertNotNull(retrieved); + assertTrue(retrieved.isHttpOnly()); + } + @Ignore(ANDROID) @Test public void testSettingACookieThatExpiredInThePast() { diff --git a/java/client/test/org/openqa/selenium/remote/BeanToJsonConverterTest.java b/java/client/test/org/openqa/selenium/remote/BeanToJsonConverterTest.java index ab0c44e5c95b4..40fb503cafa3c 100644 --- a/java/client/test/org/openqa/selenium/remote/BeanToJsonConverterTest.java +++ b/java/client/test/org/openqa/selenium/remote/BeanToJsonConverterTest.java @@ -333,7 +333,7 @@ public Date getDate() { @Test public void testShouldBeAbleToConvertACookie() throws JSONException { Date expiry = new Date(); - Cookie cookie = new Cookie("name", "value", "domain", "/path", expiry, true); + Cookie cookie = new Cookie("name", "value", "domain", "/path", expiry, true, true); String jsonStr = new BeanToJsonConverter().convert(cookie); JSONObject json = new JSONObject(jsonStr); @@ -343,6 +343,7 @@ public void testShouldBeAbleToConvertACookie() throws JSONException { assertEquals("domain", json.getString("domain")); assertEquals("/path", json.getString("path")); assertTrue(json.getBoolean("secure")); + assertTrue(json.getBoolean("httpOnly")); assertEquals(TimeUnit.MILLISECONDS.toSeconds(expiry.getTime()), json.getLong("expiry")); } diff --git a/java/client/test/org/openqa/selenium/remote/JsonToBeanConverterTest.java b/java/client/test/org/openqa/selenium/remote/JsonToBeanConverterTest.java index 3708e52ebf446..fbaa3cdd8d503 100644 --- a/java/client/test/org/openqa/selenium/remote/JsonToBeanConverterTest.java +++ b/java/client/test/org/openqa/selenium/remote/JsonToBeanConverterTest.java @@ -224,7 +224,7 @@ public void testCanHandleValueBeingAnArray() throws Exception { @Test public void testShouldConvertObjectsInArraysToMaps() throws Exception { Date date = new Date(); - Cookie cookie = new Cookie("foo", "bar", "/rooted", date); + Cookie cookie = new Cookie("foo", "bar", "localhost", "/rooted", date, true, true); String rawJson = new BeanToJsonConverter().convert(Collections.singletonList(cookie)); List list = new JsonToBeanConverter().convert(List.class, rawJson); @@ -235,7 +235,10 @@ public void testShouldConvertObjectsInArraysToMaps() throws Exception { Map map = (Map) first; assertMapEntry(map, "name", "foo"); assertMapEntry(map, "value", "bar"); + assertMapEntry(map, "domain", "localhost"); assertMapEntry(map, "path", "/rooted"); + assertMapEntry(map, "secure", true); + assertMapEntry(map, "httpOnly", true); assertMapEntry(map, "expiry", TimeUnit.MILLISECONDS.toSeconds(date.getTime())); }