| Index: LayoutTests/fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js
|
| diff --git a/LayoutTests/fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js b/LayoutTests/fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js
|
| new file mode 100644
|
| index 0000000000000000000000000000000000000000..9036e3f790b84458d0612795ece64997975f90e8
|
| --- /dev/null
|
| +++ b/LayoutTests/fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js
|
| @@ -0,0 +1,53 @@
|
| +description('Tests that adding a new devicemotion event listener from a callback works as expected.');
|
| +
|
| +var mockAccelerationX = 1.1;
|
| +var mockAccelerationY = 2.1;
|
| +var mockAccelerationZ = 3.1;
|
| +
|
| +var mockAccelerationIncludingGravityX = 1.2;
|
| +var mockAccelerationIncludingGravityY = 2.2;
|
| +var mockAccelerationIncludingGravityZ = 3.2;
|
| +
|
| +var mockRotationRateAlpha = 1.3;
|
| +var mockRotationRateBeta = 2.3;
|
| +var mockRotationRateGamma = 3.3;
|
| +
|
| +var mockInterval = 100;
|
| +
|
| +if (window.testRunner) {
|
| + testRunner.enableMockDeviceMotion();
|
| + debug('TEST MODE enabled');
|
| +} else
|
| + debug('This test can not be run without the TestRunner');
|
| +
|
| +var deviceOrientationEvent;
|
| +function checkOrientation(event) {
|
| + deviceOrientationEvent = event;
|
| + shouldBe('deviceOrientationEvent.acceleration.x', 'mockAccelerationX');
|
| + shouldBe('deviceOrientationEvent.acceleration.y', 'mockAccelerationY');
|
| + shouldBe('deviceOrientationEvent.acceleration.z', 'mockAccelerationZ');
|
| +
|
| + shouldBe('deviceOrientationEvent.accelerationIncludingGravity.x', 'mockAccelerationIncludingGravityX');
|
| + shouldBe('deviceOrientationEvent.accelerationIncludingGravity.y', 'mockAccelerationIncludingGravityY');
|
| + shouldBe('deviceOrientationEvent.accelerationIncludingGravity.z', 'mockAccelerationIncludingGravityZ');
|
| +
|
| + shouldBe('deviceOrientationEvent.rotationRate.alpha', 'mockRotationRateAlpha');
|
| + shouldBe('deviceOrientationEvent.rotationRate.beta', 'mockRotationRateBeta');
|
| + shouldBe('deviceOrientationEvent.rotationRate.gamma', 'mockRotationRateGamma');
|
| +
|
| + shouldBe('deviceOrientationEvent.interval', 'mockInterval');
|
| +}
|
| +
|
| +function listener(event) {
|
| + checkOrientation(event);
|
| + finishJSTest();
|
| +}
|
| +
|
| +window.addEventListener('devicemotion', listener);
|
| +window.jsTestIsAsync = true;
|
| +
|
| +if (window.testRunner)
|
| + testRunner.fireMockDeviceMotion(true, mockAccelerationX, true, mockAccelerationY, true, mockAccelerationZ,
|
| + true, mockAccelerationIncludingGravityX, true, mockAccelerationIncludingGravityY, true, mockAccelerationIncludingGravityZ,
|
| + true, mockRotationRateAlpha, true, mockRotationRateBeta, true, mockRotationRateGamma,
|
| + mockInterval);
|
|
|