OLD | NEW |
(Empty) | |
| 1 <!doctype html> |
| 2 <html> |
| 3 <head> |
| 4 <title>Set/Release capture + relatedTarget</title> |
| 5 <meta name="viewport" content="width=device-width"> |
| 6 <link rel="stylesheet" type="text/css" href="pointerevent_styles.css"> |
| 7 <script src="/resources/testharness.js"></script> |
| 8 <script src="/resources/testharnessreport.js"></script> |
| 9 <script src="pointerevent_support.js"></script> |
| 10 </head> |
| 11 <body> |
| 12 <h1>Pointer Events Capture Test - capture and relatedTarget</h1> |
| 13 <h4> |
| 14 Test Description: This test checks if setCapture/releaseCapture func
tions works properly. Complete the following actions: |
| 15 <ol> |
| 16 <li> Put your mouse over the lower rectangle. pointerover should
be received for the purple rectangle |
| 17 <li> Press and hold left mouse button over "Set Capture" button |
| 18 <li> Put your mouse over the upper rectangle. pointerover should
be received for the black rectangle |
| 19 <li> Release left mouse button to complete the test. |
| 20 </ol> |
| 21 </h4> |
| 22 Test passes if the proper behavior of the events is observed. |
| 23 |
| 24 <div id="target0" style="background:black; color:white"></div> |
| 25 <br> |
| 26 <div id="target1" style="background:purple; color:white"></div> |
| 27 <br> |
| 28 <input type="button" id="btnCapture" value="Set Capture"> |
| 29 <script type='text/javascript'> |
| 30 var isPointerCapture = false; |
| 31 var isPointeroverGot = false; |
| 32 var count=0; |
| 33 |
| 34 var detected_pointertypes = {}; |
| 35 add_completion_callback(showPointerTypes); |
| 36 |
| 37 var target0 = document.getElementById('target0'); |
| 38 var target1 = document.getElementById('target1'); |
| 39 var captureButton = document.getElementById('btnCapture'); |
| 40 |
| 41 setup({ explicit_done: true }); |
| 42 |
| 43 window.onload = function() { |
| 44 on_event(captureButton, 'pointerdown', function(e) { |
| 45 if(isPointerCapture == false) { |
| 46 isPointerCapture = true; |
| 47 sPointerCapture(e); |
| 48 } |
| 49 else { |
| 50 isPointerCapture = false; |
| 51 rPointerCapture(e); |
| 52 } |
| 53 }); |
| 54 |
| 55 on_event(target0, 'gotpointercapture', function(e) { |
| 56 log("gotpointercapture", document.getElementById('target0'))
; |
| 57 }); |
| 58 |
| 59 on_event(target0, 'lostpointercapture', function(e) { |
| 60 log("lostpointercapture", document.getElementById('target0')
); |
| 61 isPointerCapture = false; |
| 62 }); |
| 63 |
| 64 run(); |
| 65 } |
| 66 |
| 67 function run() { |
| 68 // After invoking the setPointerCapture method on an element, su
bsequent pointer events for the specified pointer must be targeted at that eleme
nt. |
| 69 // Additionally, the relatedTarget property of all such pointer
events must be set to null. |
| 70 // TA: 13.3 |
| 71 on_event(target0, "pointerover", function (event) { |
| 72 log("pointerover", document.getElementById('target0')); |
| 73 if(isPointerCapture && isPointeroverGot) { |
| 74 test(function() { |
| 75 assert_true(event.relatedTarget==null, "relatedTarge
t is null when the capture is set") |
| 76 }, "relatedTarget is null when the capture is set. relat
edTarget is " + event.relatedTarget); |
| 77 done(); |
| 78 } |
| 79 }); |
| 80 |
| 81 on_event(target1, "pointerover", function (event) { |
| 82 detected_pointertypes[ event.pointerType ] = true; |
| 83 if(!isPointeroverGot) { |
| 84 test(function() { |
| 85 assert_true(isPointerCapture==false, "pointerover sh
ouldn't trigger for this target when capture is enabled"); |
| 86 }, "pointerover shouldn't trigger for the purple rectang
le while the black rectangle has capture"); |
| 87 isPointeroverGot = true; |
| 88 log("pointerover", document.getElementById('target1')); |
| 89 } |
| 90 }); |
| 91 } |
| 92 </script> |
| 93 <h1>Pointer Events Capture Test</h1> |
| 94 <div id="complete-notice"> |
| 95 <p>Test complete: Scroll to Summary to view Pass/Fail Results.</p> |
| 96 <p>The following pointer types were detected: <span id="pointertype-
log"></span>.</p> |
| 97 <p>Refresh the page to run the tests again with a different pointer
type.</p> |
| 98 </div> |
| 99 <div id="log"></div> |
| 100 </body> |
| 101 </html> |
OLD | NEW |