test_bug1420589_1.html (3705B)
1 <!DOCTYPE HTML> 2 <html> 3 <!-- 4 https://bugzilla.mozilla.org/show_bug.cgi?id=1420589 5 --> 6 <head> 7 <meta charset="utf-8"> 8 <title>Test for Bug 1420589</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=1420589">Mozilla Bug 1420589</a> 15 <p id="display"></p> 16 <iframe id="iframe1" src="./bug_1420589_iframe1.html"> 17 </iframe> 18 <iframe id="iframe2" src="./bug_1420589_iframe2.html"> 19 </iframe> 20 <script type="text/javascript"> 21 /* 22 Test for Bug 1420589. This test synthesizes touch events with two points. The 23 first one hits iframe1 and the other hits iframe2. 24 25 We dispatch all touch events to the same document. We stop dispatching touch 26 events to a target if we can't find any ancestor document that is the same as 27 the document of the existing target. We check the points of the touch event in 28 reverse order. That means we choose the document of iframe2 as our targeted 29 document. We won't dispatch touch events to the document of iframe1 nor the 30 parent document of iframe1 and iframe2. 31 32 We dispatch pointer events to the hit targets even when there aren't in the 33 same document. This test expects that pointer events are dispatched to the div 34 element and the iframe document. 35 */ 36 SimpleTest.waitForExplicitFinish(); 37 38 var rx = 1; 39 var ry = 1; 40 var angle = 0; 41 var force = 1; 42 var modifiers = 0; 43 var test1PointerId = 1; 44 var test2PointerId = 2; 45 46 function withoutImplicitlyPointerCaptureForTouch() { 47 let expectedEvents = [ 48 // messages from the document of iframe1 49 "iframe1 pointerdown", 50 "iframe1 pointermove", 51 "iframe1 pointerup", 52 53 // messages from the document of iframe2 54 "iframe2 pointerdown", 55 "iframe2 pointermove", 56 "iframe2 pointerup", 57 "iframe2 touchstart", 58 "iframe2 touchmove", 59 "iframe2 touchend", 60 ]; 61 62 window.addEventListener('message',function(e) { 63 ok(expectedEvents.includes(e.data), " don't expect " + e.data); 64 expectedEvents = expectedEvents.filter(item => item !== e.data); 65 if (e.data == "iframe2 touchend") { 66 ok(!expectedEvents.length, " expect " + expectedEvents); 67 SimpleTest.finish(); 68 } 69 }) 70 71 let iframe1 = document.getElementById('iframe1'); 72 let iframe2 = document.getElementById('iframe2'); 73 74 let rect1 = iframe1.getBoundingClientRect(); 75 let rect2 = iframe2.getBoundingClientRect(); 76 77 let left1 = rect1.left + 5; 78 let left2 = rect2.left + 5; 79 80 let top1 = rect1.top + 5; 81 let top2 = rect2.top + 5; 82 83 var utils = SpecialPowers.getDOMWindowUtils(window); 84 utils.sendTouchEvent('touchstart', [test1PointerId, test2PointerId], 85 [left1, left2], [top1, top2], [rx, rx], [ry, ry], 86 [angle, angle], [force, force], [0, 0], [0, 0], 87 [0, 0], modifiers); 88 utils.sendTouchEvent('touchmove', [test1PointerId, test2PointerId], 89 [left1 + 1, left2 + 1], [top1, top2], [rx, rx], [ry, ry], 90 [angle, angle], [force, force], [0, 0], [0, 0], 91 [0, 0], modifiers); 92 utils.sendTouchEvent('touchend', [test1PointerId, test2PointerId], 93 [left1 + 1, left2 + 1], [top1, top2], [rx, rx], [ry, ry], 94 [angle, angle], [force, force], [0, 0], [0, 0], 95 [0, 0], modifiers); 96 } 97 98 SimpleTest.waitForFocus(() => { 99 SpecialPowers.pushPrefEnv({"set": [["dom.w3c_pointer_events.implicit_capture", false]]}, 100 withoutImplicitlyPointerCaptureForTouch); 101 }); 102 103 </script> 104 </body> 105 </html>