@@ -177,6 +177,38 @@ describe('debugger module', () => {
177177 await loadingFinished ;
178178 } ) ;
179179
180+ it ( 'can get and set cookies using the Storage API' , async ( ) => {
181+ await w . webContents . loadURL ( 'about:blank' ) ;
182+ w . webContents . debugger . attach ( '1.1' ) ;
183+
184+ await w . webContents . debugger . sendCommand ( 'Storage.clearCookies' , { } ) ;
185+ await w . webContents . debugger . sendCommand ( 'Storage.setCookies' , {
186+ cookies : [
187+ {
188+ name : 'cookieOne' ,
189+ value : 'cookieValueOne' ,
190+ url : 'https://cookieone.com'
191+ } ,
192+ {
193+ name : 'cookieTwo' ,
194+ value : 'cookieValueTwo' ,
195+ url : 'https://cookietwo.com'
196+ }
197+ ]
198+ } ) ;
199+
200+ const { cookies } = await w . webContents . debugger . sendCommand ( 'Storage.getCookies' , { } ) ;
201+ expect ( cookies ) . to . have . lengthOf ( 2 ) ;
202+
203+ const cookieOne = cookies . find ( ( cookie : any ) => cookie . name === 'cookieOne' ) ;
204+ expect ( cookieOne . domain ) . to . equal ( 'cookieone.com' ) ;
205+ expect ( cookieOne . value ) . to . equal ( 'cookieValueOne' ) ;
206+
207+ const cookieTwo = cookies . find ( ( cookie : any ) => cookie . name === 'cookieTwo' ) ;
208+ expect ( cookieTwo . domain ) . to . equal ( 'cookietwo.com' ) ;
209+ expect ( cookieTwo . value ) . to . equal ( 'cookieValueTwo' ) ;
210+ } ) ;
211+
180212 it ( 'uses empty sessionId by default' , async ( ) => {
181213 w . webContents . loadURL ( 'about:blank' ) ;
182214 w . webContents . debugger . attach ( ) ;
0 commit comments