Wed, 31 Dec 2014 06:09:35 +0100
Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.
michael@0 | 1 | /* Any copyright is dedicated to the Public Domain. |
michael@0 | 2 | http://creativecommons.org/publicdomain/zero/1.0/ */ |
michael@0 | 3 | |
michael@0 | 4 | function test() { |
michael@0 | 5 | let url = "http://mochi.test:8888/browser/browser/devtools/responsivedesign/test/touch.html"; |
michael@0 | 6 | |
michael@0 | 7 | let mgr = ResponsiveUI.ResponsiveUIManager; |
michael@0 | 8 | |
michael@0 | 9 | waitForExplicitFinish(); |
michael@0 | 10 | |
michael@0 | 11 | gBrowser.selectedTab = gBrowser.addTab(); |
michael@0 | 12 | gBrowser.selectedBrowser.addEventListener("load", function onload() { |
michael@0 | 13 | gBrowser.selectedBrowser.removeEventListener("load", onload, true); |
michael@0 | 14 | waitForFocus(startTest, content); |
michael@0 | 15 | }, true); |
michael@0 | 16 | |
michael@0 | 17 | content.location = url; |
michael@0 | 18 | |
michael@0 | 19 | function startTest() { |
michael@0 | 20 | mgr.once("on", function() {executeSoon(testWithNoTouch)}); |
michael@0 | 21 | mgr.once("off", function() {executeSoon(finishUp)}); |
michael@0 | 22 | mgr.toggle(window, gBrowser.selectedTab); |
michael@0 | 23 | } |
michael@0 | 24 | |
michael@0 | 25 | function testWithNoTouch() { |
michael@0 | 26 | let div = content.document.querySelector("div"); |
michael@0 | 27 | let x = 2, y = 2; |
michael@0 | 28 | EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); |
michael@0 | 29 | x += 20; y += 10; |
michael@0 | 30 | EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); |
michael@0 | 31 | is(div.style.transform, "", "touch didn't work"); |
michael@0 | 32 | EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); |
michael@0 | 33 | testWithTouch(); |
michael@0 | 34 | } |
michael@0 | 35 | |
michael@0 | 36 | function testWithTouch() { |
michael@0 | 37 | gBrowser.selectedTab.__responsiveUI.enableTouch(); |
michael@0 | 38 | let div = content.document.querySelector("div"); |
michael@0 | 39 | let x = 2, y = 2; |
michael@0 | 40 | EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); |
michael@0 | 41 | x += 20; y += 10; |
michael@0 | 42 | EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); |
michael@0 | 43 | is(div.style.transform, "translate(20px, 10px)", "touch worked"); |
michael@0 | 44 | EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); |
michael@0 | 45 | is(div.style.transform, "none", "end event worked"); |
michael@0 | 46 | mgr.toggle(window, gBrowser.selectedTab); |
michael@0 | 47 | } |
michael@0 | 48 | |
michael@0 | 49 | function testWithTouchAgain() { |
michael@0 | 50 | gBrowser.selectedTab.__responsiveUI.disableTouch(); |
michael@0 | 51 | let div = content.document.querySelector("div"); |
michael@0 | 52 | let x = 2, y = 2; |
michael@0 | 53 | EventUtils.synthesizeMouse(div, x, y, {type: "mousedown", isSynthesized: false}, content); |
michael@0 | 54 | x += 20; y += 10; |
michael@0 | 55 | EventUtils.synthesizeMouse(div, x, y, {type: "mousemove", isSynthesized: false}, content); |
michael@0 | 56 | is(div.style.transform, "", "touch didn't work"); |
michael@0 | 57 | EventUtils.synthesizeMouse(div, x, y, {type: "mouseup", isSynthesized: false}, content); |
michael@0 | 58 | finishUp(); |
michael@0 | 59 | } |
michael@0 | 60 | |
michael@0 | 61 | |
michael@0 | 62 | function finishUp() { |
michael@0 | 63 | gBrowser.removeCurrentTab(); |
michael@0 | 64 | finish(); |
michael@0 | 65 | } |
michael@0 | 66 | } |