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.

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

mercurial