| OLD | NEW | 
|---|
| 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 == null"); | 
| 26 | 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)"); | 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"); | 
| 36 shouldBeTrue("event.rotationRate.gamma == 8"); | 36 shouldBeTrue("event.rotationRate.gamma == 8"); | 
| 37 shouldBeTrue("event.interval == 9"); | 37 shouldBeTrue("event.interval == 9"); | 
| 38 | 38 | 
| 39 testException("event.initDeviceMotionEvent('', false, false, objectThrowingExcep
     tion, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9)", "Error: x getter exception"); | 39 testException("event = new DeviceMotionEvent('', {acceleration: objectThrowingEx
     ception, accelerationIncludingGravity: {x: 3, z: 5}, rotationRate: {gamma: 8, be
     ta: 7}, interval: 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")
     ; | 40 testException("event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 
     2}, accelerationIncludingGravity: objectThrowingException, rotationRate: {gamma:
      8, beta: 7}, interval: 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"); | 41 testException("event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 
     2}, accelerationIncludingGravity: {x: 3, z: 5}, rotationRate: objectThrowingExce
     ption, interval: 9})", "Error: alpha getter exception"); | 
| 42 | 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"); | 43 testException("event = new DeviceMotionEvent('', {acceleration: {x: objectThrowi
     ngException, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, y: 4, z: 5}, rota
     tionRate: {alpha: 6, beta: 7, gamma: 8}, interval: 9})", "Error: valueOf threw e
     xception"); | 
| 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"); | 44 testException("event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 
     2}, accelerationIncludingGravity: {x: 3, y: objectThrowingException, z: 5}, rota
     tionRate: {alpha: 6, beta: 7, gamma: 8}, interval: 9})", "Error: valueOf threw e
     xception"); | 
| 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"); | 45 testException("event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 
     2}, accelerationIncludingGravity: {x: 3, y: 4, z: 5}, rotationRate: {alpha: 6, b
     eta: 7, gamma: objectThrowingException}, interval: 9})", "Error: valueOf threw e
     xception"); | 
| 46 | 46 | 
| 47 evalAndLog("event.initDeviceMotionEvent('', false, false, {y: 1, x: 0}, {x: 3, z
     : 5}, {gamma: 8, beta: 7}, 9)"); | 47 evalAndLog("event = new DeviceMotionEvent('', {acceleration: {y: 1, x: 0}, accel
     erationIncludingGravity: {x: 3, z: 5}, rotationRate: {gamma: 8, beta: 7}, interv
     al: 9})"); | 
| 48 shouldBeTrue("event.acceleration.x == 0"); | 48 shouldBeTrue("event.acceleration.x == 0"); | 
| 49 shouldBeTrue("event.acceleration.y == 1"); | 49 shouldBeTrue("event.acceleration.y == 1"); | 
| 50 shouldBeTrue("event.acceleration.z == null"); | 50 shouldBeTrue("event.acceleration.z == null"); | 
| 51 shouldBeTrue("event.accelerationIncludingGravity.x == 3"); | 51 shouldBeTrue("event.accelerationIncludingGravity.x == 3"); | 
| 52 shouldBeTrue("event.accelerationIncludingGravity.y == null"); | 52 shouldBeTrue("event.accelerationIncludingGravity.y == null"); | 
| 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.initDeviceMotionEvent()"); | 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 == null"); | 
| 64 | 64 | 
| 65 evalAndLog("event.initDeviceMotionEvent('', false, false, [], [], [], [])"); | 65 evalAndLog("event = new DeviceMotionEvent('', {acceleration: [], accelerationInc
     ludingGravity: [], rotationRate: [], interval: []})"); | 
