Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(205)

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback.html

Issue 2677603003: Move DeviceMotion and DeviceOrientation out from fast/dom/. (Closed)
Patch Set: device_orientation Created 3 years, 10 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View unified diff | Download patch
OLDNEW
(Empty)
1 <!DOCTYPE html>
2 <html>
3 <body>
4 <script src="../../../resources/js-test.js"></script>
5 <script>
6 description('Tests that adding a new devicemotion event listener from a callback works as expected.');
7
8 var mockAccelerationX = 1.1;
9 var mockAccelerationY = 2.1;
10 var mockAccelerationZ = 3.1;
11
12 var mockAccelerationIncludingGravityX = 1.2;
13 var mockAccelerationIncludingGravityY = 2.2;
14 var mockAccelerationIncludingGravityZ = 3.2;
15
16 var mockRotationRateAlpha = 1.3;
17 var mockRotationRateBeta = 2.3;
18 var mockRotationRateGamma = 3.3;
19
20 var mockInterval = 100;
21
22 if (window.testRunner) {
23 testRunner.setMockDeviceMotion(true, mockAccelerationX, true, mockAccelerati onY, true, mockAccelerationZ,
24 true, mockAccelerationIncludingGravityX, true , mockAccelerationIncludingGravityY, true, mockAccelerationIncludingGravityZ,
25 true, mockRotationRateAlpha, true, mockRotati onRateBeta, true, mockRotationRateGamma,
26 mockInterval);
27 debug('TEST MODE enabled');
28 } else
29 debug('This test can not be run without the TestRunner');
30
31 var deviceMotionEvent;
32 function checkMotion(event) {
33 deviceMotionEvent = event;
34 shouldBe('deviceMotionEvent.acceleration.x', 'mockAccelerationX');
35 shouldBe('deviceMotionEvent.acceleration.y', 'mockAccelerationY');
36 shouldBe('deviceMotionEvent.acceleration.z', 'mockAccelerationZ');
37
38 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockAccelerati onIncludingGravityX');
39 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockAccelerati onIncludingGravityY');
40 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockAccelerati onIncludingGravityZ');
41
42 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockRotationRateAlpha');
43 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockRotationRateBeta');
44 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockRotationRateGamma');
45
46 shouldBe('deviceMotionEvent.interval', 'mockInterval');
47 }
48
49 function listener(event) {
50 checkMotion(event);
51 finishJSTest();
52 }
53
54 window.addEventListener('devicemotion', listener);
55 window.jsTestIsAsync = true;
56 </script>
57 </body>
58 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698