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

Side by Side Diff: third_party/WebKit/LayoutTests/device_orientation/motion/optional-event-properties.html

Issue 2758933002: Fix default initialization for DeviceMotionEvent.interval. (Closed)
Patch Set: Rebased. Created 3 years, 9 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
1 <!DOCTYPE html> 1 <!DOCTYPE html>
2 <html> 2 <html>
3 <body> 3 <body>
4 <script src="../../resources/js-test.js"></script> 4 <script src="../../resources/js-test.js"></script>
5 <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."); 6 description("Tests the optional properties of DeviceMotionEvent. Each property s hould be null if not set, or set to null or undefined.");
7 7
8 function ObjectThrowingException() {}; 8 function ObjectThrowingException() {};
9 ObjectThrowingException.prototype.valueOf = function() { throw new Error('valueO f threw exception'); } 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'); }); 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'); }); 11 ObjectThrowingException.prototype.__defineGetter__("alpha", function() { throw n ew Error('alpha getter exception'); });
12 var objectThrowingException = new ObjectThrowingException(); 12 var objectThrowingException = new ObjectThrowingException();
13 13
14 function testException(expression, expectedException) 14 function testException(expression, expectedException)
15 { 15 {
16 shouldThrow(expression, '(function() { return "' + expectedException + '"; } )();'); 16 shouldThrow(expression, '(function() { return "' + expectedException + '"; } )();');
17 } 17 }
18 18
19 var event; 19 var event;
20 20
21 evalAndLog("event = document.createEvent('DeviceMotionEvent')"); 21 evalAndLog("event = document.createEvent('DeviceMotionEvent')");
22 shouldBeTrue("event.acceleration == null"); 22 shouldBeTrue("event.acceleration == null");
23 shouldBeTrue("event.accelerationIncludingGravity == null"); 23 shouldBeTrue("event.accelerationIncludingGravity == null");
24 shouldBeTrue("event.rotationRate == null"); 24 shouldBeTrue("event.rotationRate == null");
25 shouldBeTrue("event.interval == null"); 25 shouldBeTrue("event.interval == 0");
26 26
27 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, y: 4, z: 5}, rotationRate: {alpha: 6, beta : 7, gamma: 8}, interval: 9})"); 27 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, y: 4, z: 5}, rotationRate: {alpha: 6, beta : 7, gamma: 8}, interval: 9})");
28 shouldBeTrue("event.acceleration.x == 0"); 28 shouldBeTrue("event.acceleration.x == 0");
29 shouldBeTrue("event.acceleration.y == 1"); 29 shouldBeTrue("event.acceleration.y == 1");
30 shouldBeTrue("event.acceleration.z == 2"); 30 shouldBeTrue("event.acceleration.z == 2");
31 shouldBeTrue("event.accelerationIncludingGravity.x == 3"); 31 shouldBeTrue("event.accelerationIncludingGravity.x == 3");
32 shouldBeTrue("event.accelerationIncludingGravity.y == 4"); 32 shouldBeTrue("event.accelerationIncludingGravity.y == 4");
33 shouldBeTrue("event.accelerationIncludingGravity.z == 5"); 33 shouldBeTrue("event.accelerationIncludingGravity.z == 5");
34 shouldBeTrue("event.rotationRate.alpha == 6"); 34 shouldBeTrue("event.rotationRate.alpha == 6");
35 shouldBeTrue("event.rotationRate.beta == 7"); 35 shouldBeTrue("event.rotationRate.beta == 7");
(...skipping 17 matching lines...) Expand all
53 shouldBeTrue("event.accelerationIncludingGravity.z == 5"); 53 shouldBeTrue("event.accelerationIncludingGravity.z == 5");
54 shouldBeTrue("event.rotationRate.alpha == null"); 54 shouldBeTrue("event.rotationRate.alpha == null");
55 shouldBeTrue("event.rotationRate.beta == 7"); 55 shouldBeTrue("event.rotationRate.beta == 7");
56 shouldBeTrue("event.rotationRate.gamma == 8"); 56 shouldBeTrue("event.rotationRate.gamma == 8");
57 shouldBeTrue("event.interval == 9"); 57 shouldBeTrue("event.interval == 9");
58 58
59 evalAndLog("event = new DeviceMotionEvent('')"); 59 evalAndLog("event = new DeviceMotionEvent('')");
60 shouldBeTrue("event.acceleration == null"); 60 shouldBeTrue("event.acceleration == null");
61 shouldBeTrue("event.accelerationIncludingGravity == null"); 61 shouldBeTrue("event.accelerationIncludingGravity == null");
62 shouldBeTrue("event.rotationRate == null"); 62 shouldBeTrue("event.rotationRate == null");
63 shouldBeTrue("event.interval == null"); 63 shouldBeTrue("event.interval == 0");
64 64
65 evalAndLog("event = new DeviceMotionEvent('', {acceleration: [], accelerationInc ludingGravity: [], rotationRate: [], interval: []})"); 65 evalAndLog("event = new DeviceMotionEvent('', {acceleration: [], accelerationInc ludingGravity: [], rotationRate: [], interval: []})");
66 shouldBeTrue("event.acceleration.x == null"); 66 shouldBeTrue("event.acceleration.x == null");
67 shouldBeTrue("event.acceleration.y == null"); 67 shouldBeTrue("event.acceleration.y == null");
68 shouldBeTrue("event.acceleration.z == null"); 68 shouldBeTrue("event.acceleration.z == null");
69 shouldBeTrue("event.accelerationIncludingGravity.x == null"); 69 shouldBeTrue("event.accelerationIncludingGravity.x == null");
70 shouldBeTrue("event.accelerationIncludingGravity.y == null"); 70 shouldBeTrue("event.accelerationIncludingGravity.y == null");
71 shouldBeTrue("event.accelerationIncludingGravity.z == null"); 71 shouldBeTrue("event.accelerationIncludingGravity.z == null");
72 shouldBeTrue("event.rotationRate.alpha == null"); 72 shouldBeTrue("event.rotationRate.alpha == null");
73 shouldBeTrue("event.rotationRate.beta == null"); 73 shouldBeTrue("event.rotationRate.beta == null");
74 shouldBeTrue("event.rotationRate.gamma == null"); 74 shouldBeTrue("event.rotationRate.gamma == null");
75 shouldBeTrue("event.interval == 0"); 75 shouldBeTrue("event.interval == 0");
76 76
77 evalAndLog("event = new DeviceMotionEvent('', {acceleration: [], accelerationInc ludingGravity: undefined, rotationRate: undefined, interval: undefined})"); 77 evalAndLog("event = new DeviceMotionEvent('', {acceleration: [], accelerationInc ludingGravity: undefined, rotationRate: undefined, interval: undefined})");
78 shouldBeTrue("event.acceleration.x == null"); 78 shouldBeTrue("event.acceleration.x == null");
79 shouldBeTrue("event.acceleration.y == null"); 79 shouldBeTrue("event.acceleration.y == null");
80 shouldBeTrue("event.acceleration.z == null"); 80 shouldBeTrue("event.acceleration.z == null");
81 shouldBeTrue("event.accelerationIncludingGravity == null"); 81 shouldBeTrue("event.accelerationIncludingGravity == null");
82 shouldBeTrue("event.rotationRate == null"); 82 shouldBeTrue("event.rotationRate == null");
83 shouldBeTrue("event.interval == null"); 83 shouldBeTrue("event.interval == 0");
84 84
85 evalAndLog("event = new DeviceMotionEvent('', {acceleration: null, accelerationI ncludingGravity: null, rotationRate: null, interval: null})"); 85 evalAndLog("event = new DeviceMotionEvent('', {acceleration: null, accelerationI ncludingGravity: null, rotationRate: null, interval: null})");
86 shouldBeTrue("event.acceleration == null"); 86 shouldBeTrue("event.acceleration == null");
87 shouldBeTrue("event.accelerationIncludingGravity == null"); 87 shouldBeTrue("event.accelerationIncludingGravity == null");
88 shouldBeTrue("event.rotationRate == null"); 88 shouldBeTrue("event.rotationRate == null");
89 shouldBeTrue("event.interval == null"); 89 shouldBeTrue("event.interval == 0");
90 90
91 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: null, y: null, z: null}, accelerationIncludingGravity: {x: null, y: null, z: null}, rotationRat e: {alpha: null, beta: null, gamma: null}, interval: null})"); 91 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: null, y: null, z: null}, accelerationIncludingGravity: {x: null, y: null, z: null}, rotationRat e: {alpha: null, beta: null, gamma: null}, interval: null})");
92 shouldBeTrue("event.acceleration.x == null"); 92 shouldBeTrue("event.acceleration.x == null");
93 shouldBeTrue("event.acceleration.y == null"); 93 shouldBeTrue("event.acceleration.y == null");
94 shouldBeTrue("event.acceleration.z == null"); 94 shouldBeTrue("event.acceleration.z == null");
95 shouldBeTrue("event.accelerationIncludingGravity.x == null"); 95 shouldBeTrue("event.accelerationIncludingGravity.x == null");
96 shouldBeTrue("event.accelerationIncludingGravity.y == null"); 96 shouldBeTrue("event.accelerationIncludingGravity.y == null");
97 shouldBeTrue("event.accelerationIncludingGravity.z == null"); 97 shouldBeTrue("event.accelerationIncludingGravity.z == null");
98 shouldBeTrue("event.rotationRate.alpha == null"); 98 shouldBeTrue("event.rotationRate.alpha == null");
99 shouldBeTrue("event.rotationRate.beta == null"); 99 shouldBeTrue("event.rotationRate.beta == null");
100 shouldBeTrue("event.rotationRate.gamma == null"); 100 shouldBeTrue("event.rotationRate.gamma == null");
101 shouldBeTrue("event.interval == null"); 101 shouldBeTrue("event.interval == 0");
102 102
103 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: null, y: null, z: 1}, accelerationIncludingGravity: {x: null, y: null, z: 2}, rotationRate: {al pha: null, beta: null, gamma: 3}, interval: null})"); 103 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: null, y: null, z: 1}, accelerationIncludingGravity: {x: null, y: null, z: 2}, rotationRate: {al pha: null, beta: null, gamma: 3}, interval: null})");
104 shouldBeTrue("event.acceleration.x == null"); 104 shouldBeTrue("event.acceleration.x == null");
105 shouldBeTrue("event.acceleration.y == null"); 105 shouldBeTrue("event.acceleration.y == null");
106 shouldBeTrue("event.acceleration.z == 1"); 106 shouldBeTrue("event.acceleration.z == 1");
107 shouldBeTrue("event.accelerationIncludingGravity.x == null"); 107 shouldBeTrue("event.accelerationIncludingGravity.x == null");
108 shouldBeTrue("event.accelerationIncludingGravity.y == null"); 108 shouldBeTrue("event.accelerationIncludingGravity.y == null");
109 shouldBeTrue("event.accelerationIncludingGravity.z == 2"); 109 shouldBeTrue("event.accelerationIncludingGravity.z == 2");
110 shouldBeTrue("event.rotationRate.alpha == null"); 110 shouldBeTrue("event.rotationRate.alpha == null");
111 shouldBeTrue("event.rotationRate.beta == null"); 111 shouldBeTrue("event.rotationRate.beta == null");
112 shouldBeTrue("event.rotationRate.gamma == 3"); 112 shouldBeTrue("event.rotationRate.gamma == 3");
113 shouldBeTrue("event.interval == null"); 113 shouldBeTrue("event.interval == 0");
114 114
115 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: undefined, y: u ndefined, z: undefined}, accelerationIncludingGravity: {x: undefined, y: undefin ed, z: undefined}, rotationRate: {alpha: undefined, beta: undefined, gamma: unde fined}, interval: undefined})"); 115 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: undefined, y: u ndefined, z: undefined}, accelerationIncludingGravity: {x: undefined, y: undefin ed, z: undefined}, rotationRate: {alpha: undefined, beta: undefined, gamma: unde fined}, interval: undefined})");
116 shouldBeTrue("event.acceleration.x == null"); 116 shouldBeTrue("event.acceleration.x == null");
117 shouldBeTrue("event.acceleration.y == null"); 117 shouldBeTrue("event.acceleration.y == null");
118 shouldBeTrue("event.acceleration.z == null"); 118 shouldBeTrue("event.acceleration.z == null");
119 shouldBeTrue("event.accelerationIncludingGravity.x == null"); 119 shouldBeTrue("event.accelerationIncludingGravity.x == null");
120 shouldBeTrue("event.accelerationIncludingGravity.y == null"); 120 shouldBeTrue("event.accelerationIncludingGravity.y == null");
121 shouldBeTrue("event.accelerationIncludingGravity.z == null"); 121 shouldBeTrue("event.accelerationIncludingGravity.z == null");
122 shouldBeTrue("event.rotationRate.alpha == null"); 122 shouldBeTrue("event.rotationRate.alpha == null");
123 shouldBeTrue("event.rotationRate.beta == null"); 123 shouldBeTrue("event.rotationRate.beta == null");
124 shouldBeTrue("event.rotationRate.gamma == null"); 124 shouldBeTrue("event.rotationRate.gamma == null");
125 shouldBeTrue("event.interval == null"); 125 shouldBeTrue("event.interval == 0");
126 126
127 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: undefined, y: u ndefined, z: 1}, accelerationIncludingGravity: {x: undefined, y: undefined, z: 2 }, rotationRate: {alpha: undefined, beta: undefined, gamma: 3}, interval: undefi ned})"); 127 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: undefined, y: u ndefined, z: 1}, accelerationIncludingGravity: {x: undefined, y: undefined, z: 2 }, rotationRate: {alpha: undefined, beta: undefined, gamma: 3}, interval: undefi ned})");
128 shouldBeTrue("event.acceleration.x == null"); 128 shouldBeTrue("event.acceleration.x == null");
129 shouldBeTrue("event.acceleration.y == null"); 129 shouldBeTrue("event.acceleration.y == null");
130 shouldBeTrue("event.acceleration.z == 1"); 130 shouldBeTrue("event.acceleration.z == 1");
131 shouldBeTrue("event.accelerationIncludingGravity.x == null"); 131 shouldBeTrue("event.accelerationIncludingGravity.x == null");
132 shouldBeTrue("event.accelerationIncludingGravity.y == null"); 132 shouldBeTrue("event.accelerationIncludingGravity.y == null");
133 shouldBeTrue("event.accelerationIncludingGravity.z == 2"); 133 shouldBeTrue("event.accelerationIncludingGravity.z == 2");
134 shouldBeTrue("event.rotationRate.alpha == null"); 134 shouldBeTrue("event.rotationRate.alpha == null");
135 shouldBeTrue("event.rotationRate.beta == null"); 135 shouldBeTrue("event.rotationRate.beta == null");
136 shouldBeTrue("event.rotationRate.gamma == 3"); 136 shouldBeTrue("event.rotationRate.gamma == 3");
137 shouldBeTrue("event.interval == null"); 137 shouldBeTrue("event.interval == 0");
138 </script> 138 </script>
139 </body> 139 </body>
140 </html> 140 </html>
OLDNEW

Powered by Google App Engine
This is Rietveld 408576698