| 66 shouldBeTrue("event.acceleration == null"); | 66 shouldBeTrue("event.acceleration.x == null"); | 
|  | 67 shouldBeTrue("event.acceleration.y == null"); | 
|  | 68 shouldBeTrue("event.acceleration.z == null"); | 
|  | 69 shouldBeTrue("event.accelerationIncludingGravity.x == null"); | 
|  | 70 shouldBeTrue("event.accelerationIncludingGravity.y == null"); | 
|  | 71 shouldBeTrue("event.accelerationIncludingGravity.z == null"); | 
|  | 72 shouldBeTrue("event.rotationRate.alpha == null"); | 
|  | 73 shouldBeTrue("event.rotationRate.beta == null"); | 
|  | 74 shouldBeTrue("event.rotationRate.gamma == null"); | 
|  | 75 shouldBeTrue("event.interval == 0"); | 
|  | 76 | 
|  | 77 evalAndLog("event = new DeviceMotionEvent('', {acceleration: [], accelerationInc
     ludingGravity: undefined, rotationRate: undefined, interval: undefined})"); | 
|  | 78 shouldBeTrue("event.acceleration.x == null"); | 
|  | 79 shouldBeTrue("event.acceleration.y == null"); | 
|  | 80 shouldBeTrue("event.acceleration.z == null"); | 
| 67 shouldBeTrue("event.accelerationIncludingGravity == null"); | 81 shouldBeTrue("event.accelerationIncludingGravity == null"); | 
| 68 shouldBeTrue("event.rotationRate == null"); | 82 shouldBeTrue("event.rotationRate == null"); | 
| 69 shouldBeTrue("event.interval == 0"); | 83 shouldBeTrue("event.interval == null"); | 
| 70 | 84 | 
| 71 evalAndLog("event.initDeviceMotionEvent('', false, false, undefined, undefined, 
     undefined, undefined)"); | 85 evalAndLog("event = new DeviceMotionEvent('', {acceleration: null, accelerationI
     ncludingGravity: null, rotationRate: null, interval: null})"); | 
| 72 shouldBeTrue("event.acceleration == null"); | 86 shouldBeTrue("event.acceleration == null"); | 
| 73 shouldBeTrue("event.accelerationIncludingGravity == null"); | 87 shouldBeTrue("event.accelerationIncludingGravity == null"); | 
| 74 shouldBeTrue("event.rotationRate == null"); | 88 shouldBeTrue("event.rotationRate == null"); | 
| 75 shouldBeTrue("event.interval == null"); | 89 shouldBeTrue("event.interval == null"); | 
| 76 | 90 | 
| 77 evalAndLog("event.initDeviceMotionEvent('', false, false, '', '', '', '')"); | 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})"); | 
| 78 shouldBeTrue("event.acceleration == null"); | 92 shouldBeTrue("event.acceleration.x == null"); | 
| 79 shouldBeTrue("event.accelerationIncludingGravity == null"); | 93 shouldBeTrue("event.acceleration.y == null"); | 
| 80 shouldBeTrue("event.rotationRate == null"); | 94 shouldBeTrue("event.acceleration.z == null"); | 
| 81 shouldBeTrue("event.interval == 0"); | 95 shouldBeTrue("event.accelerationIncludingGravity.x == null"); | 
| 82 | 96 shouldBeTrue("event.accelerationIncludingGravity.y == null"); | 
| 83 evalAndLog("event.initDeviceMotionEvent('', false, false, null, null, null, null
     )"); | 97 shouldBeTrue("event.accelerationIncludingGravity.z == null"); | 
| 84 shouldBeTrue("event.acceleration == null"); | 98 shouldBeTrue("event.rotationRate.alpha == null"); | 
| 85 shouldBeTrue("event.accelerationIncludingGravity == null"); | 99 shouldBeTrue("event.rotationRate.beta == null"); | 
| 86 shouldBeTrue("event.rotationRate == null"); | 100 shouldBeTrue("event.rotationRate.gamma == null"); | 
| 87 shouldBeTrue("event.interval == null"); | 101 shouldBeTrue("event.interval == null"); | 
| 88 | 102 | 
| 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
     )"); | 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})"); | 
