dom/events/test/marionette/test_sensor_orientation.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 MARIONETTE_TIMEOUT = 120000;
     5 MARIONETTE_HEAD_JS = 'head.js';
     7 function doTest(aAzimuth, aPitch, aRoll) {
     8   log("Testing [azimuth, pitch, roll] = " + Array.slice(arguments));
    10   return setEmulatorOrientationValues(aAzimuth, aPitch, aRoll)
    11     .then(() => waitForWindowEvent("deviceorientation"))
    12     .then(function(aEvent) {
    13       is(aEvent.alpha, aAzimuth, "azimuth");
    14       is(aEvent.beta,  aPitch, "pitch");
    15       is(aEvent.gamma, aRoll, "roll");
    16     });
    17 }
    19 function testAllPermutations() {
    20   const angles = [-180, -90, 0, 90, 180];
    21   let promise = Promise.resolve();
    22   for (let i = 0; i < angles.length; i++) {
    23     for (let j = 0; j < angles.length; j++) {
    24       for (let k = 0; k < angles.length; k++) {
    25         promise =
    26           promise.then(doTest.bind(null, angles[i], angles[j], angles[k]));
    27       }
    28     }
    29   }
    30   return promise;
    31 }
    33 startTestBase(function() {
    34   let origValues;
    36   return Promise.resolve()
    38     // Retrieve original status.
    39     .then(() => getEmulatorOrientationValues())
    40     .then(function(aValues) {
    41       origValues = aValues;
    42       is(typeof origValues, "object", "typeof origValues");
    43       is(origValues.length, 3, "origValues.length");
    44     })
    46     // Test original status
    47     .then(() => doTest.apply(null, origValues))
    49     .then(testAllPermutations)
    51     // Restore original status.
    52     .then(() => setEmulatorOrientationValues.apply(null, origValues));
    53 });

mercurial