michael@0: /* Any copyright is dedicated to the Public Domain. michael@0: http://creativecommons.org/publicdomain/zero/1.0/ */ michael@0: michael@0: function test() { michael@0: let url = "http://mochi.test:8888/browser/browser/devtools/responsivedesign/test/touch.html"; michael@0: michael@0: let mgr = ResponsiveUI.ResponsiveUIManager; michael@0: michael@0: waitForExplicitFinish(); michael@0: michael@0: gBrowser.selectedTab = gBrowser.addTab(); michael@0: gBrowser.selectedBrowser.addEventListener("load", function onload() { michael@0: gBrowser.selectedBrowser.removeEventListener("load", onload, true); michael@0: waitForFocus(startTest, content); michael@0: }, true); michael@0: michael@0: content.location = url; michael@0: michael@0: function startTest() { michael@0: mgr.once("on", function() {executeSoon(testWithNoTouch)}); michael@0: mgr.once("off", function() {executeSoon(finishUp)}); michael@0: mgr.toggle(window, gBrowser.selectedTab); michael@0: } michael@0: michael@0: function testWithNoTouch() { michael@0: let div = content.document.querySelector("div"); michael@0: let x = 2, y = 2; michael@0: EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); michael@0: x += 20; y += 10; michael@0: EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); michael@0: is(div.style.transform, "", "touch didn't work"); michael@0: EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); michael@0: testWithTouch(); michael@0: } michael@0: michael@0: function testWithTouch() { michael@0: gBrowser.selectedTab.__responsiveUI.enableTouch(); michael@0: let div = content.document.querySelector("div"); michael@0: let x = 2, y = 2; michael@0: EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); michael@0: x += 20; y += 10; michael@0: EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); michael@0: is(div.style.transform, "translate(20px, 10px)", "touch worked"); michael@0: EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); michael@0: is(div.style.transform, "none", "end event worked"); michael@0: mgr.toggle(window, gBrowser.selectedTab); michael@0: } michael@0: michael@0: function testWithTouchAgain() { michael@0: gBrowser.selectedTab.__responsiveUI.disableTouch(); michael@0: let div = content.document.querySelector("div"); michael@0: let x = 2, y = 2; michael@0: EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); michael@0: x += 20; y += 10; michael@0: EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); michael@0: is(div.style.transform, "", "touch didn't work"); michael@0: EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); michael@0: finishUp(); michael@0: } michael@0: michael@0: michael@0: function finishUp() { michael@0: gBrowser.removeCurrentTab(); michael@0: finish(); michael@0: } michael@0: }