summaryrefslogtreecommitdiffstats
path: root/LayoutTests/fast/dom/DeviceMotion/script-tests/optional-event-properties.js
diff options
context:
space:
mode:
authorKristian Monsen <kristianm@google.com>2010-09-30 15:42:16 +0100
committerSteve Block <steveblock@google.com>2010-10-07 10:59:29 +0100
commitbec39347bb3bb5bf1187ccaf471d26247f28b585 (patch)
tree56bdc4c2978fbfd3d79d0d36d5d6c640ecc09cc8 /LayoutTests/fast/dom/DeviceMotion/script-tests/optional-event-properties.js
parent90b7966e7815b262cd19ac25f03aaad9b21fdc06 (diff)
downloadexternal_webkit-bec39347bb3bb5bf1187ccaf471d26247f28b585.zip
external_webkit-bec39347bb3bb5bf1187ccaf471d26247f28b585.tar.gz
external_webkit-bec39347bb3bb5bf1187ccaf471d26247f28b585.tar.bz2
Merge WebKit at r68651 : Initial merge by git.
Change-Id: I3d6bff59f17eedd6722723354f386fec9be8ad12
Diffstat (limited to 'LayoutTests/fast/dom/DeviceMotion/script-tests/optional-event-properties.js')
-rw-r--r--LayoutTests/fast/dom/DeviceMotion/script-tests/optional-event-properties.js148
1 files changed, 100 insertions, 48 deletions
diff --git a/LayoutTests/fast/dom/DeviceMotion/script-tests/optional-event-properties.js b/LayoutTests/fast/dom/DeviceMotion/script-tests/optional-event-properties.js
index ab9b53b..5f5c88a 100644
--- a/LayoutTests/fast/dom/DeviceMotion/script-tests/optional-event-properties.js
+++ b/LayoutTests/fast/dom/DeviceMotion/script-tests/optional-event-properties.js
@@ -1,68 +1,120 @@
description("Tests the optional properties of DeviceMotionEvent. Each property should be null if not set, or set to null or undefined.");
+function ObjectThrowingException() {};
+ObjectThrowingException.prototype.valueOf = function() { throw new Error('valueOf threw exception'); }
+ObjectThrowingException.prototype.__defineGetter__("x", function() { throw new Error('x getter exception'); });
+ObjectThrowingException.prototype.__defineGetter__("alpha", function() { throw new Error('alpha getter exception'); });
+var objectThrowingException = new ObjectThrowingException();
+
+function testException(expression, expectedException)
+{
+ shouldThrow(expression, '(function() { return "' + expectedException + '"; })();');
+}
+
var event;
evalAndLog("event = document.createEvent('DeviceMotionEvent')");
-shouldBeTrue("event.xAcceleration == null");
-shouldBeTrue("event.yAcceleration == null");
-shouldBeTrue("event.zAcceleration == null");
-shouldBeTrue("event.xRotationRate == null");
-shouldBeTrue("event.yRotationRate == null");
-shouldBeTrue("event.zRotationRate == null");
+shouldBeTrue("event.acceleration == null");
+shouldBeTrue("event.accelerationIncludingGravity == null");
+shouldBeTrue("event.rotationRate == null");
shouldBeTrue("event.interval == null");
-evalAndLog("event.initDeviceMotionEvent('', false, false, 0, 1, 2, 3, 4, 5, 6)");
-shouldBeTrue("event.xAcceleration == 0");
-shouldBeTrue("event.yAcceleration == 1");
-shouldBeTrue("event.zAcceleration == 2");
-shouldBeTrue("event.xRotationRate == 3");
-shouldBeTrue("event.yRotationRate == 4");
-shouldBeTrue("event.zRotationRate == 5");
-shouldBeTrue("event.interval == 6");
+evalAndLog("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9)");
+shouldBeTrue("event.acceleration.x == 0");
+shouldBeTrue("event.acceleration.y == 1");
+shouldBeTrue("event.acceleration.z == 2");
+shouldBeTrue("event.accelerationIncludingGravity.x == 3");
+shouldBeTrue("event.accelerationIncludingGravity.y == 4");
+shouldBeTrue("event.accelerationIncludingGravity.z == 5");
+shouldBeTrue("event.rotationRate.alpha == 6");
+shouldBeTrue("event.rotationRate.beta == 7");
+shouldBeTrue("event.rotationRate.gamma == 8");
+shouldBeTrue("event.interval == 9");
+
+testException("event.initDeviceMotionEvent('', false, false, objectThrowingException, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9)", "Error: x getter exception");
+testException("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, objectThrowingException, {gamma: 8, beta: 7}, 9)", "Error: x getter exception");
+testException("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, z: 5}, objectThrowingException, 9)", "Error: alpha getter exception");
+
+testException("event.initDeviceMotionEvent('', false, false, {x: objectThrowingException, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9)", "Error: valueOf threw exception");
+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");
+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");
+
+evalAndLog("event.initDeviceMotionEvent('', false, false, {y: 1, x: 0}, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9)");
+shouldBeTrue("event.acceleration.x == 0");
+shouldBeTrue("event.acceleration.y == 1");
+shouldBeTrue("event.acceleration.z == null");
+shouldBeTrue("event.accelerationIncludingGravity.x == 3");
+shouldBeTrue("event.accelerationIncludingGravity.y == null");
+shouldBeTrue("event.accelerationIncludingGravity.z == 5");
+shouldBeTrue("event.rotationRate.alpha == null");
+shouldBeTrue("event.rotationRate.beta == 7");
+shouldBeTrue("event.rotationRate.gamma == 8");
+shouldBeTrue("event.interval == 9");
evalAndLog("event.initDeviceMotionEvent()");
-shouldBeTrue("event.xAcceleration == null");
-shouldBeTrue("event.yAcceleration == null");
-shouldBeTrue("event.zAcceleration == null");
-shouldBeTrue("event.xRotationRate == null");
-shouldBeTrue("event.yRotationRate == null");
-shouldBeTrue("event.zRotationRate == null");
+shouldBeTrue("event.acceleration == null");
+shouldBeTrue("event.accelerationIncludingGravity == null");
+shouldBeTrue("event.rotationRate == null");
shouldBeTrue("event.interval == null");
-evalAndLog("event.initDeviceMotionEvent('', false, false, [], [], [], [], [], [], [])");
-shouldBeTrue("event.xAcceleration == 0");
-shouldBeTrue("event.yAcceleration == 0");
-shouldBeTrue("event.zAcceleration == 0");
-shouldBeTrue("event.xRotationRate == 0");
-shouldBeTrue("event.yRotationRate == 0");
-shouldBeTrue("event.zRotationRate == 0");
+evalAndLog("event.initDeviceMotionEvent('', false, false, [], [], [], [])");
+shouldBeTrue("event.acceleration == null");
+shouldBeTrue("event.accelerationIncludingGravity == null");
+shouldBeTrue("event.rotationRate == null");
shouldBeTrue("event.interval == 0");
-evalAndLog("event.initDeviceMotionEvent('', false, false, undefined, undefined, undefined, undefined, undefined, undefined, undefined)");
-shouldBeTrue("event.xAcceleration == null");
-shouldBeTrue("event.yAcceleration == null");
-shouldBeTrue("event.zAcceleration == null");
-shouldBeTrue("event.xRotationRate == null");
-shouldBeTrue("event.yRotationRate == null");
-shouldBeTrue("event.zRotationRate == null");
+evalAndLog("event.initDeviceMotionEvent('', false, false, undefined, undefined, undefined, undefined)");
+shouldBeTrue("event.acceleration == null");
+shouldBeTrue("event.accelerationIncludingGravity == null");
+shouldBeTrue("event.rotationRate == null");
shouldBeTrue("event.interval == null");
-evalAndLog("event.initDeviceMotionEvent('', false, false, '', '', '', '', '', '', '')");
-shouldBeTrue("event.xAcceleration == 0");
-shouldBeTrue("event.yAcceleration == 0");
-shouldBeTrue("event.zAcceleration == 0");
-shouldBeTrue("event.xRotationRate == 0");
-shouldBeTrue("event.yRotationRate == 0");
-shouldBeTrue("event.zRotationRate == 0");
+evalAndLog("event.initDeviceMotionEvent('', false, false, '', '', '', '')");
+shouldBeTrue("event.acceleration == null");
+shouldBeTrue("event.accelerationIncludingGravity == null");
+shouldBeTrue("event.rotationRate == null");
shouldBeTrue("event.interval == 0");
-evalAndLog("event.initDeviceMotionEvent('', false, false, null, null, null, null, null, null, null)");
-shouldBeTrue("event.xAcceleration == null");
-shouldBeTrue("event.yAcceleration == null");
-shouldBeTrue("event.zAcceleration == null");
-shouldBeTrue("event.xRotationRate == null");
-shouldBeTrue("event.yRotationRate == null");
-shouldBeTrue("event.zRotationRate == null");
+evalAndLog("event.initDeviceMotionEvent('', false, false, null, null, null, null)");
+shouldBeTrue("event.acceleration == null");
+shouldBeTrue("event.accelerationIncludingGravity == null");
+shouldBeTrue("event.rotationRate == null");
+shouldBeTrue("event.interval == null");
+
+evalAndLog("event.initDeviceMotionEvent('', false, false, {x: null, y: null, z: null}, {x: null, y: null, z: null}, {alpha: null, beta: null, gamma: null}, null)");
+shouldBeTrue("event.acceleration == null");
+shouldBeTrue("event.accelerationIncludingGravity == null");
+shouldBeTrue("event.rotationRate == null");
+shouldBeTrue("event.interval == null");
+
+evalAndLog("event.initDeviceMotionEvent('', false, false, {x: null, y: null, z: 1}, {x: null, y: null, z: 2}, {alpha: null, beta: null, gamma: 3}, null)");
+shouldBeTrue("event.acceleration.x == null");
+shouldBeTrue("event.acceleration.y == null");
+shouldBeTrue("event.acceleration.z == 1");
+shouldBeTrue("event.accelerationIncludingGravity.x == null");
+shouldBeTrue("event.accelerationIncludingGravity.y == null");
+shouldBeTrue("event.accelerationIncludingGravity.z == 2");
+shouldBeTrue("event.rotationRate.alpha == null");
+shouldBeTrue("event.rotationRate.beta == null");
+shouldBeTrue("event.rotationRate.gamma == 3");
+shouldBeTrue("event.interval == null");
+
+evalAndLog("event.initDeviceMotionEvent('', false, false, {x: undefined, y: undefined, z: undefined}, {x: undefined, y: undefined, z: undefined}, {alpha: undefined, beta: undefined, gamma: undefined}, undefined)");
+shouldBeTrue("event.acceleration == null");
+shouldBeTrue("event.accelerationIncludingGravity == null");
+shouldBeTrue("event.rotationRate == null");
+shouldBeTrue("event.interval == null");
+
+evalAndLog("event.initDeviceMotionEvent('', false, false, {x: undefined, y: undefined, z: 1}, {x: undefined, y: undefined, z: 2}, {alpha: undefined, beta: undefined, gamma: 3}, undefined)");
+shouldBeTrue("event.acceleration.x == null");
+shouldBeTrue("event.acceleration.y == null");
+shouldBeTrue("event.acceleration.z == 1");
+shouldBeTrue("event.accelerationIncludingGravity.x == null");
+shouldBeTrue("event.accelerationIncludingGravity.y == null");
+shouldBeTrue("event.accelerationIncludingGravity.z == 2");
+shouldBeTrue("event.rotationRate.alpha == null");
+shouldBeTrue("event.rotationRate.beta == null");
+shouldBeTrue("event.rotationRate.gamma == 3");
shouldBeTrue("event.interval == null");
window.successfullyParsed = true;