michael@0: /* Any copyright is dedicated to the public domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: // Test that sendMouseEvent dispatch events. michael@0: "use strict"; michael@0: michael@0: SimpleTest.waitForExplicitFinish(); michael@0: browserElementTestHelpers.setEnabledPref(true); michael@0: browserElementTestHelpers.addPermission(); michael@0: michael@0: function runTest() { michael@0: var iframe = document.createElement("iframe"); michael@0: SpecialPowers.wrap(iframe).mozbrowser = true; michael@0: document.body.appendChild(iframe); michael@0: michael@0: iframe.addEventListener("mozbrowserloadend", function onloadend(e) { michael@0: iframe.sendMouseEvent("mousedown", 10, 10, 0, 1, 0); michael@0: }); michael@0: michael@0: iframe.addEventListener("mozbrowserlocationchange", function onlocchange(e) { michael@0: var a = document.createElement("a"); michael@0: a.href = e.detail; michael@0: michael@0: switch (a.hash) { michael@0: case "#mousedown": michael@0: ok(true, "Receive a mousedown event."); michael@0: iframe.sendMouseEvent("mousemove", 10, 10, 0, 0, 0); michael@0: break; michael@0: case "#mousemove": michael@0: ok(true, "Receive a mousemove event."); michael@0: iframe.sendMouseEvent("mouseup", 10, 10, 0, 1, 0); michael@0: break; michael@0: case "#mouseup": michael@0: ok(true, "Receive a mouseup event."); michael@0: break; michael@0: case "#click": michael@0: ok(true, "Receive a click event."); michael@0: if (SpecialPowers.getIntPref("dom.w3c_touch_events.enabled") != 0) { michael@0: iframe.sendTouchEvent("touchstart", [1], [10], [10], [2], [2], michael@0: [20], [0.5], 1, 0); michael@0: } else { michael@0: iframe.removeEventListener('mozbrowserlocationchange', onlocchange); michael@0: SimpleTest.finish(); michael@0: } michael@0: break; michael@0: case "#touchstart": michael@0: ok(true, "Receive a touchstart event."); michael@0: iframe.sendTouchEvent("touchmove", [1], [10], [10], [2], [2], michael@0: [20], [0.5], 1, 0); michael@0: case "#touchmove": michael@0: ok(true, "Receive a touchmove event."); michael@0: iframe.sendTouchEvent("touchend", [1], [10], [10], [2], [2], michael@0: [20], [0.5], 1, 0); michael@0: break; michael@0: case "#touchend": michael@0: ok(true, "Receive a touchend event."); michael@0: iframe.sendTouchEvent("touchcancel", [1], [10], [10], [2], [2], michael@0: [20], [0.5], 1, 0); michael@0: iframe.removeEventListener('mozbrowserlocationchange', onlocchange); michael@0: SimpleTest.finish(); michael@0: break; michael@0: } michael@0: }); michael@0: michael@0: iframe.src = "data:text/html," + michael@0: "" + michael@0: ""; michael@0: michael@0: } michael@0: michael@0: addEventListener('testready', runTest);