mirror of
https://github.com/puppeteer/puppeteer
synced 2024-06-14 14:02:48 +00:00
Test touch emulation more completely (#235)
This commit is contained in:
parent
8ccd10bfa2
commit
0a55345060
14
test/test.js
14
test/test.js
@ -1410,8 +1410,22 @@ describe('Page', function() {
|
||||
expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(false);
|
||||
await page.setViewport(iPhone.viewport);
|
||||
expect(await page.evaluate(() => 'ontouchstart' in window)).toBe(true);
|
||||
expect(await page.evaluate(dispatchTouch)).toBe('Recieved touch');
|
||||
await page.setViewport({width: 100, height: 100});
|
||||
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() {
|
||||
await page.goto(PREFIX + '/mobile.html');
|
||||
|
Loading…
Reference in New Issue
Block a user