File tree Expand file tree Collapse file tree 2 files changed +19
-0
lines changed
src/org/openqa/selenium/remote Expand file tree Collapse file tree 2 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -869,6 +869,9 @@ public void addCookie(Cookie cookie) {
869
869
870
870
@ Override
871
871
public void deleteCookieNamed (String name ) {
872
+ if (name == null || name .isBlank ()) {
873
+ throw new IllegalArgumentException ("Cookie name cannot be empty" );
874
+ }
872
875
execute (DriverCommand .DELETE_COOKIE (name ));
873
876
}
874
877
@@ -927,6 +930,9 @@ public Set<Cookie> getCookies() {
927
930
928
931
@ Override
929
932
public Cookie getCookieNamed (String name ) {
933
+ if (name == null || name .isBlank ()) {
934
+ throw new IllegalArgumentException ("Cookie name cannot be empty" );
935
+ }
930
936
Set <Cookie > allCookies = getCookies ();
931
937
for (Cookie cookie : allCookies ) {
932
938
if (cookie .getName ().equals (name )) {
Original file line number Diff line number Diff line change 18
18
package org .openqa .selenium ;
19
19
20
20
import static org .assertj .core .api .Assertions .assertThat ;
21
+ import static org .junit .jupiter .api .Assertions .assertThrows ;
21
22
import static org .junit .jupiter .api .Assumptions .assumeTrue ;
22
23
import static org .openqa .selenium .testing .drivers .Browser .ALL ;
23
24
import static org .openqa .selenium .testing .drivers .Browser .CHROME ;
@@ -503,6 +504,18 @@ public void testDeleteNotExistedCookie() {
503
504
driver .manage ().deleteCookieNamed (key );
504
505
}
505
506
507
+ @ Test
508
+ public void testDeleteEmptyNamedCookie () {
509
+ assertThrows (IllegalArgumentException .class , () -> driver .manage ().deleteCookieNamed ("" ));
510
+ assertThrows (IllegalArgumentException .class , () -> driver .manage ().deleteCookieNamed (" " ));
511
+ }
512
+
513
+ @ Test
514
+ public void testGetEmptyNamedCookie () {
515
+ assertThrows (IllegalArgumentException .class , () -> driver .manage ().getCookieNamed ("" ));
516
+ assertThrows (IllegalArgumentException .class , () -> driver .manage ().getCookieNamed (" " ));
517
+ }
518
+
506
519
@ Test
507
520
@ Ignore (value = ALL , reason = "Non W3C conformant" )
508
521
public void testShouldDeleteOneOfTheCookiesWithTheSameName () {
You can’t perform that action at this time.
0 commit comments