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

Side by Side Diff: third_party/WebKit/LayoutTests/fast/dom/DeviceMotion/optional-event-properties.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 the optional properties of DeviceMotionEvent. Each property s hould be null if not set, or set to null or undefined.");
7
8 function ObjectThrowingException() {};
9 ObjectThrowingException.prototype.valueOf = function() { throw new Error('valueO f threw exception'); }
10 ObjectThrowingException.prototype.__defineGetter__("x", function() { throw new E rror('x getter exception'); });
11 ObjectThrowingException.prototype.__defineGetter__("alpha", function() { throw n ew Error('alpha getter exception'); });
12 var objectThrowingException = new ObjectThrowingException();
13
14 function testException(expression, expectedException)
15 {
16 shouldThrow(expression, '(function() { return "' + expectedException + '"; } )();');
17 }
18
19 var event;
20
21 evalAndLog("event = document.createEvent('DeviceMotionEvent')");
22 shouldBeTrue("event.acceleration == null");
23 shouldBeTrue("event.accelerationIncludingGravity == null");
24 shouldBeTrue("event.rotationRate == null");
25 shouldBeTrue("event.interval == null");
26
27 evalAndLog("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x : 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9)");
28 shouldBeTrue("event.acceleration.x == 0");
29 shouldBeTrue("event.acceleration.y == 1");
30 shouldBeTrue("event.acceleration.z == 2");
31 shouldBeTrue("event.accelerationIncludingGravity.x == 3");
32 shouldBeTrue("event.accelerationIncludingGravity.y == 4");
33 shouldBeTrue("event.accelerationIncludingGravity.z == 5");
34 shouldBeTrue("event.rotationRate.alpha == 6");
35 shouldBeTrue("event.rotationRate.beta == 7");
36 shouldBeTrue("event.rotationRate.gamma == 8");
37 shouldBeTrue("event.interval == 9");
38
39 testException("event.initDeviceMotionEvent('', false, false, objectThrowingExcep tion, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9)", "Error: x getter exception");
40 testException("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, objectThrowingException, {gamma: 8, beta: 7}, 9)", "Error: x getter exception") ;
41 testException("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, z: 5}, objectThrowingException, 9)", "Error: alpha getter exception");
42
43 testException("event.initDeviceMotionEvent('', false, false, {x: objectThrowingE xception, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9)", " Error: valueOf threw exception");
44 testException("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: objectThrowingException, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9)", " Error: valueOf threw exception");
45 testException("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: objectThrowingException}, 9)", " Error: valueOf threw exception");
46
47 evalAndLog("event.initDeviceMotionEvent('', false, false, {y: 1, x: 0}, {x: 3, z : 5}, {gamma: 8, beta: 7}, 9)");
48 shouldBeTrue("event.acceleration.x == 0");
49 shouldBeTrue("event.acceleration.y == 1");
50 shouldBeTrue("event.acceleration.z == null");
51 shouldBeTrue("event.accelerationIncludingGravity.x == 3");
52 shouldBeTrue("event.accelerationIncludingGravity.y == null");
53 shouldBeTrue("event.accelerationIncludingGravity.z == 5");
54 shouldBeTrue("event.rotationRate.alpha == null");
55 shouldBeTrue("event.rotationRate.beta == 7");
56 shouldBeTrue("event.rotationRate.gamma == 8");
57 shouldBeTrue("event.interval == 9");
58
59 evalAndLog("event.initDeviceMotionEvent()");
60 shouldBeTrue("event.acceleration == null");
61 shouldBeTrue("event.accelerationIncludingGravity == null");
62 shouldBeTrue("event.rotationRate == null");
63 shouldBeTrue("event.interval == null");
64
65 evalAndLog("event.initDeviceMotionEvent('', false, false, [], [], [], [])");
66 shouldBeTrue("event.acceleration == null");
67 shouldBeTrue("event.accelerationIncludingGravity == null");
68 shouldBeTrue("event.rotationRate == null");
69 shouldBeTrue("event.interval == 0");
70
71 evalAndLog("event.initDeviceMotionEvent('', false, false, undefined, undefined, undefined, undefined)");
72 shouldBeTrue("event.acceleration == null");
73 shouldBeTrue("event.accelerationIncludingGravity == null");
74 shouldBeTrue("event.rotationRate == null");
75 shouldBeTrue("event.interval == null");
76
77 evalAndLog("event.initDeviceMotionEvent('', false, false, '', '', '', '')");
78 shouldBeTrue("event.acceleration == null");
79 shouldBeTrue("event.accelerationIncludingGravity == null");
80 shouldBeTrue("event.rotationRate == null");
81 shouldBeTrue("event.interval == 0");
82
83 evalAndLog("event.initDeviceMotionEvent('', false, false, null, null, null, null )");
84 shouldBeTrue("event.acceleration == null");
85 shouldBeTrue("event.accelerationIncludingGravity == null");
86 shouldBeTrue("event.rotationRate == null");
87 shouldBeTrue("event.interval == null");
88
89 evalAndLog("event.initDeviceMotionEvent('', false, false, {x: null, y: null, z: null}, {x: null, y: null, z: null}, {alpha: null, beta: null, gamma: null}, null )");
90 shouldBeTrue("event.acceleration == null");
91 shouldBeTrue("event.accelerationIncludingGravity == null");
92 shouldBeTrue("event.rotationRate == null");
93 shouldBeTrue("event.interval == null");
94
95 evalAndLog("event.initDeviceMotionEvent('', false, false, {x: null, y: null, z: 1}, {x: null, y: null, z: 2}, {alpha: null, beta: null, gamma: 3}, null)");
96 shouldBeTrue("event.acceleration.x == null");
97 shouldBeTrue("event.acceleration.y == null");
98 shouldBeTrue("event.acceleration.z == 1");
99 shouldBeTrue("event.accelerationIncludingGravity.x == null");
100 shouldBeTrue("event.accelerationIncludingGravity.y == null");
101 shouldBeTrue("event.accelerationIncludingGravity.z == 2");
102 shouldBeTrue("event.rotationRate.alpha == null");
103 shouldBeTrue("event.rotationRate.beta == null");
104 shouldBeTrue("event.rotationRate.gamma == 3");
105 shouldBeTrue("event.interval == null");
106
107 evalAndLog("event.initDeviceMotionEvent('', false, false, {x: undefined, y: unde fined, z: undefined}, {x: undefined, y: undefined, z: undefined}, {alpha: undefi ned, beta: undefined, gamma: undefined}, undefined)");
108 shouldBeTrue("event.acceleration == null");
109 shouldBeTrue("event.accelerationIncludingGravity == null");
110 shouldBeTrue("event.rotationRate == null");
111 shouldBeTrue("event.interval == null");
112
113 evalAndLog("event.initDeviceMotionEvent('', false, false, {x: undefined, y: unde fined, z: 1}, {x: undefined, y: undefined, z: 2}, {alpha: undefined, beta: undef ined, gamma: 3}, undefined)");
114 shouldBeTrue("event.acceleration.x == null");
115 shouldBeTrue("event.acceleration.y == null");
116 shouldBeTrue("event.acceleration.z == 1");
117 shouldBeTrue("event.accelerationIncludingGravity.x == null");
118 shouldBeTrue("event.accelerationIncludingGravity.y == null");
119 shouldBeTrue("event.accelerationIncludingGravity.z == 2");
120 shouldBeTrue("event.rotationRate.alpha == null");
121 shouldBeTrue("event.rotationRate.beta == null");
122 shouldBeTrue("event.rotationRate.gamma == 3");
123 shouldBeTrue("event.interval == null");
124 </script>
125 </body>
126 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698