test_bug1403055.html (3759B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1403055 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1403055</title> 9 <script src="/tests/SimpleTest/SimpleTest.js"></script> 10 <script src="/tests/SimpleTest/EventUtils.js"></script> 11 <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 12 </head> 13 <body> 14 <a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=1403055">Mozilla Bug 1403055</a> 15 <p id="display"></p> 16 <div id="target0" style="width: 50px; height: 50px; background: green"></div> 17 <div id="target1" style="width: 50px; height: 50px; background: red"></div> 18 <div id="done" style="width: 50px; height: 50px; background: black"></div> 19 <script type="text/javascript"> 20 /** Test for Bug 1403055 */ 21 SimpleTest.waitForExplicitFinish(); 22 23 var target0 = window.document.getElementById("target0"); 24 var target1 = window.document.getElementById("target1"); 25 var done = window.document.getElementById("done"); 26 27 function withoutImplicitlyPointerCaptureForTouch() { 28 let target0_events = ["pointerover", "pointerenter", "pointerdown", "pointermove"]; 29 let target1_events = ["pointerover", "pointerenter", "pointermove", "pointercancel", "pointerout", "pointerleave"]; 30 31 target0_events.forEach((elem, index, arr) => { 32 target0.addEventListener(elem, (event) => { 33 is(event.type, target0_events[0], "receive " + event.type + " on target0"); 34 target0_events = target0_events.filter(item => item !== event.type); 35 }, { once: true }); 36 }); 37 38 target1_events.forEach((elem, index, arr) => { 39 target1.addEventListener(elem, (event) => { 40 is(event.type, target1_events[0], "receive " + event.type + " on target1"); 41 target1_events = target1_events.filter(item => item !== event.type); 42 }, { once: true }); 43 }); 44 45 done.addEventListener("mouseup", () => { 46 ok(!target0_events.length, " should receive " + target0_events + " on target0"); 47 ok(!target1_events.length, " should receive " + target1_events + " on target1"); 48 SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.implicit_capture", true]]}, 49 withImplicitlyPointerCaptureForTouch); 50 }, {once : true}); 51 52 synthesizeTouch(target0, 5, 5, { type: "touchstart" }); 53 synthesizeTouch(target0, 6, 6, { type: "touchmove" }); 54 synthesizeTouch(target1, 5, 5, { type: "touchmove" }); 55 synthesizeTouch(target1, 5, 5, { type: "touchcancel" }); 56 synthesizeMouseAtCenter(done, { type: "mousedown" }); 57 synthesizeMouseAtCenter(done, { type: "mouseup" }); 58 } 59 60 function withImplicitlyPointerCaptureForTouch() { 61 let target0_events = ["pointerover", "pointerenter", "pointerdown", "pointermove", "pointercancel", "pointerout", "pointerleave"]; 62 63 target0_events.forEach((elem, index, arr) => { 64 target0.addEventListener(elem, (event) => { 65 is(event.type, target0_events[0], "receive " + event.type + " on target0"); 66 target0_events = target0_events.filter(item => item !== event.type); 67 }, { once: true }); 68 }); 69 70 done.addEventListener("mouseup", () => { 71 ok(!target0_events.length, " should receive " + target0_events + " on target0"); 72 SimpleTest.finish(); 73 }, {once : true}); 74 75 synthesizeTouch(target0, 5, 5, { type: "touchstart" }); 76 synthesizeTouch(target0, 5, 5, { type: "touchmove" }); 77 synthesizeTouch(target1, 5, 5, { type: "touchmove" }); 78 synthesizeTouch(target1, 5, 5, { type: "touchcancel" }); 79 synthesizeMouseAtCenter(done, { type: "mousedown" }); 80 synthesizeMouseAtCenter(done, { type: "mouseup" }); 81 } 82 83 SimpleTest.waitForFocus(() => { 84 SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.implicit_capture", false]]}, 85 withoutImplicitlyPointerCaptureForTouch); 86 }); 87 88 </script> 89 </body> 90 </html>