-
Notifications
You must be signed in to change notification settings - Fork 9.3k
TouchScreen.tap #639
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
TouchScreen.tap #639
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,35 @@ | ||
| <!DOCTYPE html> | ||
| <html> | ||
| <head> | ||
| <title>Touch test</title> | ||
| </head> | ||
| <body> | ||
| <script src="mouse-helper.js"></script> | ||
| <button onclick="clicked();">Click target</button> | ||
| <script> | ||
| window.result = []; | ||
| const button = document.querySelector('button'); | ||
| button.style.height = '200px'; | ||
| button.style.width = '200px'; | ||
| button.focus(); | ||
| button.addEventListener('touchstart', event => { | ||
| log('Touchstart:', ...Array.from(event.changedTouches).map(touch => touch.identifier)); | ||
| }); | ||
| button.addEventListener('touchend', event => { | ||
| log('Touchend:', ...Array.from(event.changedTouches).map(touch => touch.identifier)); | ||
| }); | ||
| button.addEventListener('touchmove', event => { | ||
| log('Touchmove:', ...Array.from(event.changedTouches).map(touch => touch.identifier)); | ||
| }); | ||
| function log(...args) { | ||
| console.log.apply(console, args); | ||
| result.push(args.join(' ')); | ||
| } | ||
| function getResult() { | ||
| let temp = result; | ||
| result = []; | ||
| return temp; | ||
| } | ||
| </script> | ||
| </body> | ||
| </html> | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1509,6 +1509,17 @@ describe('Page', function() { | |
| [200, 300] | ||
| ]); | ||
| })); | ||
| it('should tap the button', SX(async function() { | ||
| await page.goto(PREFIX + '/input/button.html'); | ||
|
||
| await page.tap('button'); | ||
| expect(await page.evaluate(() => result)).toBe('Clicked'); | ||
| })); | ||
| it('should report touches', SX(async function() { | ||
| await page.goto(PREFIX + '/input/touches.html'); | ||
| const button = await page.$('button'); | ||
| await button.tap(); | ||
| expect(await page.evaluate(() => getResult())).toEqual(['Touchstart: 0', 'Touchend: 0']); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Out of curiosity, how's There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. it clears the result |
||
| })); | ||
| function dimensions() { | ||
| const rect = document.querySelector('textarea').getBoundingClientRect(); | ||
| return { | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
don't we have the same asset for mouse? Can we unify the two, simply recording all the events for the button?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is a similar one for keyboard, but it has a textarea.