|
38 | 38 | </style>
|
39 | 39 | <script>
|
40 | 40 | var expectedPointerId = NaN;
|
41 |
| - var startSummation = false; |
42 |
| - var lastScreenX = 0; |
43 |
| - var lastScreenY = 0; |
| 41 | + var lastScreenX = null; |
| 42 | + var lastScreenY = null; |
44 | 43 |
|
45 | 44 | function resetTestState() {
|
46 |
| - startSummation = false; |
47 |
| - lastScreenX = 0; |
48 |
| - lastScreenY = 0; |
| 45 | + lastScreenX = null; |
| 46 | + lastScreenY = null; |
49 | 47 | }
|
50 | 48 |
|
| 49 | + var nonPointermoveEventList = [ |
| 50 | + "pointerover", |
| 51 | + "pointerenter", |
| 52 | + "pointerdown", |
| 53 | + "pointerup", |
| 54 | + "pointerout", |
| 55 | + "pointerleave", |
| 56 | + "gotpointercapture", |
| 57 | + "lostpointercapture"]; |
| 58 | + |
51 | 59 | function injectInput(pointerType) {
|
52 | 60 | var pointerId = pointerType + "Pointer1";
|
53 | 61 | return new test_driver.Actions()
|
54 | 62 | .addPointer(pointerId, pointerType)
|
55 | 63 | .pointerMove(0, 0, {origin: box1})
|
56 | 64 | .pointerDown()
|
57 | 65 | .pointerMove(20, 30, {origin: box1})
|
58 |
| - .pointerMove(60, 40, {origin: box1}) |
| 66 | + .pointerMove(50, 40, {origin: box1}) |
| 67 | + .pointerMove(80, 30, {origin: box1}) |
| 68 | + .pointerMove(110, 20, {origin: box1}) |
59 | 69 | .pointerMove(0, 0, {origin: box2})
|
60 | 70 | .pointerUp()
|
61 | 71 | .send();
|
|
65 | 75 | var test_pointerEvent = setup_pointerevent_test("pointerevent attributes", ALL_POINTERS);
|
66 | 76 |
|
67 | 77 | [document, document.getElementById('innerFrame').contentDocument].forEach(function(element) {
|
| 78 | + nonPointermoveEventList.forEach(function(eventName) { |
| 79 | + on_event(element, eventName, function (event) { |
| 80 | + if (lastScreenX && lastScreenY) { |
| 81 | + test_pointerEvent.step(function() { |
| 82 | + assert_equals(event.movementX, 0, "movementX should be 0 for event other than pointermove."); |
| 83 | + assert_equals(event.movementY, 0, "movementY should be 0 for event other than pointermove."); |
| 84 | + }); |
| 85 | + // Reset when entering the new frame. |
| 86 | + if (event.type == "pointerenter") { |
| 87 | + lastScreenX = null; |
| 88 | + lastScreenY = null; |
| 89 | + } |
| 90 | + } |
| 91 | + }); |
| 92 | + }); |
| 93 | + |
68 | 94 | on_event(element, 'pointermove', function (event) {
|
69 |
| - if (startSummation) { |
70 |
| - test_pointerEvent.step(function() { |
| 95 | + test_pointerEvent.step(function() { |
| 96 | + if (lastScreenX && lastScreenY) { |
71 | 97 | assert_equals(event.movementX, event.screenX - lastScreenX, "movementX should be the delta between current event's and last event's screenX");
|
72 | 98 | assert_equals(event.movementY, event.screenY - lastScreenY, "movementY should be the delta between current event's and last event's screenY");
|
73 |
| - }); |
74 |
| - lastScreenX = event.screenX; |
75 |
| - lastScreenY = event.screenY; |
76 |
| - } |
| 99 | + } |
| 100 | + }); |
| 101 | + lastScreenX = event.screenX; |
| 102 | + lastScreenY = event.screenY; |
77 | 103 | });
|
78 | 104 | });
|
79 | 105 | on_event(document.querySelector('#box1'), 'pointerdown', function(event) {
|
80 | 106 | event.target.releasePointerCapture(event.pointerId);
|
81 | 107 | test_pointerEvent.step(function() {
|
82 | 108 | assert_equals(event.pointerType, expectedPointerType, "Use the instructed pointer type.");
|
83 | 109 | });
|
84 |
| - startSummation = true; |
85 | 110 | lastScreenX = event.screenX;
|
86 | 111 | lastScreenY = event.screenY;
|
87 | 112 | });
|
88 | 113 | on_event(document.querySelector('#box2'), 'pointerup', function(event) {
|
89 |
| - startSummation = false; |
90 | 114 | test_pointerEvent.done();
|
91 | 115 | });
|
92 | 116 |
|
|
0 commit comments