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