Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(440)

Unified Diff: chrome/test/data/devtools/touch_emulation.html

Issue 249613002: [DevTools] Interactive test for DevTools touch emulation. (Closed) Base URL: svn://svn.chromium.org/chrome/trunk/src
Patch Set: DCHECK Created 6 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: chrome/test/data/devtools/touch_emulation.html
diff --git a/chrome/test/data/devtools/touch_emulation.html b/chrome/test/data/devtools/touch_emulation.html
new file mode 100644
index 0000000000000000000000000000000000000000..8789b368fcd59b5170dfab81b6ce179684ca84c3
--- /dev/null
+++ b/chrome/test/data/devtools/touch_emulation.html
@@ -0,0 +1,64 @@
+<head>
+<style>
+div {
+ width: 400px;
+ height: 400px;
+}
+</style>
+</head>
+
+<body>
+<div></div>
+<script>
+var events = [];
+var expectedEventsCount = null;
+// Prevent default to disable gestures.
+var preventDefault = true;
+
+function maybeSendEvents() {
+ if (expectedEventsCount === null)
+ return;
+ if (events.length < expectedEventsCount)
+ return;
+
+ var result = events.join(" ");
+ events = [];
+ expectedEventsCount = null;
+ window.domAutomationController.send(result);
+}
+
+function getEventNames(count) {
+ expectedEventsCount = count;
+ maybeSendEvents();
+}
+
+function onEvent(name, event) {
+ events.push(name);
+ if (preventDefault)
+ event.preventDefault();
+ setTimeout(maybeSendEvents, 0);
+}
+
+var names = [
+ "touchstart",
+ "touchmove",
+ "touchend",
+ "touchcancel",
+ "mouseover",
+ "mouseout",
+ "mouseleave",
+ "mouseenter",
+ "mousedown",
+ "mouseup",
+ "mousemove",
+ "click"
+];
+
+for (var i = 0; i < names.length; ++i) {
+ document.querySelector("div").addEventListener(
+ names[i],
+ onEvent.bind(null, names[i]),
+ false);
+}
+</script>
+</body>

Powered by Google App Engine
This is Rietveld 408576698