Test touch emulation more completely (#235)

This commit is contained in:
JoelEinbinder 2017-08-10 18:25:56 -07:00 committed by Andrey Lushnikov
parent 8ccd10bfa2
commit 0a55345060

View File

@ -1410,8 +1410,22 @@ describe('Page', function() {
expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(false); expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(false);
await page.setViewport(iPhone.viewport); await page.setViewport(iPhone.viewport);
expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(true); expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(true);
expect(await page.evaluate(dispatchTouch)).toBe('Recieved touch');
await page.setViewport({width: 100, height: 100}); await page.setViewport({width: 100, height: 100});
expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(false); expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(false);
function dispatchTouch() {
let fulfill;
let promise = new Promise(x => fulfill = x);
window.ontouchstart = function(e) {
fulfill('Recieved touch');
};
window.dispatchEvent(new Event('touchstart'));
fulfill('Did not recieve touch');
return promise;
}
})); }));
it('should support landscape emulation', SX(async function() { it('should support landscape emulation', SX(async function() {
await page.goto(PREFIX + '/mobile.html'); await page.goto(PREFIX + '/mobile.html');