Commit 0921e831 authored by reillyg's avatar reillyg Committed by Commit bot

Remove non-standard DeviceOrientation Event initializers.

This patch removes DeviceOrientationEvent.initDeviceOrientationEvent
and DeviceMotionEvent.initDeviceMotionEvent and rewrites the LayoutTests
to use the constructors for these objects instead.

https://www.w3.org/TR/2016/CR-orientation-event-20160818/

BUG=697598

Review-Url: https://codereview.chromium.org/2728963004
Cr-Commit-Position: refs/heads/master@{#457849}
parent 6f7dd6b2
......@@ -615,14 +615,12 @@ interface DeviceMotionEvent : Event
getter interval
getter rotationRate
method constructor
method initDeviceMotionEvent
interface DeviceOrientationEvent : Event
getter absolute
getter alpha
getter beta
getter gamma
method constructor
method initDeviceOrientationEvent
interface Document : Node
getter URL
getter activeElement
......
......@@ -8,7 +8,7 @@ PASS event.acceleration == null is true
PASS event.accelerationIncludingGravity == null is true
PASS event.rotationRate == null is true
PASS event.interval == null is true
event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9)
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})
PASS event.acceleration.x == 0 is true
PASS event.acceleration.y == 1 is true
PASS event.acceleration.z == 2 is true
......@@ -19,13 +19,13 @@ PASS event.rotationRate.alpha == 6 is true
PASS event.rotationRate.beta == 7 is true
PASS event.rotationRate.gamma == 8 is true
PASS event.interval == 9 is true
PASS event.initDeviceMotionEvent('', false, false, objectThrowingException, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9) threw exception Error: x getter exception.
PASS event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, objectThrowingException, {gamma: 8, beta: 7}, 9) threw exception Error: x getter exception.
PASS event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, z: 5}, objectThrowingException, 9) threw exception Error: alpha getter exception.
PASS event.initDeviceMotionEvent('', false, false, {x: objectThrowingException, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9) threw exception Error: valueOf threw exception.
PASS event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: objectThrowingException, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9) threw exception Error: valueOf threw exception.
PASS event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: objectThrowingException}, 9) threw exception Error: valueOf threw exception.
event.initDeviceMotionEvent('', false, false, {y: 1, x: 0}, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9)
PASS event = new DeviceMotionEvent('', {acceleration: objectThrowingException, accelerationIncludingGravity: {x: 3, z: 5}, rotationRate: {gamma: 8, beta: 7}, interval: 9}) threw exception Error: x getter exception.
PASS event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 2}, accelerationIncludingGravity: objectThrowingException, rotationRate: {gamma: 8, beta: 7}, interval: 9}) threw exception Error: x getter exception.
PASS event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, z: 5}, rotationRate: objectThrowingException, interval: 9}) threw exception Error: alpha getter exception.
PASS event = new DeviceMotionEvent('', {acceleration: {x: objectThrowingException, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, y: 4, z: 5}, rotationRate: {alpha: 6, beta: 7, gamma: 8}, interval: 9}) threw exception Error: valueOf threw exception.
PASS event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, y: objectThrowingException, z: 5}, rotationRate: {alpha: 6, beta: 7, gamma: 8}, interval: 9}) threw exception Error: valueOf threw exception.
PASS event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, y: 4, z: 5}, rotationRate: {alpha: 6, beta: 7, gamma: objectThrowingException}, interval: 9}) threw exception Error: valueOf threw exception.
event = new DeviceMotionEvent('', {acceleration: {y: 1, x: 0}, accelerationIncludingGravity: {x: 3, z: 5}, rotationRate: {gamma: 8, beta: 7}, interval: 9})
PASS event.acceleration.x == 0 is true
PASS event.acceleration.y == 1 is true
PASS event.acceleration.z == null is true
......@@ -36,37 +36,46 @@ PASS event.rotationRate.alpha == null is true
PASS event.rotationRate.beta == 7 is true
PASS event.rotationRate.gamma == 8 is true
PASS event.interval == 9 is true
event.initDeviceMotionEvent()
event = new DeviceMotionEvent('')
PASS event.acceleration == null is true
PASS event.accelerationIncludingGravity == null is true
PASS event.rotationRate == null is true
PASS event.interval == null is true
event.initDeviceMotionEvent('', false, false, [], [], [], [])
PASS event.acceleration == null is true
PASS event.accelerationIncludingGravity == null is true
PASS event.rotationRate == null is true
event = new DeviceMotionEvent('', {acceleration: [], accelerationIncludingGravity: [], rotationRate: [], interval: []})
PASS event.acceleration.x == null is true
PASS event.acceleration.y == null is true
PASS event.acceleration.z == null is true
PASS event.accelerationIncludingGravity.x == null is true
PASS event.accelerationIncludingGravity.y == null is true
PASS event.accelerationIncludingGravity.z == null is true
PASS event.rotationRate.alpha == null is true
PASS event.rotationRate.beta == null is true
PASS event.rotationRate.gamma == null is true
PASS event.interval == 0 is true
event.initDeviceMotionEvent('', false, false, undefined, undefined, undefined, undefined)
PASS event.acceleration == null is true
event = new DeviceMotionEvent('', {acceleration: [], accelerationIncludingGravity: undefined, rotationRate: undefined, interval: undefined})
PASS event.acceleration.x == null is true
PASS event.acceleration.y == null is true
PASS event.acceleration.z == null is true
PASS event.accelerationIncludingGravity == null is true
PASS event.rotationRate == null is true
PASS event.interval == null is true
event.initDeviceMotionEvent('', false, false, '', '', '', '')
PASS event.acceleration == null is true
PASS event.accelerationIncludingGravity == null is true
PASS event.rotationRate == null is true
PASS event.interval == 0 is true
event.initDeviceMotionEvent('', false, false, null, null, null, null)
event = new DeviceMotionEvent('', {acceleration: null, accelerationIncludingGravity: null, rotationRate: null, interval: null})
PASS event.acceleration == null is true
PASS event.accelerationIncludingGravity == null is true
PASS event.rotationRate == null is true
PASS event.interval == null is true
event.initDeviceMotionEvent('', false, false, {x: null, y: null, z: null}, {x: null, y: null, z: null}, {alpha: null, beta: null, gamma: null}, null)
PASS event.acceleration == null is true
PASS event.accelerationIncludingGravity == null is true
PASS event.rotationRate == null is true
event = new DeviceMotionEvent('', {acceleration: {x: null, y: null, z: null}, accelerationIncludingGravity: {x: null, y: null, z: null}, rotationRate: {alpha: null, beta: null, gamma: null}, interval: null})
PASS event.acceleration.x == null is true
PASS event.acceleration.y == null is true
PASS event.acceleration.z == null is true
PASS event.accelerationIncludingGravity.x == null is true
PASS event.accelerationIncludingGravity.y == null is true
PASS event.accelerationIncludingGravity.z == null is true
PASS event.rotationRate.alpha == null is true
PASS event.rotationRate.beta == null is true
PASS event.rotationRate.gamma == null is true
PASS event.interval == null is true
event.initDeviceMotionEvent('', false, false, {x: null, y: null, z: 1}, {x: null, y: null, z: 2}, {alpha: null, beta: null, gamma: 3}, null)
event = new DeviceMotionEvent('', {acceleration: {x: null, y: null, z: 1}, accelerationIncludingGravity: {x: null, y: null, z: 2}, rotationRate: {alpha: null, beta: null, gamma: 3}, interval: null})
PASS event.acceleration.x == null is true
PASS event.acceleration.y == null is true
PASS event.acceleration.z == 1 is true
......@@ -77,12 +86,18 @@ PASS event.rotationRate.alpha == null is true
PASS event.rotationRate.beta == null is true
PASS event.rotationRate.gamma == 3 is true
PASS event.interval == null is true
event.initDeviceMotionEvent('', false, false, {x: undefined, y: undefined, z: undefined}, {x: undefined, y: undefined, z: undefined}, {alpha: undefined, beta: undefined, gamma: undefined}, undefined)
PASS event.acceleration == null is true
PASS event.accelerationIncludingGravity == null is true
PASS event.rotationRate == null is true
event = new DeviceMotionEvent('', {acceleration: {x: undefined, y: undefined, z: undefined}, accelerationIncludingGravity: {x: undefined, y: undefined, z: undefined}, rotationRate: {alpha: undefined, beta: undefined, gamma: undefined}, interval: undefined})
PASS event.acceleration.x == null is true
PASS event.acceleration.y == null is true
PASS event.acceleration.z == null is true
PASS event.accelerationIncludingGravity.x == null is true
PASS event.accelerationIncludingGravity.y == null is true
PASS event.accelerationIncludingGravity.z == null is true
PASS event.rotationRate.alpha == null is true
PASS event.rotationRate.beta == null is true
PASS event.rotationRate.gamma == null is true
PASS event.interval == null is true
event.initDeviceMotionEvent('', false, false, {x: undefined, y: undefined, z: 1}, {x: undefined, y: undefined, z: 2}, {alpha: undefined, beta: undefined, gamma: 3}, undefined)
event = new DeviceMotionEvent('', {acceleration: {x: undefined, y: undefined, z: 1}, accelerationIncludingGravity: {x: undefined, y: undefined, z: 2}, rotationRate: {alpha: undefined, beta: undefined, gamma: 3}, interval: undefined})
PASS event.acceleration.x == null is true
PASS event.acceleration.y == null is true
PASS event.acceleration.z == 1 is true
......
......@@ -24,7 +24,7 @@ shouldBeTrue("event.accelerationIncludingGravity == null");
shouldBeTrue("event.rotationRate == null");
shouldBeTrue("event.interval == null");
evalAndLog("event.initDeviceMotionEvent('', false, false, {x: 0, y: 1, z: 2}, {x: 3, y: 4, z: 5}, {alpha: 6, beta: 7, gamma: 8}, 9)");
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})");
shouldBeTrue("event.acceleration.x == 0");
shouldBeTrue("event.acceleration.y == 1");
shouldBeTrue("event.acceleration.z == 2");
......@@ -36,15 +36,15 @@ 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 = new DeviceMotionEvent('', {acceleration: objectThrowingException, accelerationIncludingGravity: {x: 3, z: 5}, rotationRate: {gamma: 8, beta: 7}, interval: 9})", "Error: x getter exception");
testException("event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 2}, accelerationIncludingGravity: objectThrowingException, rotationRate: {gamma: 8, beta: 7}, interval: 9})", "Error: x getter exception");
testException("event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, z: 5}, rotationRate: objectThrowingException, interval: 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");
testException("event = new DeviceMotionEvent('', {acceleration: {x: objectThrowingException, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, y: 4, z: 5}, rotationRate: {alpha: 6, beta: 7, gamma: 8}, interval: 9})", "Error: valueOf threw exception");
testException("event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, y: objectThrowingException, z: 5}, rotationRate: {alpha: 6, beta: 7, gamma: 8}, interval: 9})", "Error: valueOf threw exception");
testException("event = new DeviceMotionEvent('', {acceleration: {x: 0, y: 1, z: 2}, accelerationIncludingGravity: {x: 3, y: 4, z: 5}, rotationRate: {alpha: 6, beta: 7, gamma: objectThrowingException}, interval: 9})", "Error: valueOf threw exception");
evalAndLog("event.initDeviceMotionEvent('', false, false, {y: 1, x: 0}, {x: 3, z: 5}, {gamma: 8, beta: 7}, 9)");
evalAndLog("event = new DeviceMotionEvent('', {acceleration: {y: 1, x: 0}, accelerationIncludingGravity: {x: 3, z: 5}, rotationRate: {gamma: 8, beta: 7}, interval: 9})");
shouldBeTrue("event.acceleration.x == 0");
shouldBeTrue("event.acceleration.y == 1");
shouldBeTrue("event.acceleration.z == null");
......@@ -56,43 +56,51 @@ shouldBeTrue("event.rotationRate.beta == 7");
shouldBeTrue("event.rotationRate.gamma == 8");
shouldBeTrue("event.interval == 9");
evalAndLog("event.initDeviceMotionEvent()");
evalAndLog("event = new DeviceMotionEvent('')");
shouldBeTrue("event.acceleration == null");
shouldBeTrue("event.accelerationIncludingGravity == null");
shouldBeTrue("event.rotationRate == null");
shouldBeTrue("event.interval == null");
evalAndLog("event.initDeviceMotionEvent('', false, false, [], [], [], [])");
shouldBeTrue("event.acceleration == null");
shouldBeTrue("event.accelerationIncludingGravity == null");
shouldBeTrue("event.rotationRate == null");
evalAndLog("event = new DeviceMotionEvent('', {acceleration: [], accelerationIncludingGravity: [], rotationRate: [], interval: []})");
shouldBeTrue("event.acceleration.x == null");
shouldBeTrue("event.acceleration.y == null");
shouldBeTrue("event.acceleration.z == null");
shouldBeTrue("event.accelerationIncludingGravity.x == null");
shouldBeTrue("event.accelerationIncludingGravity.y == null");
shouldBeTrue("event.accelerationIncludingGravity.z == null");
shouldBeTrue("event.rotationRate.alpha == null");
shouldBeTrue("event.rotationRate.beta == null");
shouldBeTrue("event.rotationRate.gamma == null");
shouldBeTrue("event.interval == 0");
evalAndLog("event.initDeviceMotionEvent('', false, false, undefined, undefined, undefined, undefined)");
shouldBeTrue("event.acceleration == null");
evalAndLog("event = new DeviceMotionEvent('', {acceleration: [], accelerationIncludingGravity: undefined, rotationRate: undefined, interval: undefined})");
shouldBeTrue("event.acceleration.x == null");
shouldBeTrue("event.acceleration.y == null");
shouldBeTrue("event.acceleration.z == null");
shouldBeTrue("event.accelerationIncludingGravity == null");
shouldBeTrue("event.rotationRate == null");
shouldBeTrue("event.interval == null");
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)");
evalAndLog("event = new DeviceMotionEvent('', {acceleration: null, accelerationIncludingGravity: null, rotationRate: null, interval: 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");
evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: null, y: null, z: null}, accelerationIncludingGravity: {x: null, y: null, z: null}, rotationRate: {alpha: null, beta: null, gamma: null}, interval: null})");
shouldBeTrue("event.acceleration.x == null");
shouldBeTrue("event.acceleration.y == null");
shouldBeTrue("event.acceleration.z == null");
shouldBeTrue("event.accelerationIncludingGravity.x == null");
shouldBeTrue("event.accelerationIncludingGravity.y == null");
shouldBeTrue("event.accelerationIncludingGravity.z == null");
shouldBeTrue("event.rotationRate.alpha == null");
shouldBeTrue("event.rotationRate.beta == null");
shouldBeTrue("event.rotationRate.gamma == 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)");
evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: null, y: null, z: 1}, accelerationIncludingGravity: {x: null, y: null, z: 2}, rotationRate: {alpha: null, beta: null, gamma: 3}, interval: null})");
shouldBeTrue("event.acceleration.x == null");
shouldBeTrue("event.acceleration.y == null");
shouldBeTrue("event.acceleration.z == 1");
......@@ -104,13 +112,19 @@ 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");
evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: undefined, y: undefined, z: undefined}, accelerationIncludingGravity: {x: undefined, y: undefined, z: undefined}, rotationRate: {alpha: undefined, beta: undefined, gamma: undefined}, interval: undefined})");
shouldBeTrue("event.acceleration.x == null");
shouldBeTrue("event.acceleration.y == null");
shouldBeTrue("event.acceleration.z == null");
shouldBeTrue("event.accelerationIncludingGravity.x == null");
shouldBeTrue("event.accelerationIncludingGravity.y == null");
shouldBeTrue("event.accelerationIncludingGravity.z == null");
shouldBeTrue("event.rotationRate.alpha == null");
shouldBeTrue("event.rotationRate.beta == null");
shouldBeTrue("event.rotationRate.gamma == 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)");
evalAndLog("event = new DeviceMotionEvent('', {acceleration: {x: undefined, y: undefined, z: 1}, accelerationIncludingGravity: {x: undefined, y: undefined, z: 2}, rotationRate: {alpha: undefined, beta: undefined, gamma: 3}, interval: undefined})");
shouldBeTrue("event.acceleration.x == null");
shouldBeTrue("event.acceleration.y == null");
shouldBeTrue("event.acceleration.z == 1");
......
......@@ -8,37 +8,37 @@ PASS event.alpha == null is true
PASS event.beta == null is true
PASS event.gamma == null is true
PASS event.absolute is false
event.initDeviceOrientationEvent('', false, false, 0, 1, 2, false)
event = new DeviceOrientationEvent('', {alpha: 0, beta: 1, gamma: 2, absolute: false})
PASS event.alpha == 0 is true
PASS event.beta == 1 is true
PASS event.gamma == 2 is true
PASS event.absolute is false
event.initDeviceOrientationEvent('', false, false, 0, 1, 2, true)
event = new DeviceOrientationEvent('', {alpha: 0, beta: 1, gamma: 2, absolute: true})
PASS event.alpha == 0 is true
PASS event.beta == 1 is true
PASS event.gamma == 2 is true
PASS event.absolute is true
event.initDeviceOrientationEvent()
event = new DeviceOrientationEvent('')
PASS event.alpha == null is true
PASS event.beta == null is true
PASS event.gamma == null is true
PASS event.absolute is false
event.initDeviceOrientationEvent('', false, false, [], [], [], [])
event = new DeviceOrientationEvent('', {alpha: [], beta: [], gamma: [], absolute: []})
PASS event.alpha == 0 is true
PASS event.beta == 0 is true
PASS event.gamma == 0 is true
PASS event.absolute is true
event.initDeviceOrientationEvent('', false, false, undefined, undefined, undefined, undefined)
event = new DeviceOrientationEvent('', {alpha: undefined, beta: undefined, gamma: undefined, absolute: undefined})
PASS event.alpha == null is true
PASS event.beta == null is true
PASS event.gamma == null is true
PASS event.absolute is false
event.initDeviceOrientationEvent('', false, false, '', '', '', '')
event = new DeviceOrientationEvent('', {alpha: '', beta: '', gamma: '', absolute: ''})
PASS event.alpha == 0 is true
PASS event.beta == 0 is true
PASS event.gamma == 0 is true
PASS event.absolute is false
event.initDeviceOrientationEvent('', false, false, null, null, null, null)
event = new DeviceOrientationEvent('', {alpha: null, beta: null, gamma: null, absolute: null})
PASS event.alpha == null is true
PASS event.beta == null is true
PASS event.gamma == null is true
......
......@@ -13,43 +13,43 @@ shouldBeTrue("event.beta == null");
shouldBeTrue("event.gamma == null");
shouldBeFalse("event.absolute");
evalAndLog("event.initDeviceOrientationEvent('', false, false, 0, 1, 2, false)");
evalAndLog("event = new DeviceOrientationEvent('', {alpha: 0, beta: 1, gamma: 2, absolute: false})");
shouldBeTrue("event.alpha == 0");
shouldBeTrue("event.beta == 1");
shouldBeTrue("event.gamma == 2");
shouldBeFalse("event.absolute");
evalAndLog("event.initDeviceOrientationEvent('', false, false, 0, 1, 2, true)");
evalAndLog("event = new DeviceOrientationEvent('', {alpha: 0, beta: 1, gamma: 2, absolute: true})");
shouldBeTrue("event.alpha == 0");
shouldBeTrue("event.beta == 1");
shouldBeTrue("event.gamma == 2");
shouldBeTrue("event.absolute");
evalAndLog("event.initDeviceOrientationEvent()");
evalAndLog("event = new DeviceOrientationEvent('')");
shouldBeTrue("event.alpha == null");
shouldBeTrue("event.beta == null");
shouldBeTrue("event.gamma == null");
shouldBeFalse("event.absolute");
evalAndLog("event.initDeviceOrientationEvent('', false, false, [], [], [], [])");
evalAndLog("event = new DeviceOrientationEvent('', {alpha: [], beta: [], gamma: [], absolute: []})");
shouldBeTrue("event.alpha == 0");
shouldBeTrue("event.beta == 0");
shouldBeTrue("event.gamma == 0");
shouldBeTrue("event.absolute");
evalAndLog("event.initDeviceOrientationEvent('', false, false, undefined, undefined, undefined, undefined)");
evalAndLog("event = new DeviceOrientationEvent('', {alpha: undefined, beta: undefined, gamma: undefined, absolute: undefined})");
shouldBeTrue("event.alpha == null");
shouldBeTrue("event.beta == null");
shouldBeTrue("event.gamma == null");
shouldBeFalse("event.absolute");
evalAndLog("event.initDeviceOrientationEvent('', false, false, '', '', '', '')");
evalAndLog("event = new DeviceOrientationEvent('', {alpha: '', beta: '', gamma: '', absolute: ''})");
shouldBeTrue("event.alpha == 0");
shouldBeTrue("event.beta == 0");
shouldBeTrue("event.gamma == 0");
shouldBeFalse("event.absolute");
evalAndLog("event.initDeviceOrientationEvent('', false, false, null, null, null, null)");
evalAndLog("event = new DeviceOrientationEvent('', {alpha: null, beta: null, gamma: null, absolute: null})");
shouldBeTrue("event.alpha == null");
shouldBeTrue("event.beta == null");
shouldBeTrue("event.gamma == null");
......
......@@ -817,7 +817,6 @@ interface DeviceMotionEvent : Event
getter interval
getter rotationRate
method constructor
method initDeviceMotionEvent
interface DeviceOrientationEvent : Event
attribute @@toStringTag
getter absolute
......@@ -825,7 +824,6 @@ interface DeviceOrientationEvent : Event
getter beta
getter gamma
method constructor
method initDeviceOrientationEvent
interface Document : Node
attribute @@toStringTag
attribute @@unscopables
......
......@@ -746,7 +746,6 @@ interface DeviceMotionEvent : Event
getter interval
getter rotationRate
method constructor
method initDeviceMotionEvent
interface DeviceOrientationEvent : Event
attribute @@toStringTag
getter absolute
......@@ -754,7 +753,6 @@ interface DeviceOrientationEvent : Event
getter beta
getter gamma
method constructor
method initDeviceOrientationEvent
interface Document : Node
attribute @@toStringTag
attribute @@unscopables
......
......@@ -1315,7 +1315,6 @@ interface DeviceMotionEvent : Event
getter interval
getter rotationRate
method constructor
method initDeviceMotionEvent
interface DeviceOrientationEvent : Event
attribute @@toStringTag
getter absolute
......@@ -1323,7 +1322,6 @@ interface DeviceOrientationEvent : Event
getter beta
getter gamma
method constructor
method initDeviceOrientationEvent
interface Document : Node
attribute @@toStringTag
attribute @@unscopables
......
/*
* Copyright (C) 2010 Apple Inc. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
* are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
* OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
#include "bindings/modules/v8/V8DeviceMotionEvent.h"
#include "bindings/core/v8/V8Binding.h"
#include "modules/device_orientation/DeviceMotionData.h"
#include "v8/include/v8.h"
namespace blink {
namespace {
DeviceMotionData::Acceleration* readAccelerationArgument(
v8::Local<v8::Value> value,
v8::Isolate* isolate) {
if (isUndefinedOrNull(value))
return nullptr;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Object> object;
if (!value->ToObject(context).ToLocal(&object))
return nullptr;
v8::Local<v8::Value> xValue;
if (!object->Get(context, v8AtomicString(isolate, "x")).ToLocal(&xValue))
return nullptr;
bool canProvideX = !isUndefinedOrNull(xValue);
double x;
if (!xValue->NumberValue(context).To(&x))
return nullptr;
v8::Local<v8::Value> yValue;
if (!object->Get(context, v8AtomicString(isolate, "y")).ToLocal(&yValue))
return nullptr;
bool canProvideY = !isUndefinedOrNull(yValue);
double y;
if (!yValue->NumberValue(context).To(&y))
return nullptr;
v8::Local<v8::Value> zValue;
if (!object->Get(context, v8AtomicString(isolate, "z")).ToLocal(&zValue))
return nullptr;
bool canProvideZ = !isUndefinedOrNull(zValue);
double z;
if (!zValue->NumberValue(context).To(&z))
return nullptr;
if (!canProvideX && !canProvideY && !canProvideZ)
return nullptr;
return DeviceMotionData::Acceleration::create(canProvideX, x, canProvideY, y,
canProvideZ, z);
}
DeviceMotionData::RotationRate* readRotationRateArgument(
v8::Local<v8::Value> value,
v8::Isolate* isolate) {
if (isUndefinedOrNull(value))
return nullptr;
v8::Local<v8::Context> context = isolate->GetCurrentContext();
v8::Local<v8::Object> object;
if (!value->ToObject(context).ToLocal(&object))
return nullptr;
v8::Local<v8::Value> alphaValue;
if (!object->Get(context, v8AtomicString(isolate, "alpha"))
.ToLocal(&alphaValue))
return nullptr;
bool canProvideAlpha = !isUndefinedOrNull(alphaValue);
double alpha;
if (!alphaValue->NumberValue(context).To(&alpha))
return nullptr;
v8::Local<v8::Value> betaValue;
if (!object->Get(context, v8AtomicString(isolate, "beta"))
.ToLocal(&betaValue))
return nullptr;
bool canProvideBeta = !isUndefinedOrNull(betaValue);
double beta;
if (!betaValue->NumberValue(context).To(&beta))
return nullptr;
v8::Local<v8::Value> gammaValue;
if (!object->Get(context, v8AtomicString(isolate, "gamma"))
.ToLocal(&gammaValue))
return nullptr;
bool canProvideGamma = !isUndefinedOrNull(gammaValue);
double gamma;
if (!gammaValue->NumberValue(context).To(&gamma))
return nullptr;
if (!canProvideAlpha && !canProvideBeta && !canProvideGamma)
return nullptr;
return DeviceMotionData::RotationRate::create(
canProvideAlpha, alpha, canProvideBeta, beta, canProvideGamma, gamma);
}
} // namespace
void V8DeviceMotionEvent::initDeviceMotionEventMethodCustom(
const v8::FunctionCallbackInfo<v8::Value>& info) {
// TODO(haraken): This custom binding should mimic auto-generated code more.
ExceptionState exceptionState(info.GetIsolate(),
ExceptionState::ExecutionContext,
"DeviceMotionEvent", "initDeviceMotionEvent");
DeviceMotionEvent* impl = V8DeviceMotionEvent::toImpl(info.Holder());
v8::Isolate* isolate = info.GetIsolate();
V8StringResource<> type(info[0]);
if (!type.prepare())
return;
v8::Local<v8::Context> context = info.GetIsolate()->GetCurrentContext();
bool bubbles = false;
if (!info[1]->BooleanValue(context).To(&bubbles))
return;
bool cancelable = false;
if (!info[2]->BooleanValue(context).To(&cancelable))
return;
DeviceMotionData::Acceleration* acceleration =
readAccelerationArgument(info[3], isolate);
DeviceMotionData::Acceleration* accelerationIncludingGravity =
readAccelerationArgument(info[4], isolate);
DeviceMotionData::RotationRate* rotationRate =
readRotationRateArgument(info[5], isolate);
bool intervalProvided = !isUndefinedOrNull(info[6]);
double interval = 0;
if (intervalProvided) {
interval = toRestrictedDouble(isolate, info[6], exceptionState);
if (exceptionState.hadException())
return;
}
DeviceMotionData* deviceMotionData =
DeviceMotionData::create(acceleration, accelerationIncludingGravity,
rotationRate, intervalProvided, interval);
impl->initDeviceMotionEvent(type, bubbles, cancelable, deviceMotionData);
}
} // namespace blink
......@@ -6,7 +6,6 @@
bindings_modules_v8_custom_files =
get_path_info([
"V8CustomSQLStatementErrorCallback.cpp",
"V8DeviceMotionEventCustom.cpp",
"V8ExtendableMessageEventCustom.cpp",
"V8IDBObserverCustom.cpp",
],
......
......@@ -47,22 +47,6 @@ DeviceMotionEvent::DeviceMotionEvent(const AtomicString& eventType,
: Event(eventType, false, false), // Can't bubble, not cancelable
m_deviceMotionData(deviceMotionData) {}
void DeviceMotionEvent::initDeviceMotionEvent(
const AtomicString& type,
bool bubbles,
bool cancelable,
DeviceMotionData* deviceMotionData) {
if (isBeingDispatched())
return;
initEvent(type, bubbles, cancelable);
m_deviceMotionData = deviceMotionData;
m_acceleration.clear();
m_accelerationIncludingGravity.clear();
m_rotationRate.clear();
}
DeviceAcceleration* DeviceMotionEvent::acceleration() {
if (!m_deviceMotionData->getAcceleration())
return nullptr;
......
......@@ -51,11 +51,6 @@ class DeviceMotionEvent final : public Event {
return new DeviceMotionEvent(eventType, deviceMotionData);
}
void initDeviceMotionEvent(const AtomicString& type,
bool bubbles,
bool cancelable,
DeviceMotionData*);
DeviceMotionData* getDeviceMotionData() const {
return m_deviceMotionData.get();
}
......
......@@ -31,14 +31,4 @@ interface DeviceMotionEvent : Event {
readonly attribute DeviceAcceleration? accelerationIncludingGravity;
readonly attribute DeviceRotationRate? rotationRate;
readonly attribute double? interval;
// TODO(foolip): The init*Event() methods are not in the spec:
// https://github.com/w3c/deviceorientation/issues/18
[Custom, Measure] void initDeviceMotionEvent([Default=Undefined] optional DOMString type,
[Default=Undefined] optional boolean bubbles,
[Default=Undefined] optional boolean cancelable,
[Default=Undefined] optional DeviceAcceleration acceleration,
[Default=Undefined] optional DeviceAcceleration accelerationIncludingGravity,
[Default=Undefined] optional DeviceRotationRate rotationRate,
[Default=Undefined] optional double interval);
};
......@@ -47,21 +47,6 @@ DeviceOrientationEvent::DeviceOrientationEvent(
: Event(eventType, false, false), // Can't bubble, not cancelable
m_orientation(orientation) {}
void DeviceOrientationEvent::initDeviceOrientationEvent(
const AtomicString& type,
bool bubbles,
bool cancelable,
const Nullable<double>& alpha,
const Nullable<double>& beta,
const Nullable<double>& gamma,
bool absolute) {
if (isBeingDispatched())
return;
initEvent(type, bubbles, cancelable);
m_orientation = DeviceOrientationData::create(alpha, beta, gamma, absolute);
}
double DeviceOrientationEvent::alpha(bool& isNull) const {
if (m_orientation->canProvideAlpha())
return m_orientation->alpha();
......
......@@ -51,14 +51,6 @@ class DeviceOrientationEvent final : public Event {
return new DeviceOrientationEvent(eventType, orientation);
}
void initDeviceOrientationEvent(const AtomicString& type,
bool bubbles,
bool cancelable,
const Nullable<double>& alpha,
const Nullable<double>& beta,
const Nullable<double>& gamma,
bool absolute);
DeviceOrientationData* orientation() const { return m_orientation.get(); }
double alpha(bool& isNull) const;
......
......@@ -31,14 +31,4 @@ interface DeviceOrientationEvent : Event {
readonly attribute double? beta;
readonly attribute double? gamma;
readonly attribute boolean absolute;
// TODO(foolip): The init*Event() methods are not in the spec:
// https://github.com/w3c/deviceorientation/issues/18
[Measure] void initDeviceOrientationEvent([Default=Undefined] optional DOMString type,
[Default=Undefined] optional boolean bubbles,
[Default=Undefined] optional boolean cancelable,
[Default=Undefined] optional double? alpha,
[Default=Undefined] optional double? beta,
[Default=Undefined] optional double? gamma,
[Default=Undefined] optional boolean absolute);
};
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment