var touchmoveEvents = [];
function touchmove(e) {
// Make touchmove handling slow var start = performance.now();
while (performance.now() < (start + 10));
touchmoveEvents.push(e);
}
async function fireLotsOfSingleTouchMoves() { var ret = new Promise(function(resolve) {
SpecialPowers.loadChromeScript(function() {
/* eslint-env mozilla/chrome-script */ var element = this.actorParent.rootFrameLoader.ownerElement; var rect = element.getBoundingClientRect(); var win = element.ownerDocument.defaultView; var utils = win.windowUtils; var x = rect.x + (rect.width / 2); var y = Math.floor(rect.y + (rect.height / 4)); var endY = Math.floor(rect.y + ((rect.height / 4) * 2));
utils.sendTouchEvent("touchstart", [0], [x], [y], [1], [1], [0], [1],
[0], [0], [0], 0, false);
while (y != endY) {
utils.sendTouchEvent("touchmove", [0], [x], [y], [1], [1], [0], [1],
[0], [0], [0], 0, false);
++y;
}
utils.sendTouchEvent("touchend", [0], [x], [y], [1], [1], [0], [1],
[0], [0], [0], 0, false);
function disableIPCCompression() {
return SpecialPowers.pushPrefEnv({"set": [["dom.events.compress.touchmove",
false],
["dom.events.coalesce.touchmove",
false]]});
}
function enableIPCCompression() {
return SpecialPowers.pushPrefEnv({"set": [["dom.events.compress.touchmove",
true],
["dom.events.coalesce.touchmove",
false]]});
}
async function runTests() {
document.body.clientTop; // Flush layout
await disableIPCCompression(); var touchMovesWithoutCoalescing = await fireLotsOfSingleTouchMoves();
await enableIPCCompression(); var touchMovesWithCoalescing = await fireLotsOfSingleTouchMoves();
opener.ok(touchMovesWithoutCoalescing.length > touchMovesWithCoalescing.length, "Coalescing should reduce the number of touchmove events");
opener.isDeeply(touchMovesWithoutCoalescing.shift().touches,
touchMovesWithCoalescing.shift().touches, "Shouldn't have coalesced the initial touchmove");
opener.isDeeply(touchMovesWithoutCoalescing.pop().touches,
touchMovesWithCoalescing.pop().touches, "The last touchmove event should be up-to-date");
await disableIPCCompression(); var twoTouchMovesWithoutCoalescing = await fireTwoSingleTouches();
await enableIPCCompression(); var twoTouchMovesWithCoalescing = await fireTwoSingleTouches();
opener.is(twoTouchMovesWithoutCoalescing.length, 2, "Should have got two touchmoves");
opener.is(twoTouchMovesWithoutCoalescing.length,
twoTouchMovesWithCoalescing.length, "Shouldn't have coalesced the touchmove.");
await disableIPCCompression(); var multiTouchMovesWithoutCoalescing = await fireLotsOfMultiTouchMoves();
await enableIPCCompression(); var multiTouchMovesWithCoalescing = await fireLotsOfMultiTouchMoves();
opener.ok(multiTouchMovesWithoutCoalescing.length > multiTouchMovesWithCoalescing.length, "Coalescing should reduce the number of multitouch touchmove events");
opener.isDeeply(multiTouchMovesWithoutCoalescing.shift().touches,
multiTouchMovesWithCoalescing.shift().touches, "Shouldn't have coalesced the initial multitouch touchmove event");
opener.isDeeply(multiTouchMovesWithoutCoalescing.pop().touches,
multiTouchMovesWithCoalescing.pop().touches, "The last multitouch touchmove event should be up-to-date");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.