| OLD | NEW |
| 1 <!doctype html> | 1 <!doctype html> |
| 2 <html> | 2 <html> |
| 3 <head> | 3 <head> |
| 4 <title>Pointer Event: releasePointerCapture() - subsequent events follow
normal hitting testing mechanisms</title> | 4 <title>Pointer Event: releasePointerCapture() - subsequent events follow
normal hitting testing mechanisms</title> |
| 5 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/> | 5 <meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/> |
| 6 <link rel="author" title="Microsoft" href="http://www.microsoft.com/"/> | 6 <link rel="author" title="Microsoft" href="http://www.microsoft.com/"/> |
| 7 <meta name="assert" content="After invoking the releasePointerCapture me
thod on an element, subsequent events for the specified pointer must follow norm
al hit testing mechanisms for determining the event target"/> | 7 <meta name="assert" content="After invoking the releasePointerCapture me
thod on an element, subsequent events for the specified pointer must follow norm
al hit testing mechanisms for determining the event target"/> |
| 8 <link rel="stylesheet" type="text/css" href="pointerevent_styles.css"> | 8 <link rel="stylesheet" type="text/css" href="pointerevent_styles.css"> |
| 9 <script src="/resources/testharness.js"></script> | 9 <script src="/resources/testharness.js"></script> |
| 10 <script src="/resources/testharnessreport.js"></script> | 10 <script src="/resources/testharnessreport.js"></script> |
| 11 <!-- Additional helper script for common checks across event types --> | 11 <!-- Additional helper script for common checks across event types --> |
| 12 <script type="text/javascript" src="pointerevent_support.js"></script> | 12 <script type="text/javascript" src="pointerevent_support.js"></script> |
| 13 <script type="text/javascript"> | 13 <script type="text/javascript"> |
| 14 var detected_pointertypes = {}; | 14 var detected_pointertypes = {}; |
| 15 var test_pointerEvent = async_test("lostpointercapture: subsequent e
vents to target."); // set up test harness | 15 var test_pointerEvent = async_test("lostpointercapture: subsequent e
vents to target."); // set up test harness |
| 16 var suppressedEventsFail = false; | |
| 17 // showPointerTypes is defined in pointerevent_support.js | 16 // showPointerTypes is defined in pointerevent_support.js |
| 18 // Requirements: the callback function will reference the test_point
erEvent object and | 17 // Requirements: the callback function will reference the test_point
erEvent object and |
| 19 // will fail unless the async_test is created with the var name "tes
t_pointerEvent". | 18 // will fail unless the async_test is created with the var name "tes
t_pointerEvent". |
| 20 add_completion_callback(showPointerTypes); | 19 add_completion_callback(showPointerTypes); |
| 21 | 20 |
| 22 var captured_event; | 21 var captured_event; |
| 22 var test_done = false; |
| 23 var overEnterEventsFail = false; |
| 24 var outLeaveEventsFail = false; |
| 23 var f_gotPointerCapture = false; | 25 var f_gotPointerCapture = false; |
| 24 var f_lostPointerCapture = false; | 26 var f_lostPointerCapture = false; |
| 25 | 27 |
| 26 function listenerEventHandler(event) { | 28 function listenerEventHandler(event) { |
| 29 if (test_done) |
| 30 return; |
| 27 detected_pointertypes[event.pointerType] = true; | 31 detected_pointertypes[event.pointerType] = true; |
| 28 if (event.type == "gotpointercapture") { | 32 if (event.type == "gotpointercapture") { |
| 29 f_gotPointerCapture = true; | 33 f_gotPointerCapture = true; |
| 30 check_PointerEvent(event); | 34 check_PointerEvent(event); |
| 31 } | 35 } |
| 32 else if (event.type == "lostpointercapture") { | 36 else if (event.type == "lostpointercapture") { |
| 33 f_lostPointerCapture = true; | 37 f_lostPointerCapture = true; |
| 34 f_gotPointerCapture = false; | 38 f_gotPointerCapture = false; |
| 35 check_PointerEvent(event); | 39 check_PointerEvent(event); |
| 36 } | 40 } |
| 37 else if(event.type == "pointerover" || event.type == "pointerent
er" || event.type == "pointerout" || event.type == "pointerleave") { | 41 else if(event.type == "pointerover" || event.type == "pointerent
er") { |
| 38 if(!suppressedEventsFail) { | 42 if(!overEnterEventsFail) { |
| 39 test(function() { | 43 test(function() { |
| 40 assert_true(false, "Suppressed events were received"
); | 44 assert_true(f_gotPointerCapture, "pointerover/enter
should not be received when the target doesn't have capture and pointer is not o
ver it."); |
| 41 }, "Suppressed events were received"); | 45 }, "pointerover/enter should not be received when the ta
rget doesn't have capture and pointer is not over it."); |
| 42 suppressedEventsFail = true; | 46 overEnterEventsFail = true; |
| 47 } |
| 48 } |
| 49 else if(event.type == "pointerout" || event.type == "pointerleav
e") { |
| 50 if(!outLeaveEventsFail) { |
| 51 test(function() { |
| 52 assert_true(f_lostPointerCapture, "pointerout/leave
should not be received unless the target just lost the capture."); |
| 53 }, "pointerout/leave should not be received unless the t
arget just lost the capture."); |
| 54 outLeaveEventsFail = true; |
| 43 } | 55 } |
| 44 } | 56 } |
| 45 else if (event.pointerId == captured_event.pointerId) { | 57 else if (event.pointerId == captured_event.pointerId) { |
| 46 if (f_gotPointerCapture && event.type == "pointermove") { | 58 if (f_gotPointerCapture && event.type == "pointermove") { |
| 47 // on first event received for capture, release capture | 59 // on first event received for capture, release capture |
| 48 listener.releasePointerCapture(event.pointerId); | 60 listener.releasePointerCapture(event.pointerId); |
| 49 } | 61 } |
| 50 else { | 62 else { |
| 51 // if any other events are received after releaseCapture
, then the test fails | 63 // if any other events are received after releaseCapture
, then the test fails |
| 52 test_pointerEvent.step(function () { | 64 test(function () { |
| 53 assert_true(false, event.target.id + "-" + event.typ
e + " should be handled by target element handler"); | 65 assert_unreached(event.target.id + "-" + event.type
+ " should be handled by target element handler"); |
| 54 }); | 66 }, "No other events should be recieved by capturing node
after release"); |
| 55 } | 67 } |
| 56 } | 68 } |
| 57 } | 69 } |
| 58 | 70 |
| 59 function targetEventHandler(event) { | 71 function targetEventHandler(event) { |
| 72 if (test_done) |
| 73 return; |
| 60 if (f_gotPointerCapture) { | 74 if (f_gotPointerCapture) { |
| 61 if(event.type != "pointerout" && event.type != "pointerleave
") { | 75 if(event.type != "pointerout" && event.type != "pointerleave
") { |
| 62 test_pointerEvent.step(function () { | 76 test(function () { |
| 63 assert_true(false, "The Target element should not ha
ve received any events while capture is active. Event recieved:" + event.type +
". "); | 77 assert_unreached("The Target element should not have
received any events while capture is active. Event recieved:" + event.type + ".
"); |
| 64 }); | 78 }, "The target element should not receive any events whi
le capture is active"); |
| 65 } | 79 } |
| 66 } | 80 } |
| 67 | 81 |
| 68 if (event.type == "pointerdown") { | 82 if (event.type == "pointerdown") { |
| 69 // pointerdown event received will be used to capture events
. | 83 // pointerdown event received will be used to capture events
. |
| 70 listener.setPointerCapture(event.pointerId); | 84 listener.setPointerCapture(event.pointerId); |
| 71 captured_event = event; | 85 captured_event = event; |
| 72 } | 86 } |
| 73 | 87 |
| 74 if (f_lostPointerCapture) { | 88 if (f_lostPointerCapture) { |
| 75 test_pointerEvent.step(function () { | 89 test_pointerEvent.step(function () { |
| 76 assert_equals(event.pointerId, captured_event.pointerId,
"pointerID is same for event captured and after release"); | 90 assert_equals(event.pointerId, captured_event.pointerId,
"pointerID is same for event captured and after release"); |
| 77 }); | 91 }); |
| 78 if (event.type == "pointerup") { | 92 if (event.type == "pointerup") { |
| 79 test_pointerEvent.done(); // complete test | 93 test_pointerEvent.done(); // complete test |
| 94 test_done = true; |
| 80 } | 95 } |
| 81 } | 96 } |
| 82 } | 97 } |
| 83 | 98 |
| 84 function run() { | 99 function run() { |
| 85 var listener = document.getElementById("listener"); | 100 var listener = document.getElementById("listener"); |
| 86 var target0 = document.getElementById("target0"); | 101 var target0 = document.getElementById("target0"); |
| 87 target0.style["touchAction"] = "none"; | 102 target0.style["touchAction"] = "none"; |
| 88 | 103 |
| 89 // target0 and listener - handle all events | 104 // target0 and listener - handle all events |
| (...skipping 16 matching lines...) Expand all Loading... |
| 106 <div id="target0"> | 121 <div id="target0"> |
| 107 Use mouse, touch or pen to contact here and move around. | 122 Use mouse, touch or pen to contact here and move around. |
| 108 </div> | 123 </div> |
| 109 <div id="complete-notice"> | 124 <div id="complete-notice"> |
| 110 <p>Test complete: Scroll to Summary to view Pass/Fail Results.</p> | 125 <p>Test complete: Scroll to Summary to view Pass/Fail Results.</p> |
| 111 <p>The following pointer types were detected: <span id="pointertype-
log"></span>.</p> | 126 <p>The following pointer types were detected: <span id="pointertype-
log"></span>.</p> |
| 112 <p>Refresh the page to run the tests again with a different pointer
type.</p> | 127 <p>Refresh the page to run the tests again with a different pointer
type.</p> |
| 113 </div> | 128 </div> |
| 114 <div id="log"></div> | 129 <div id="log"></div> |
| 115 </body> | 130 </body> |
| 116 </html> | 131 </html> |
| OLD | NEW |