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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/DeviceMotion/fire-last-event.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
7 description('Tests to see if the last available event is fired.');
8
9 var mockEvent;
10 function setMockMotion(accelerationX, accelerationY, accelerationZ,
11 accelerationIncludingGravityX, accelerationIncludingGravi tyY, accelerationIncludingGravityZ,
12 rotationRateAlpha, rotationRateBeta, rotationRateGamma,
13 interval) {
14
15 mockEvent = {accelerationX: accelerationX, accelerationY: accelerationY, acc elerationZ: accelerationZ,
16 accelerationIncludingGravityX: accelerationIncludingGravityX, a ccelerationIncludingGravityY: accelerationIncludingGravityY, accelerationIncludi ngGravityZ: accelerationIncludingGravityZ,
17 rotationRateAlpha: rotationRateAlpha, rotationRateBeta: rotatio nRateBeta, rotationRateGamma: rotationRateGamma,
18 interval: interval};
19
20 if (window.testRunner)
21 testRunner.setMockDeviceMotion(null != mockEvent.accelerationX, null == mockEvent.accelerationX ? 0 : mockEvent.accelerationX,
22 null != mockEvent.accelerationY, null == mockEvent.accelerationY ? 0 : mockEvent.accelerationY,
23 null != mockEvent.accelerationZ, null == mockEvent.accelerationZ ? 0 : mockEvent.accelerationZ,
24 null != mockEvent.accelerationIncludingGr avityX, null == mockEvent.accelerationIncludingGravityX ? 0 : mockEvent.accelera tionIncludingGravityX,
25 null != mockEvent.accelerationIncludingGr avityY, null == mockEvent.accelerationIncludingGravityY ? 0 : mockEvent.accelera tionIncludingGravityY,
26 null != mockEvent.accelerationIncludingGr avityZ, null == mockEvent.accelerationIncludingGravityZ ? 0 : mockEvent.accelera tionIncludingGravityZ,
27 null != mockEvent.rotationRateAlpha, null == mockEvent.rotationRateAlpha ? 0 : mockEvent.rotationRateAlpha,
28 null != mockEvent.rotationRateBeta, null == mockEvent.rotationRateBeta ? 0 : mockEvent.rotationRateBeta,
29 null != mockEvent.rotationRateGamma, null == mockEvent.rotationRateGamma ? 0 : mockEvent.rotationRateGamma,
30 interval);
31 else
32 debug('This test can not be run without the TestRunner');
33 }
34
35
36 var deviceMotionEvent;
37 function checkMotion(event) {
38 deviceMotionEvent = event;
39 shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX');
40 shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY');
41 shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ');
42
43 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.acce lerationIncludingGravityX');
44 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.acce lerationIncludingGravityY');
45 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.acce lerationIncludingGravityZ');
46
47 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlph a');
48 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta' );
49 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamm a');
50
51 shouldBe('deviceMotionEvent.interval', 'mockEvent.interval');
52 }
53
54
55 function mainFrameListener(event) {
56 checkMotion(event);
57 var childFrame = document.createElement('iframe');
58 document.body.appendChild(childFrame);
59 window.removeEventListener('devicemotion', mainFrameListener);
60 testRunner.setMockDeviceMotion(true, 0, true, 0, true, 0,
61 true, 0, true, 0, true, 0,
62 true, 0, true, 0, true, 0,
63 0);
64 childFrame.contentWindow.addEventListener('devicemotion', childFrameListener );
65 }
66
67 function childFrameListener(event) {
68 checkMotion(event);
69 finishJSTest();
70 }
71
72 setMockMotion(1, 2, 3,
73 4, 5, 6,
74 7, 8, 9,
75 10);
76
77 window.addEventListener('devicemotion', mainFrameListener);
78
79 window.jsTestIsAsync = true;
80
81 </script>
82 </body>
83 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698