browser/devtools/responsivedesign/test/browser_responsiveui_touch.js

Wed, 31 Dec 2014 06:09:35 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Wed, 31 Dec 2014 06:09:35 +0100
changeset 0
6474c204b198
permissions
-rw-r--r--

Cloned upstream origin tor-browser at tor-browser-31.3.0esr-4.5-1-build1
revision ID fc1c9ff7c1b2defdbc039f12214767608f46423f for hacking purpose.

     1 /* Any copyright is dedicated to the Public Domain.
     2    http://creativecommons.org/publicdomain/zero/1.0/ */
     4 function test() {
     5   let url = "http://mochi.test:8888/browser/browser/devtools/responsivedesign/test/touch.html";
     7   let mgr = ResponsiveUI.ResponsiveUIManager;
     9   waitForExplicitFinish();
    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);
    17   content.location = url;
    19   function startTest() {
    20     mgr.once("on", function() {executeSoon(testWithNoTouch)});
    21     mgr.once("off", function() {executeSoon(finishUp)});
    22     mgr.toggle(window, gBrowser.selectedTab);
    23   }
    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   }
    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   }
    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   }
    62   function finishUp() {
    63     gBrowser.removeCurrentTab();
    64     finish();
    65   }
    66 }

mercurial