| Index: LayoutTests/fast/dom/DeviceMotion/fire-last-event.html
|
| diff --git a/LayoutTests/fast/dom/DeviceMotion/fire-last-event.html b/LayoutTests/fast/dom/DeviceMotion/fire-last-event.html
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..e840d15e0af2c6de0ceea22e3a8c787b7521c0dc
|
| --- /dev/null
|
| +++ b/LayoutTests/fast/dom/DeviceMotion/fire-last-event.html
|
| @@ -0,0 +1,85 @@
|
| +<html>
|
| +<head>
|
| +<script src="../../js/resources/js-test-pre.js"></script>
|
| +</head>
|
| +<body>
|
| +<script>
|
| +
|
| +description('Tests to see if the last available event is fired.');
|
| +
|
| +var mockEvent;
|
| +function setMockMotion(accelerationX, accelerationY, accelerationZ,
|
| + accelerationIncludingGravityX, accelerationIncludingGravityY, accelerationIncludingGravityZ,
|
| + rotationRateAlpha, rotationRateBeta, rotationRateGamma,
|
| + interval) {
|
| +
|
| + mockEvent = {accelerationX: accelerationX, accelerationY: accelerationY, accelerationZ: accelerationZ,
|
| + accelerationIncludingGravityX: accelerationIncludingGravityX, accelerationIncludingGravityY: accelerationIncludingGravityY, accelerationIncludingGravityZ: accelerationIncludingGravityZ,
|
| + rotationRateAlpha: rotationRateAlpha, rotationRateBeta: rotationRateBeta, rotationRateGamma: rotationRateGamma,
|
| + interval: interval};
|
| +
|
| + if (window.testRunner)
|
| + testRunner.setMockDeviceMotion(null != mockEvent.accelerationX, null == mockEvent.accelerationX ? 0 : mockEvent.accelerationX,
|
| + null != mockEvent.accelerationY, null == mockEvent.accelerationY ? 0 : mockEvent.accelerationY,
|
| + null != mockEvent.accelerationZ, null == mockEvent.accelerationZ ? 0 : mockEvent.accelerationZ,
|
| + null != mockEvent.accelerationIncludingGravityX, null == mockEvent.accelerationIncludingGravityX ? 0 : mockEvent.accelerationIncludingGravityX,
|
| + null != mockEvent.accelerationIncludingGravityY, null == mockEvent.accelerationIncludingGravityY ? 0 : mockEvent.accelerationIncludingGravityY,
|
| + null != mockEvent.accelerationIncludingGravityZ, null == mockEvent.accelerationIncludingGravityZ ? 0 : mockEvent.accelerationIncludingGravityZ,
|
| + null != mockEvent.rotationRateAlpha, null == mockEvent.rotationRateAlpha ? 0 : mockEvent.rotationRateAlpha,
|
| + null != mockEvent.rotationRateBeta, null == mockEvent.rotationRateBeta ? 0 : mockEvent.rotationRateBeta,
|
| + null != mockEvent.rotationRateGamma, null == mockEvent.rotationRateGamma ? 0 : mockEvent.rotationRateGamma,
|
| + interval);
|
| + else
|
| + debug('This test can not be run without the TestRunner');
|
| +}
|
| +
|
| +
|
| +var deviceMotionEvent;
|
| +function checkMotion(event) {
|
| + deviceMotionEvent = event;
|
| + shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX');
|
| + shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY');
|
| + shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ');
|
| +
|
| + shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.accelerationIncludingGravityX');
|
| + shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.accelerationIncludingGravityY');
|
| + shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.accelerationIncludingGravityZ');
|
| +
|
| + shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlpha');
|
| + shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta');
|
| + shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamma');
|
| +
|
| + shouldBe('deviceMotionEvent.interval', 'mockEvent.interval');
|
| +}
|
| +
|
| +
|
| +function mainFrameListener(event) {
|
| + checkMotion(event);
|
| + var childFrame = document.createElement('iframe');
|
| + document.body.appendChild(childFrame);
|
| + window.removeEventListener('devicemotion', mainFrameListener);
|
| + testRunner.setMockDeviceMotion(true, 0, true, 0, true, 0,
|
| + true, 0, true, 0, true, 0,
|
| + true, 0, true, 0, true, 0,
|
| + 0);
|
| + childFrame.contentWindow.addEventListener('devicemotion', childFrameListener);
|
| +}
|
| +
|
| +function childFrameListener(event) {
|
| + checkMotion(event);
|
| + finishJSTest();
|
| +}
|
| +
|
| +setMockMotion(1, 2, 3,
|
| + 4, 5, 6,
|
| + 7, 8, 9,
|
| + 10);
|
| +
|
| +window.addEventListener('devicemotion', mainFrameListener);
|
| +
|
| +window.jsTestIsAsync = true;
|
| +
|
| +</script>
|
| +<script src="../../js/resources/js-test-post.js"></script>
|
| +</body>
|
| +</html>
|
|
|