gardr / validator

MIT License
3 stars 0 forks source link

Detect vertical scroll/touch-usage #3

Closed sveisvei closed 10 years ago

sveisvei commented 10 years ago

Need to identify/find the event handler function that decides to preventDefault, and try to run it.

sveisvei commented 10 years ago

It is possible to emulate events somewhat, but its an non-standard implementation in phantoms webkit engine:

var touchEvent = document.createEvent('TouchEvent');
touchEvent.initTouchEvent(
                //touches
               document.createTouchList(document.createTouch(window, elem, 1, 2, 1, 2, 1, 2)),
                //targetTouches
                [],
                //changedTouches
                [],
                //type
               'touchstart',
                //view
                window,
                //screenX
                0,
                //screenY
                0,
                //clientX
                123,
                //clientY
                321,
                //ctrlKey
                false,
                //altKey
                false,
                //shiftKey
                false,
                //metaKey
                false
            );
elem.dispatchEvent(touchEvent);

TouchList seams missing, so unsure how to make touches work against code that expect this.

I think our best option is to move over from phantom to use chrome directly with X and via remote debugger.

leftieFriele commented 10 years ago

My experience with running automation of a browser with X are mostly bad. It is unstable and very much prone to errors. That is why phantom was created, to ease this pain. We should consider carefully if moving to X based solution is something we must do or if we can provide something "good enough" for the touch stuff and keeping our current setup. On Mar 13, 2014 8:17 AM, "Sveinung Røsaker" notifications@github.com wrote:

It is possible to emulate events somewhat, but its an non-standard implementation in phantoms webkit engine:

var touchEvent = document.createEvent('TouchEvent'); touchEvent.initTouchEvent( //touches [], //targetTouches [], //changedTouches [], //type 'touchstart', //view window, //screenX 0, //screenY 0, //clientX 123, //clientY 321, //ctrlKey false, //altKey false, //shiftKey false, //metaKey false ); elem.dispatchEvent(touchEvent);

TouchList seams missing, so unsure how to make touches work against code that expect this.

I think our best option is to move over from phantom to use chrome directly with X and via remote debugger.

Reply to this email directly or view it on GitHubhttps://github.com/gardr/validator/issues/3#issuecomment-37505928 .

sveisvei commented 10 years ago

It will be more error-prone indead.

leftieFriele commented 10 years ago

It would be a good thing not having to go down that route of swapping Phantom with Chrome. Would be better to solve the vertical scroll thing some other way, perhaps just inspecting the source is good enough? at least something we can try first and see how it works out.

gregersrygg commented 10 years ago

I'm curious on how you would inspect the source (in an automated way) to see if it uses preventDefault on touch events moving vertically @leftieFriele

I can help you with the touch event emulation @sveisvei . It should be possible :)

sveisvei commented 10 years ago

@leftieFriele Yes, we try to make this work on phantom first. Looks like we are landing this, but need to test some more before closing.