2011-06-19 22:36:17 -07:00
|
|
|
<!DOCTYPE HTML>
|
|
|
|
<html>
|
|
|
|
<!--
|
|
|
|
https://bugzilla.mozilla.org/show_bug.cgi?id=662678
|
|
|
|
-->
|
|
|
|
<head>
|
|
|
|
<title>Test for Bug 662678</title>
|
|
|
|
<script type="application/javascript" src="/tests/SimpleTest/SimpleTest.js"></script>
|
|
|
|
<link rel="stylesheet" type="text/css" href="/tests/SimpleTest/test.css"/>
|
|
|
|
</head>
|
|
|
|
<body>
|
|
|
|
<a target="_blank" href="https://bugzilla.mozilla.org/show_bug.cgi?id=662678">Mozilla Bug 662678</a>
|
|
|
|
<p id="display"></p>
|
|
|
|
<div id="content" style="display: none">
|
|
|
|
|
|
|
|
</div>
|
|
|
|
<pre id="test">
|
|
|
|
<script type="application/javascript">
|
|
|
|
|
|
|
|
/** Test for Bug 662678 **/
|
2011-10-06 07:51:03 -07:00
|
|
|
SimpleTest.waitForExplicitFinish();
|
|
|
|
|
|
|
|
var checkMotion = function(event) {
|
|
|
|
window.removeEventListener("devicemotion", checkMotion, true);
|
2011-06-19 22:36:17 -07:00
|
|
|
|
2014-01-01 14:52:47 -08:00
|
|
|
is(event.acceleration.x, 1.5, "acceleration.x");
|
|
|
|
is(event.acceleration.y, 2.5, "acceleration.y");
|
|
|
|
is(event.acceleration.z, 3.5, "acceleration.z");
|
|
|
|
is(event.accelerationIncludingGravity.x, 4.5, "accelerationIncludingGravity.x");
|
|
|
|
is(event.accelerationIncludingGravity.y, 5.5, "accelerationIncludingGravity.y");
|
|
|
|
is(event.accelerationIncludingGravity.z, 6.5, "accelerationIncludingGravity.z");
|
|
|
|
is(event.rotationRate.alpha, 7.5, "rotationRate.alpha");
|
|
|
|
is(event.rotationRate.beta, 8.5, "rotationRate.beta");
|
|
|
|
is(event.rotationRate.gamma, 9.5, "rotationRate.gamma");
|
|
|
|
is(event.interval, 0.5, "interval");
|
2013-04-16 06:03:46 -07:00
|
|
|
|
|
|
|
var e = document.createEvent("DeviceMotionEvent");
|
|
|
|
e.initDeviceMotionEvent('devicemotion', true, true,
|
2014-01-01 14:52:47 -08:00
|
|
|
null, null, null, null);
|
|
|
|
is(e.acceleration.x, null, "acceleration.x");
|
|
|
|
is(e.acceleration.y, null, "acceleration.y");
|
|
|
|
is(e.acceleration.z, null, "acceleration.z");
|
|
|
|
is(e.accelerationIncludingGravity.x, null, "accelerationIncludingGravity.x");
|
|
|
|
is(e.accelerationIncludingGravity.y, null, "accelerationIncludingGravity.y");
|
|
|
|
is(e.accelerationIncludingGravity.z, null, "accelerationIncludingGravity.z");
|
|
|
|
is(e.rotationRate.alpha, null, "rotationRate.alpha");
|
|
|
|
is(e.rotationRate.beta, null, "rotationRate.beta");
|
|
|
|
is(e.rotationRate.gamma, null, "rotationRate.gamma");
|
|
|
|
is(e.interval, null, "interval");
|
2013-04-16 06:03:46 -07:00
|
|
|
|
|
|
|
e.initDeviceMotionEvent('devicemotion', true, true,
|
|
|
|
{}, {}, {}, 0);
|
2014-01-01 14:52:47 -08:00
|
|
|
is(e.acceleration.x, null, "acceleration.x");
|
|
|
|
is(e.acceleration.y, null, "acceleration.y");
|
|
|
|
is(e.acceleration.z, null, "acceleration.z");
|
|
|
|
is(e.accelerationIncludingGravity.x, null, "accelerationIncludingGravity.x");
|
|
|
|
is(e.accelerationIncludingGravity.y, null, "accelerationIncludingGravity.y");
|
|
|
|
is(e.accelerationIncludingGravity.z, null, "accelerationIncludingGravity.z");
|
|
|
|
is(e.rotationRate.alpha, null, "rotationRate.alpha");
|
|
|
|
is(e.rotationRate.beta, null, "rotationRate.beta");
|
|
|
|
is(e.rotationRate.gamma, null, "rotationRate.gamma");
|
|
|
|
is(e.interval, 0, "interval");
|
|
|
|
|
|
|
|
window.addEventListener("devicemotion", checkMotionCtor, true);
|
|
|
|
|
|
|
|
event = new DeviceMotionEvent('devicemotion', {
|
|
|
|
bubbles: true, cancelable: true,
|
|
|
|
acceleration: {x:1.5,y:2.5,z:3.5},
|
|
|
|
accelerationIncludingGravity: {x:4.5,y:5.5,z:6.5},
|
|
|
|
rotationRate: {alpha:7.5,beta:8.5,gamma:9.5},
|
|
|
|
interval: 0.5
|
|
|
|
});
|
|
|
|
window.dispatchEvent(event);
|
|
|
|
};
|
|
|
|
|
|
|
|
var checkMotionCtor = function(event) {
|
|
|
|
window.removeEventListener("devicemotion", checkMotionCtor, true);
|
|
|
|
|
|
|
|
is(event.acceleration.x, 1.5, "acceleration.x");
|
|
|
|
is(event.acceleration.y, 2.5, "acceleration.y");
|
|
|
|
is(event.acceleration.z, 3.5, "acceleration.z");
|
|
|
|
is(event.accelerationIncludingGravity.x, 4.5, "accelerationIncludingGravity.x");
|
|
|
|
is(event.accelerationIncludingGravity.y, 5.5, "accelerationIncludingGravity.y");
|
|
|
|
is(event.accelerationIncludingGravity.z, 6.5, "accelerationIncludingGravity.z");
|
|
|
|
is(event.rotationRate.alpha, 7.5, "rotationRate.alpha");
|
|
|
|
is(event.rotationRate.beta, 8.5, "rotationRate.beta");
|
|
|
|
is(event.rotationRate.gamma, 9.5, "rotationRate.gamma");
|
|
|
|
is(event.interval, 0.5, "interval");
|
2013-04-16 06:03:46 -07:00
|
|
|
|
2014-01-01 14:52:47 -08:00
|
|
|
var e = new DeviceMotionEvent('devicemotion');
|
|
|
|
is(e.acceleration.x, null, "acceleration.x");
|
|
|
|
is(e.acceleration.y, null, "acceleration.y");
|
|
|
|
is(e.acceleration.z, null, "acceleration.z");
|
|
|
|
is(e.accelerationIncludingGravity.x, null, "accelerationIncludingGravity.x");
|
|
|
|
is(e.accelerationIncludingGravity.y, null, "accelerationIncludingGravity.y");
|
|
|
|
is(e.accelerationIncludingGravity.z, null, "accelerationIncludingGravity.z");
|
|
|
|
is(e.rotationRate.alpha, null, "rotationRate.alpha");
|
|
|
|
is(e.rotationRate.beta, null, "rotationRate.beta");
|
|
|
|
is(e.rotationRate.gamma, null, "rotationRate.gamma");
|
|
|
|
is(e.interval, null, "interval");
|
2013-04-16 06:03:46 -07:00
|
|
|
|
2014-01-01 14:52:47 -08:00
|
|
|
e = new DeviceMotionEvent('devicemotion', {
|
|
|
|
bubbles: true, cancelable: true,
|
|
|
|
acceleration: null, accelerationIncludingGravity: null,
|
|
|
|
rotationRate: null, interval: null
|
|
|
|
});
|
|
|
|
is(e.acceleration.x, null, "acceleration.x");
|
|
|
|
is(e.acceleration.y, null, "acceleration.y");
|
|
|
|
is(e.acceleration.z, null, "acceleration.z");
|
|
|
|
is(e.accelerationIncludingGravity.x, null, "accelerationIncludingGravity.x");
|
|
|
|
is(e.accelerationIncludingGravity.y, null, "accelerationIncludingGravity.y");
|
|
|
|
is(e.accelerationIncludingGravity.z, null, "accelerationIncludingGravity.z");
|
|
|
|
is(e.rotationRate.alpha, null, "rotationRate.alpha");
|
|
|
|
is(e.rotationRate.beta, null, "rotationRate.beta");
|
|
|
|
is(e.rotationRate.gamma, null, "rotationRate.gamma");
|
|
|
|
is(e.interval, null, "interval");
|
2013-04-16 06:03:46 -07:00
|
|
|
|
2014-01-01 14:52:47 -08:00
|
|
|
e = new DeviceMotionEvent('devicemotion', {
|
|
|
|
bubbles: true, cancelable: true,
|
|
|
|
acceleration: {}, accelerationIncludingGravity: {},
|
|
|
|
rotationRate: {}, interval: 0
|
|
|
|
});
|
|
|
|
is(e.acceleration.x, null, "acceleration.x");
|
|
|
|
is(e.acceleration.y, null, "acceleration.y");
|
|
|
|
is(e.acceleration.z, null, "acceleration.z");
|
|
|
|
is(e.accelerationIncludingGravity.x, null, "accelerationIncludingGravity.x");
|
|
|
|
is(e.accelerationIncludingGravity.y, null, "accelerationIncludingGravity.y");
|
|
|
|
is(e.accelerationIncludingGravity.z, null, "accelerationIncludingGravity.z");
|
|
|
|
is(e.rotationRate.alpha, null, "rotationRate.alpha");
|
|
|
|
is(e.rotationRate.beta, null, "rotationRate.beta");
|
|
|
|
is(e.rotationRate.gamma, null, "rotationRate.gamma");
|
|
|
|
is(e.interval, 0, "interval");
|
2011-06-19 22:36:17 -07:00
|
|
|
|
|
|
|
SimpleTest.finish();
|
2011-10-06 07:51:03 -07:00
|
|
|
};
|
|
|
|
|
|
|
|
window.addEventListener("devicemotion", checkMotion, true);
|
2011-06-19 22:36:17 -07:00
|
|
|
|
|
|
|
var event = DeviceMotionEvent;
|
|
|
|
ok(!!event, "Should have seen DeviceMotionEvent!");
|
|
|
|
|
|
|
|
event = document.createEvent("DeviceMotionEvent");
|
|
|
|
event.initDeviceMotionEvent('devicemotion', true, true,
|
2013-04-16 06:03:46 -07:00
|
|
|
{x:1.5,y:2.5,z:3.5},
|
|
|
|
{x:4.5,y:5.5,z:6.5},
|
|
|
|
{alpha:7.5,beta:8.5,gamma:9.5},
|
2014-01-01 14:52:47 -08:00
|
|
|
0.5);
|
2011-06-19 22:36:17 -07:00
|
|
|
window.dispatchEvent(event);
|
|
|
|
|
|
|
|
</script>
|
|
|
|
</pre>
|
|
|
|
</body>
|
|
|
|
</html>
|