1 var hitRegionEventList = {
3 send : function(x, y) {
4 eventSender.mouseMoveTo(x, y);
5 eventSender.mouseDown();
8 getId : function(event) { return event.region; }
11 send : function(x, y) {
12 eventSender.clearTouchPoints();
13 eventSender.addTouchPoint(x, y);
14 eventSender.touchStart();
15 eventSender.touchEnd();
17 getId : function(event) { return event.targetTouches[0].region; }
21 function clickCanvas(x, y, scaleFactor)
23 if (!window.eventSender)
24 return "This test requires eventSender";
29 function listener(event) {
30 result[event.type] = hitRegionEventList[event.type].getId(event);
31 canvas.removeEventListener(type, listener, false);
34 if (scaleFactor === undefined)
36 var rect = canvas.getBoundingClientRect();
37 var translatedCanvasLeft = rect.left * scaleFactor * window.devicePixelRatio;
38 var translatedCanvasTop = rect.top * scaleFactor * window.devicePixelRatio;
39 for (var type in hitRegionEventList) {
40 canvas.addEventListener(type, listener, false);
41 hitRegionEventList[type].send(translatedCanvasLeft + x, translatedCanvasTop + y);
44 // single actualId guarantees that results of eventlist are same
45 for (var type in hitRegionEventList) {
46 if (result[type] === undefined)
47 result[type] = "no event sent to canvas";
48 if (actualId === null) {
49 actualId = result[type];
51 if (actualId != result[type]) {
52 // some results of eventlist are different, makes log
55 for (var type in hitRegionEventList) {
56 actualId += type + ": '" + result[type] + "'; ";
65 for (var type in hitRegionEventList) {
66 canvas.removeEventListener(type, listener, false);