add tests
This commit is contained in:
parent
92dc2bba2f
commit
25816c1c50
|
|
@ -83,9 +83,25 @@ it('should round-trip through the file', async ({ contextFactory }, testInfo) =>
|
||||||
route.fulfill({ body: '<html></html>' }).catch(() => {});
|
route.fulfill({ body: '<html></html>' }).catch(() => {});
|
||||||
});
|
});
|
||||||
await page1.goto('https://www.example.com');
|
await page1.goto('https://www.example.com');
|
||||||
await page1.evaluate(() => {
|
await page1.evaluate(async () => {
|
||||||
localStorage['name1'] = 'value1';
|
localStorage['name1'] = 'value1';
|
||||||
document.cookie = 'username=John Doe';
|
document.cookie = 'username=John Doe';
|
||||||
|
|
||||||
|
await new Promise((resolve, reject) => {
|
||||||
|
const openRequest = indexedDB.open('db', 42);
|
||||||
|
openRequest.onupgradeneeded = () => {
|
||||||
|
openRequest.result.createObjectStore('store');
|
||||||
|
|
||||||
|
};
|
||||||
|
openRequest.onsuccess = () => {
|
||||||
|
const request = openRequest.result.transaction('store', 'readwrite')
|
||||||
|
.objectStore('store')
|
||||||
|
.put('foo', 'bar');
|
||||||
|
request.addEventListener('success', resolve);
|
||||||
|
request.addEventListener('error', reject);
|
||||||
|
};
|
||||||
|
});
|
||||||
|
|
||||||
return document.cookie;
|
return document.cookie;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
@ -104,6 +120,18 @@ it('should round-trip through the file', async ({ contextFactory }, testInfo) =>
|
||||||
expect(localStorage).toEqual({ name1: 'value1' });
|
expect(localStorage).toEqual({ name1: 'value1' });
|
||||||
const cookie = await page2.evaluate('document.cookie');
|
const cookie = await page2.evaluate('document.cookie');
|
||||||
expect(cookie).toEqual('username=John Doe');
|
expect(cookie).toEqual('username=John Doe');
|
||||||
|
const idbValue = await page2.evaluate(() => new Promise<string>((resolve, reject) => {
|
||||||
|
const openRequest = indexedDB.open('db', 42);
|
||||||
|
openRequest.addEventListener('success', () => {
|
||||||
|
const db = openRequest.result;
|
||||||
|
const transaction = db.transaction('store', 'readonly');
|
||||||
|
const getRequest = transaction.objectStore('store').get('bar');
|
||||||
|
getRequest.addEventListener('success', () => resolve(getRequest.result));
|
||||||
|
getRequest.addEventListener('error', () => reject(getRequest.error));
|
||||||
|
});
|
||||||
|
openRequest.addEventListener('error', () => reject(openRequest.error));
|
||||||
|
}));
|
||||||
|
expect(idbValue).toEqual('foo');
|
||||||
await context2.close();
|
await context2.close();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -352,7 +352,25 @@ it('should preserve local storage on import/export of storage state', async ({ p
|
||||||
name: 'name1',
|
name: 'name1',
|
||||||
value: 'value1'
|
value: 'value1'
|
||||||
}],
|
}],
|
||||||
indexedDB: [],
|
indexedDB: [
|
||||||
|
{
|
||||||
|
name: 'db',
|
||||||
|
version: 5,
|
||||||
|
stores: [
|
||||||
|
{
|
||||||
|
name: 'store',
|
||||||
|
keyPath: 'id',
|
||||||
|
autoIncrement: false,
|
||||||
|
indexes: [],
|
||||||
|
records: [
|
||||||
|
{
|
||||||
|
value: { id: 'foo', name: 'John Doe' }
|
||||||
|
}
|
||||||
|
],
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
},
|
},
|
||||||
]
|
]
|
||||||
};
|
};
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue