File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed
javascript/node/selenium-webdriver Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change @@ -1937,6 +1937,11 @@ class Options {
19371937 * when the cookie has been deleted.
19381938 */
19391939 deleteCookie ( name ) {
1940+ // Validate the cookie name is non-empty and properly trimmed.
1941+ if ( ! name ?. trim ( ) ) {
1942+ throw new error . InvalidArgumentError ( 'Cookie name cannot be empty' )
1943+ }
1944+
19401945 return this . driver_ . execute ( new command . Command ( command . Name . DELETE_COOKIE ) . setParameter ( 'name' , name ) )
19411946 }
19421947
Original file line number Diff line number Diff line change @@ -54,7 +54,7 @@ suite(function (env) {
5454 } )
5555 } )
5656
57- it ( 'throw error if name is null' , async function ( ) {
57+ it ( 'Get Cookie: throw error if name is null' , async function ( ) {
5858 const cookie = createCookieSpec ( )
5959 await driver . manage ( ) . addCookie ( cookie )
6060 await assert . rejects ( async ( ) => await driver . manage ( ) . getCookie ( null ) , {
@@ -63,6 +63,15 @@ suite(function (env) {
6363 } )
6464 } )
6565
66+ it ( 'Delete cookie: throw error if name is null' , async function ( ) {
67+ const cookie = createCookieSpec ( )
68+ await driver . manage ( ) . addCookie ( cookie )
69+ await assert . rejects ( async ( ) => await driver . manage ( ) . deleteCookie ( null ) , {
70+ name : 'InvalidArgumentError' ,
71+ message : `Cookie name cannot be empty` ,
72+ } )
73+ } )
74+
6675 it ( 'can get all cookies' , async function ( ) {
6776 const cookie1 = createCookieSpec ( )
6877 const cookie2 = createCookieSpec ( )
You can’t perform that action at this time.
0 commit comments