Skip to content

Instantly share code, notes, and snippets.

@sdesai
Created August 10, 2012 02:23
Show Gist options
  • Save sdesai/3310429 to your computer and use it in GitHub Desktop.
Save sdesai/3310429 to your computer and use it in GitHub Desktop.
var page = require('webpage').create(),
url = 'http://localhost/YuiWip/sb/phantomtest.html';
page.open(url, function(status) {
var results = page.evaluate(function() {
return ("ontouchstart" in window);
});
console.log(results);
results = page.evaluate(function() {
var foo = "not invoked";
document.addEventListener("touchstart", function() {
foo = "invoked";
}, false);
var customEvent = document.createEvent("TouchEvent");
customEvent.initTouchEvent("touchstart", true, true, window, 1,
10, 10, 10, 10,
false, false, false, false,
document.createTouchList(document.createTouch(window, document, 1, 10, 10, 10, 10)), // touches[0]
document.createTouchList(document.createTouch(window, document, 1, 10, 10, 10, 10)),
document.createTouchList(),
1.0, 1.0);
document.dispatchEvent(customEvent);
return foo;
});
console.log(results);
phantom.exit();
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment