diff -r 000000000000 -r 6474c204b198 browser/devtools/responsivedesign/test/browser_responsiveui_touch.js --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/browser/devtools/responsivedesign/test/browser_responsiveui_touch.js Wed Dec 31 06:09:35 2014 +0100 @@ -0,0 +1,66 @@ +/* Any copyright is dedicated to the Public Domain. + http://creativecommons.org/publicdomain/zero/1.0/ */ + +function test() { + let url = "http://mochi.test:8888/browser/browser/devtools/responsivedesign/test/touch.html"; + + let mgr = ResponsiveUI.ResponsiveUIManager; + + waitForExplicitFinish(); + + gBrowser.selectedTab = gBrowser.addTab(); + gBrowser.selectedBrowser.addEventListener("load", function onload() { + gBrowser.selectedBrowser.removeEventListener("load", onload, true); + waitForFocus(startTest, content); + }, true); + + content.location = url; + + function startTest() { + mgr.once("on", function() {executeSoon(testWithNoTouch)}); + mgr.once("off", function() {executeSoon(finishUp)}); + mgr.toggle(window, gBrowser.selectedTab); + } + + function testWithNoTouch() { + let div = content.document.querySelector("div"); + let x = 2, y = 2; + EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); + x += 20; y += 10; + EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); + is(div.style.transform, "", "touch didn't work"); + EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); + testWithTouch(); + } + + function testWithTouch() { + gBrowser.selectedTab.__responsiveUI.enableTouch(); + let div = content.document.querySelector("div"); + let x = 2, y = 2; + EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); + x += 20; y += 10; + EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); + is(div.style.transform, "translate(20px, 10px)", "touch worked"); + EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); + is(div.style.transform, "none", "end event worked"); + mgr.toggle(window, gBrowser.selectedTab); + } + + function testWithTouchAgain() { + gBrowser.selectedTab.__responsiveUI.disableTouch(); + let div = content.document.querySelector("div"); + let x = 2, y = 2; + EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); + x += 20; y += 10; + EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); + is(div.style.transform, "", "touch didn't work"); + EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); + finishUp(); + } + + + function finishUp() { + gBrowser.removeCurrentTab(); + finish(); + } +}