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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/events/hr-timestamp/input-events.html

Issue 2784913002: Fix flaky hi-resolution event timestamp test. (Closed)
Patch Set: Created 3 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 unified diff | Download patch
« no previous file with comments | « no previous file | no next file » | no next file with comments »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
OLDNEW
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 2
3 <script src="../../../resources/testharness.js"></script> 3 <script src="../../../resources/testharness.js"></script>
4 <script src="../../../resources/testharnessreport.js"></script> 4 <script src="../../../resources/testharnessreport.js"></script>
5 <script type="text/javascript"> 5 <script type="text/javascript">
6 'use strict'; 6 'use strict';
7 7
8 const testCases = { 8 const testCases = {
9 'mousedown': () => eventSender.mouseDown(), 9 'mousedown': () => eventSender.mouseDown(),
10 'keydown': () => eventSender.keyDown('x'), 10 'keydown': () => eventSender.keyDown('x'),
11 'touchstart': () => { 11 'touchstart': () => {
12 eventSender.addTouchPoint(1, 1); 12 eventSender.addTouchPoint(1, 1);
13 eventSender.touchStart(); 13 eventSender.touchStart();
14 }, 14 },
15 'click': () => eventSender.gestureTap(1, 1), 15 'click': () => eventSender.gestureTap(1, 1),
16 'contextmenu': () => eventSender.contextClick(), 16 'contextmenu': () => eventSender.contextClick(),
17 'wheel': () => eventSender.mouseScrollBy(0, -50), 17 'wheel': () => eventSender.mouseScrollBy(0, -50),
18 }; 18 };
19 19
20 for (let eventName in testCases) 20 for (let eventName in testCases)
21 createTest(eventName, testCases[eventName]); 21 createTest(eventName, testCases[eventName]);
22 22
23 function createTest(eventName, dispatchEventFn) { 23 function createTest(eventName, dispatchEventFn) {
24 async_test(function(t) { 24 async_test(function(t) {
25 document.addEventListener(eventName, t.step_func(function(e) { 25 document.addEventListener(eventName, t.step_func(function(e) {
26 const platformTimestamp = eventSender.lastEventTimestamp(); // in se conds 26 const platformTimestamp = eventSender.lastEventTimestamp(); // in se conds
27 const expectedTimestamp = internals.monotonicTimeToZeroBasedDocument Time(platformTimestamp) * 1000; // in milliseconds 27 const expectedTimestamp = Math.floor((internals.monotonicTimeToZeroB asedDocumentTime(platformTimestamp) * 1000) / 0.005) * 0.005;
28 assert_approx_equals(e.timeStamp, expectedTimestamp, 0.005); 28 assert_approx_equals(e.timeStamp, expectedTimestamp, 0.005);
29 t.done(); 29 t.done();
30 })); 30 }));
31 dispatchEventFn(); 31 dispatchEventFn();
32 }, "Event timestamp should be equal to the timestamp provided by the platfor m for " + eventName); 32 }, "Event timestamp should be equal to the timestamp provided by the platfor m for " + eventName);
33 } 33 }
34 </script> 34 </script>
OLDNEW
« no previous file with comments | « no previous file | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698