1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/dom/events/test/test_bug648573.html Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,112 @@ 1.4 +<!DOCTYPE HTML> 1.5 +<html> 1.6 +<!-- 1.7 +https://bugzilla.mozilla.org/show_bug.cgi?id=648573 1.8 +--> 1.9 +<head> 1.10 + <title>Test for Bug 648573</title> 1.11 + <script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script> 1.12 + <link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/> 1.13 +</head> 1.14 +<body> 1.15 +<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=648573">Mozilla Bug 648573</a> 1.16 +<p id="display"></p> 1.17 +<div id="content" style="display: none"> 1.18 + 1.19 +</div> 1.20 +<pre id="test"> 1.21 +<script type="application/javascript"> 1.22 + 1.23 +/** Test for Bug 648573 **/ 1.24 + 1.25 +var utils = SpecialPowers.getDOMWindowUtils(window); 1.26 + 1.27 +ok(!utils.mayHaveTouchEventListeners, 1.28 + "There shouldn't be any touch event listeners yet."); 1.29 + 1.30 +ok("createTouch" in document, "Should have createTouch function"); 1.31 +ok("createTouchList" in document, "Should have createTouchList function"); 1.32 +ok(document.createEvent("touchevent"), "Should be able to create TouchEvent objects"); 1.33 + 1.34 +var t1 = document.createTouch(window, document, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11); 1.35 +is(t1.target, document, "Wrong target"); 1.36 +is(t1.identifier, 1, "Wrong identifier"); 1.37 +is(t1.pageX, 2, "Wrong pageX"); 1.38 +is(t1.pageY, 3, "Wrong pageY"); 1.39 +is(t1.screenX, 4, "Wrong screenX"); 1.40 +is(t1.screenY, 5, "Wrong screenY"); 1.41 +is(t1.clientX, 6, "Wrong clientX"); 1.42 +is(t1.clientY, 7, "Wrong clientY"); 1.43 +is(t1.radiusX, 8, "Wrong radiusX"); 1.44 +is(t1.radiusY, 9, "Wrong radiusY"); 1.45 +is(t1.rotationAngle, 10, "Wrong rotationAngle"); 1.46 +is(t1.force, 11, "Wrong force"); 1.47 + 1.48 +var t2 = document.createTouch(); 1.49 + 1.50 +var l1 = document.createTouchList(t1); 1.51 +is(l1.length, 1, "Wrong length"); 1.52 +is(l1.item(0), t1, "Wront item (1)"); 1.53 +is(l1[0], t1, "Wront item (2)"); 1.54 + 1.55 +var l2 = document.createTouchList([t1, t2]); 1.56 +is(l2.length, 2, "Wrong length"); 1.57 +is(l2.item(0), t1, "Wront item (3)"); 1.58 +is(l2.item(1), t2, "Wront item (4)"); 1.59 +is(l2[0], t1, "Wront item (5)"); 1.60 +is(l2[1], t2, "Wront item (6)"); 1.61 + 1.62 +var l3 = document.createTouchList(); 1.63 + 1.64 +var e = document.createEvent("touchevent"); 1.65 +e.initTouchEvent("touchmove", true, true, window, 0, true, true, true, true, 1.66 + l1, l2, l3); 1.67 +is(e.touches, l1, "Wrong list (1)"); 1.68 +is(e.targetTouches, l2, "Wrong list (2)"); 1.69 +is(e.changedTouches, l3, "Wrong list (3)"); 1.70 +ok(e.altKey, "Alt should be true"); 1.71 +ok(e.metaKey, "Meta should be true"); 1.72 +ok(e.ctrlKey, "Ctrl should be true"); 1.73 +ok(e.shiftKey, "Shift should be true"); 1.74 + 1.75 + 1.76 +var events = 1.77 + ["touchstart", 1.78 + "touchend", 1.79 + "touchmove", 1.80 + "touchenter", 1.81 + "touchleave", 1.82 + "touchcancel"]; 1.83 + 1.84 +function runEventTest(type) { 1.85 + var e = document.createEvent("touchevent"); 1.86 + e.initTouchEvent(type, true, true, window, 0, true, true, true, true, 1.87 + l1, l2, l3); 1.88 + var t = document.createElement("div"); 1.89 + // Testing target.onFoo; 1.90 + var didCall = false; 1.91 + t["on" + type] = function (evt) { 1.92 + is(evt, e, "Wrong event"); 1.93 + evt.target.didCall = true; 1.94 + } 1.95 + t.dispatchEvent(e); 1.96 + ok(t.didCall, "Should have called the listener(1)"); 1.97 + 1.98 + // Testing <element onFoo=""> 1.99 + t = document.createElement("div"); 1.100 + t.setAttribute("on" + type, "this.didCall = true;"); 1.101 + t.dispatchEvent(e); 1.102 + ok(t.didCall, "Should have called the listener(2)"); 1.103 +} 1.104 + 1.105 +for (var i = 0; i < events.length; ++i) { 1.106 + runEventTest(events[i]); 1.107 +} 1.108 + 1.109 +ok(utils.mayHaveTouchEventListeners, 1.110 + "There should be touch event listeners."); 1.111 +</script> 1.112 +</pre> 1.113 +</body> 1.114 +</html> 1.115 +