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

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

Issue 1704723002: DevTools: add input event instrumentation test (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: speculative attempt to fix MacOS 10.6 flakiness Created 4 years, 10 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/latency_info.html
diff --git a/chrome/test/data/devtools/latency_info.html b/chrome/test/data/devtools/latency_info.html
new file mode 100644
index 0000000000000000000000000000000000000000..e3290d82cf01eaf3a5af95e5ebc3e902a97eb192
--- /dev/null
+++ b/chrome/test/data/devtools/latency_info.html
@@ -0,0 +1,105 @@
+<html>
+<head>
+<style>
+#test-hover {
+ position: absolute;
+ left: 20px;
+ top: 40px;
+ width: 100px;
+ height: 30px;
+ background-color: red;
+}
+
+#test-hover:hover {
+ background-color: blue;
+}
+
+#test-button {
+ position: absolute;
+ left: 20px;
+ top: 100px;
+ width: 100px;
+ height: 30px;
+}
+
+#scrollable {
+ position: absolute;
+ left: 200px;
+ top: 30px;
+ width: 200px;
+ height: 200px;
+ overflow: scroll;
+}
+
+#scrolled {
+ width: 800px;
+ height: 800px;
+}
+</style>
+</head>
+<body>
+<div id="test-hover">Hover me</div>
+<button id="test-button">Click me</button>
+<div id="scrollable"><div id="scrolled"></div></div>
+<script>
+var pendingListeners = {};
+var pendingEvents = {};
+var inflightEvents = null;
+function onEvent(event)
+{
+ if (inflightEvents) {
+ inflightEvents.push(event);
+ return;
+ }
+ inflightEvents = [event];
+ if (event.type === "mousemove")
+ document.body.style.backgroundColor = "#" + Math.floor(Math.random() * (1 << 24)).toString(16);
+ requestAnimationFrame(onEventAfterFrame);
+}
+
+function onEventAfterFrame()
+{
+ for (event of inflightEvents) {
+ var type = event.type;
+ var listener = pendingListeners[type];
+ if (!listener) {
+ pendingEvents[type] = (pendingEvents[type] || 0) + 1;
+ continue;
+ }
+ delete pendingListeners[type];
+ listener();
+ }
+ inflightEvents = null;
+}
+
+function waitForEvent(eventType, callback)
+{
+ if (pendingEvents[eventType]) {
+ pendingEvents[eventType]--;
+ callback();
+ return;
+ }
+ pendingListeners[eventType] = callback;
+}
+
+var eventTypes = [
+ "mousemove",
+ "mousedown",
+ "mouseup",
+ "wheel",
+ "gesturetap",
+ "click",
+ "keydown",
+ "keyup",
+ "touchstart",
+ "touchend",
+ "touchcancel",
+ "touchmove"
+];
+
+for (var e of eventTypes) {
+ window.addEventListener(e, onEvent, true);
+}
+</script>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698