| 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"); | 104 shouldBeTrue("event.acceleration.x == null"); | 
| 97 shouldBeTrue("event.acceleration.y == null"); | 105 shouldBeTrue("event.acceleration.y == null"); | 
| 98 shouldBeTrue("event.acceleration.z == 1"); | 106 shouldBeTrue("event.acceleration.z == 1"); | 
| 99 shouldBeTrue("event.accelerationIncludingGravity.x == null"); | 107 shouldBeTrue("event.accelerationIncludingGravity.x == null"); | 
| 100 shouldBeTrue("event.accelerationIncludingGravity.y == null"); | 108 shouldBeTrue("event.accelerationIncludingGravity.y == null"); | 
| 101 shouldBeTrue("event.accelerationIncludingGravity.z == 2"); | 109 shouldBeTrue("event.accelerationIncludingGravity.z == 2"); | 
| 102 shouldBeTrue("event.rotationRate.alpha == null"); | 110 shouldBeTrue("event.rotationRate.alpha == null"); | 
| 103 shouldBeTrue("event.rotationRate.beta == null"); | 111 shouldBeTrue("event.rotationRate.beta == null"); | 
| 104 shouldBeTrue("event.rotationRate.gamma == 3"); | 112 shouldBeTrue("event.rotationRate.gamma == 3"); | 
| 105 shouldBeTrue("event.interval == null"); | 113 shouldBeTrue("event.interval == null"); | 
| 106 | 114 | 
| 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)"); | 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})"); | 
| 108 shouldBeTrue("event.acceleration == null"); | 116 shouldBeTrue("event.acceleration.x == null"); | 
| 109 shouldBeTrue("event.accelerationIncludingGravity == null"); | 117 shouldBeTrue("event.acceleration.y == null"); | 
| 110 shouldBeTrue("event.rotationRate == null"); | 118 shouldBeTrue("event.acceleration.z == null"); | 
|  | 119 shouldBeTrue("event.accelerationIncludingGravity.x == null"); | 
|  | 120 shouldBeTrue("event.accelerationIncludingGravity.y == null"); | 
|  | 121 shouldBeTrue("event.accelerationIncludingGravity.z == null"); | 
|  | 122 shouldBeTrue("event.rotationRate.alpha == null"); | 
|  | 123 shouldBeTrue("event.rotationRate.beta == null"); | 
|  | 124 shouldBeTrue("event.rotationRate.gamma == null"); | 
| 111 shouldBeTrue("event.interval == null"); | 125 shouldBeTrue("event.interval == null"); | 
| 112 | 126 | 
| 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)"); | 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})"); | 
| 114 shouldBeTrue("event.acceleration.x == null"); | 128 shouldBeTrue("event.acceleration.x == null"); | 
| 115 shouldBeTrue("event.acceleration.y == null"); | 129 shouldBeTrue("event.acceleration.y == null"); | 
| 116 shouldBeTrue("event.acceleration.z == 1"); | 130 shouldBeTrue("event.acceleration.z == 1"); | 
| 117 shouldBeTrue("event.accelerationIncludingGravity.x == null"); | 131 shouldBeTrue("event.accelerationIncludingGravity.x == null"); | 
| 118 shouldBeTrue("event.accelerationIncludingGravity.y == null"); | 132 shouldBeTrue("event.accelerationIncludingGravity.y == null"); | 
| 119 shouldBeTrue("event.accelerationIncludingGravity.z == 2"); | 133 shouldBeTrue("event.accelerationIncludingGravity.z == 2"); | 
| 120 shouldBeTrue("event.rotationRate.alpha == null"); | 134 shouldBeTrue("event.rotationRate.alpha == null"); | 
| 121 shouldBeTrue("event.rotationRate.beta == null"); | 135 shouldBeTrue("event.rotationRate.beta == null"); | 
| 122 shouldBeTrue("event.rotationRate.gamma == 3"); | 136 shouldBeTrue("event.rotationRate.gamma == 3"); | 
| 123 shouldBeTrue("event.interval == null"); | 137 shouldBeTrue("event.interval == null"); | 
| 124 </script> | 138 </script> | 
| 125 </body> | 139 </body> | 
| 126 </html> | 140 </html> | 
| OLD | NEW | 
|---|