diff options
author | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
---|---|---|
committer | Matt A. Tobin <mattatobin@localhost.localdomain> | 2018-02-02 04:16:08 -0500 |
commit | 5f8de423f190bbb79a62f804151bc24824fa32d8 (patch) | |
tree | 10027f336435511475e392454359edea8e25895d /dom/browser-element/mochitest/browserElement_SendEvent.js | |
parent | 49ee0794b5d912db1f95dce6eb52d781dc210db5 (diff) | |
download | UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.gz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.lz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.tar.xz UXP-5f8de423f190bbb79a62f804151bc24824fa32d8.zip |
Add m-esr52 at 52.6.0
Diffstat (limited to 'dom/browser-element/mochitest/browserElement_SendEvent.js')
-rw-r--r-- | dom/browser-element/mochitest/browserElement_SendEvent.js | 85 |
1 files changed, 85 insertions, 0 deletions
diff --git a/dom/browser-element/mochitest/browserElement_SendEvent.js b/dom/browser-element/mochitest/browserElement_SendEvent.js new file mode 100644 index 000000000..a65d6f24f --- /dev/null +++ b/dom/browser-element/mochitest/browserElement_SendEvent.js @@ -0,0 +1,85 @@ +/* Any copyright is dedicated to the public domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +// Test that sendMouseEvent dispatch events. +"use strict"; + +SimpleTest.waitForExplicitFinish(); +browserElementTestHelpers.setEnabledPref(true); + +function runTest() { + var iframe = document.createElement("iframe"); + iframe.setAttribute('mozbrowser', 'true'); + document.body.appendChild(iframe); + var x = 10; + var y = 10; + // First we force a reflow so that getChildProcessOffset actually returns + // meaningful data. + iframe.getBoundingClientRect(); + // We need to make sure the event coordinates are actually inside the iframe, + // relative to the chome window. + var tabParent = SpecialPowers.wrap(iframe) + .QueryInterface(SpecialPowers.Ci.nsIFrameLoaderOwner) + .frameLoader.tabParent; + if (tabParent) { + let offsetX = {}; + let offsetY = {}; + tabParent.getChildProcessOffset(offsetX, offsetY); + x -= offsetX.value; + y -= offsetY.value; + } + + iframe.addEventListener("mozbrowserloadend", function onloadend(e) { + iframe.sendMouseEvent("mousedown", x, y, 0, 1, 0); + }); + + iframe.addEventListener("mozbrowserlocationchange", function onlocchange(e) { + var a = document.createElement("a"); + a.href = e.detail.url; + + switch (a.hash) { + case "#mousedown": + ok(true, "Receive a mousedown event."); + iframe.sendMouseEvent("mousemove", x, y, 0, 0, 0); + break; + case "#mousemove": + ok(true, "Receive a mousemove event."); + iframe.sendMouseEvent("mouseup", x, y, 0, 1, 0); + break; + case "#mouseup": + ok(true, "Receive a mouseup event."); + break; + case "#click": + ok(true, "Receive a click event."); + if (SpecialPowers.getIntPref("dom.w3c_touch_events.enabled") != 0) { + iframe.sendTouchEvent("touchstart", [1], [x], [y], [2], [2], + [20], [0.5], 1, 0); + } else { + iframe.removeEventListener('mozbrowserlocationchange', onlocchange); + SimpleTest.finish(); + } + break; + case "#touchstart": + ok(true, "Receive a touchstart event."); + iframe.sendTouchEvent("touchmove", [1], [x], [y], [2], [2], + [20], [0.5], 1, 0); + case "#touchmove": + ok(true, "Receive a touchmove event."); + iframe.sendTouchEvent("touchend", [1], [x], [y], [2], [2], + [20], [0.5], 1, 0); + break; + case "#touchend": + ok(true, "Receive a touchend event."); + iframe.sendTouchEvent("touchcancel", [1], [x], [y], [2], [2], + [20], [0.5], 1, 0); + iframe.removeEventListener('mozbrowserlocationchange', onlocchange); + SimpleTest.finish(); + break; + } + }); + + iframe.src = "file_browserElement_SendEvent.html"; + +} + +addEventListener('testready', runTest); |