1.1 --- /dev/null Thu Jan 01 00:00:00 1970 +0000 1.2 +++ b/browser/devtools/responsivedesign/test/browser_responsiveui_touch.js Wed Dec 31 06:09:35 2014 +0100 1.3 @@ -0,0 +1,66 @@ 1.4 +/* Any copyright is dedicated to the Public Domain. 1.5 + http://creativecommons.org/publicdomain/zero/1.0/ */ 1.6 + 1.7 +function test() { 1.8 + let url = "http://mochi.test:8888/browser/browser/devtools/responsivedesign/test/touch.html"; 1.9 + 1.10 + let mgr = ResponsiveUI.ResponsiveUIManager; 1.11 + 1.12 + waitForExplicitFinish(); 1.13 + 1.14 + gBrowser.selectedTab = gBrowser.addTab(); 1.15 + gBrowser.selectedBrowser.addEventListener("load", function onload() { 1.16 + gBrowser.selectedBrowser.removeEventListener("load", onload, true); 1.17 + waitForFocus(startTest, content); 1.18 + }, true); 1.19 + 1.20 + content.location = url; 1.21 + 1.22 + function startTest() { 1.23 + mgr.once("on", function() {executeSoon(testWithNoTouch)}); 1.24 + mgr.once("off", function() {executeSoon(finishUp)}); 1.25 + mgr.toggle(window, gBrowser.selectedTab); 1.26 + } 1.27 + 1.28 + function testWithNoTouch() { 1.29 + let div = content.document.querySelector("div"); 1.30 + let x = 2, y = 2; 1.31 + EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); 1.32 + x += 20; y += 10; 1.33 + EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); 1.34 + is(div.style.transform, "", "touch didn't work"); 1.35 + EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); 1.36 + testWithTouch(); 1.37 + } 1.38 + 1.39 + function testWithTouch() { 1.40 + gBrowser.selectedTab.__responsiveUI.enableTouch(); 1.41 + let div = content.document.querySelector("div"); 1.42 + let x = 2, y = 2; 1.43 + EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); 1.44 + x += 20; y += 10; 1.45 + EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); 1.46 + is(div.style.transform, "translate(20px, 10px)", "touch worked"); 1.47 + EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); 1.48 + is(div.style.transform, "none", "end event worked"); 1.49 + mgr.toggle(window, gBrowser.selectedTab); 1.50 + } 1.51 + 1.52 + function testWithTouchAgain() { 1.53 + gBrowser.selectedTab.__responsiveUI.disableTouch(); 1.54 + let div = content.document.querySelector("div"); 1.55 + let x = 2, y = 2; 1.56 + EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); 1.57 + x += 20; y += 10; 1.58 + EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); 1.59 + is(div.style.transform, "", "touch didn't work"); 1.60 + EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); 1.61 + finishUp(); 1.62 + } 1.63 + 1.64 + 1.65 + function finishUp() { 1.66 + gBrowser.removeCurrentTab(); 1.67 + finish(); 1.68 + } 1.69 +}