|
@@ -177,6 +177,38 @@ describe('debugger module', () => {
|
|
|
await loadingFinished;
|
|
|
});
|
|
|
|
|
|
+ it('can get and set cookies using the Storage API', async () => {
|
|
|
+ await w.webContents.loadURL('about:blank');
|
|
|
+ w.webContents.debugger.attach('1.1');
|
|
|
+
|
|
|
+ await w.webContents.debugger.sendCommand('Storage.clearCookies', {});
|
|
|
+ await w.webContents.debugger.sendCommand('Storage.setCookies', {
|
|
|
+ cookies: [
|
|
|
+ {
|
|
|
+ name: 'cookieOne',
|
|
|
+ value: 'cookieValueOne',
|
|
|
+ url: 'https://cookieone.com'
|
|
|
+ },
|
|
|
+ {
|
|
|
+ name: 'cookieTwo',
|
|
|
+ value: 'cookieValueTwo',
|
|
|
+ url: 'https://cookietwo.com'
|
|
|
+ }
|
|
|
+ ]
|
|
|
+ });
|
|
|
+
|
|
|
+ const { cookies } = await w.webContents.debugger.sendCommand('Storage.getCookies', {});
|
|
|
+ expect(cookies).to.have.lengthOf(2);
|
|
|
+
|
|
|
+ const cookieOne = cookies.find((cookie: any) => cookie.name === 'cookieOne');
|
|
|
+ expect(cookieOne.domain).to.equal('cookieone.com');
|
|
|
+ expect(cookieOne.value).to.equal('cookieValueOne');
|
|
|
+
|
|
|
+ const cookieTwo = cookies.find((cookie: any) => cookie.name === 'cookieTwo');
|
|
|
+ expect(cookieTwo.domain).to.equal('cookietwo.com');
|
|
|
+ expect(cookieTwo.value).to.equal('cookieValueTwo');
|
|
|
+ });
|
|
|
+
|
|
|
it('uses empty sessionId by default', async () => {
|
|
|
w.webContents.loadURL('about:blank');
|
|
|
w.webContents.debugger.attach();
|