Source/WebKit/chromium/ChangeLog

 12012-06-20 Amy Ousterhout <aousterh@chromium.org>
 2
 3 [Chromium] Implements DeviceMotion
 4 https://bugs.webkit.org/show_bug.cgi?id=89197
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Implements DeviceMotion in a very similar manner to DeviceOrientation, since they are part of the same spec and work very similarly.
 9
 10 * WebKit.gyp:
 11 * public/WebDeviceMotionClient.h: Added.
 12 (WebKit):
 13 (WebDeviceMotionClient):
 14 (WebKit::WebDeviceMotionClient::~WebDeviceMotionClient):
 15 * public/WebDeviceMotionClientMock.h: Added.
 16 (WebKit):
 17 (WebDeviceMotionClientMock):
 18 (WebKit::WebDeviceMotionClientMock::~WebDeviceMotionClientMock):
 19 (WebKit::WebDeviceMotionClientMock::WebDeviceMotionClientMock):
 20 * public/WebDeviceMotionController.h: Added.
 21 (WebKit):
 22 (WebDeviceMotionController):
 23 (WebKit::WebDeviceMotionController::WebDeviceMotionController):
 24 * public/WebDeviceMotionData.h: Added.
 25 (WebKit):
 26 (WebDeviceMotionData):
 27 (WebKit::WebDeviceMotionData::WebDeviceMotionData):
 28 (WebKit::WebDeviceMotionData::nullMotion):
 29 (WebKit::WebDeviceMotionData::setNull):
 30 (WebKit::WebDeviceMotionData::isNull):
 31 (WebKit::WebDeviceMotionData::setAccelerationX):
 32 (WebKit::WebDeviceMotionData::canProvideAccelerationX):
 33 (WebKit::WebDeviceMotionData::accelerationX):
 34 (WebKit::WebDeviceMotionData::setAccelerationY):
 35 (WebKit::WebDeviceMotionData::canProvideAccelerationY):
 36 (WebKit::WebDeviceMotionData::accelerationY):
 37 (WebKit::WebDeviceMotionData::setAccelerationZ):
 38 (WebKit::WebDeviceMotionData::canProvideAccelerationZ):
 39 (WebKit::WebDeviceMotionData::accelerationZ):
 40 (WebKit::WebDeviceMotionData::setAccelerationIncludingGravityX):
 41 (WebKit::WebDeviceMotionData::canProvideAccelerationIncludingGravityX):
 42 (WebKit::WebDeviceMotionData::accelerationIncludingGravityX):
 43 (WebKit::WebDeviceMotionData::setAccelerationIncludingGravityY):
 44 (WebKit::WebDeviceMotionData::canProvideAccelerationIncludingGravityY):
 45 (WebKit::WebDeviceMotionData::accelerationIncludingGravityY):
 46 (WebKit::WebDeviceMotionData::setAccelerationIncludingGravityZ):
 47 (WebKit::WebDeviceMotionData::canProvideAccelerationIncludingGravityZ):
 48 (WebKit::WebDeviceMotionData::accelerationIncludingGravityZ):
 49 (WebKit::WebDeviceMotionData::setRotationRateAlpha):
 50 (WebKit::WebDeviceMotionData::canProvideRotationRateAlpha):
 51 (WebKit::WebDeviceMotionData::rotationRateAlpha):
 52 (WebKit::WebDeviceMotionData::setRotationRateBeta):
 53 (WebKit::WebDeviceMotionData::canProvideRotationRateBeta):
 54 (WebKit::WebDeviceMotionData::rotationRateBeta):
 55 (WebKit::WebDeviceMotionData::setRotationRateGamma):
 56 (WebKit::WebDeviceMotionData::canProvideRotationRateGamma):
 57 (WebKit::WebDeviceMotionData::rotationRateGamma):
 58 (WebKit::WebDeviceMotionData::setInterval):
 59 (WebKit::WebDeviceMotionData::canProvideInterval):
 60 (WebKit::WebDeviceMotionData::interval):
 61 * public/WebViewClient.h:
 62 (WebKit):
 63 (WebViewClient):
 64 (WebKit::WebViewClient::deviceMotionClient):
 65 * src/DeviceMotionClientProxy.cpp: Added.
 66 (WebCore):
 67 (WebKit):
 68 (WebKit::DeviceMotionClientProxy::setController):
 69 (WebKit::DeviceMotionClientProxy::startUpdating):
 70 (WebKit::DeviceMotionClientProxy::stopUpdating):
 71 (WebKit::DeviceMotionClientProxy::lastMotion):
 72 (WebKit::DeviceMotionClientProxy::deviceMotionControllerDestroyed):
 73 * src/DeviceMotionClientProxy.h: Added.
 74 (WebCore):
 75 (WebKit):
 76 (DeviceMotionClientProxy):
 77 (WebKit::DeviceMotionClientProxy::DeviceMotionClientProxy):
 78 * src/WebDeviceMotionClientMock.cpp: Added.
 79 (WebKit):
 80 (WebKit::WebDeviceMotionClientMock::create):
 81 (WebKit::WebDeviceMotionClientMock::setController):
 82 (WebKit::WebDeviceMotionClientMock::startUpdating):
 83 (WebKit::WebDeviceMotionClientMock::stopUpdating):
 84 (WebKit::WebDeviceMotionClientMock::lastMotion):
 85 (WebKit::WebDeviceMotionClientMock::setMotion):
 86 (WebKit::WebDeviceMotionClientMock::initialize):
 87 (WebKit::WebDeviceMotionClientMock::reset):
 88 * src/WebDeviceMotionController.cpp: Added.
 89 (WebKit):
 90 (WebKit::WebDeviceMotionController::didChangeDeviceMotion):
 91 (WebKit::WebDeviceMotionController::controller):
 92 * src/WebDeviceMotionData.cpp: Added.
 93 (WebKit):
 94 (WebKit::WebDeviceMotionData::WebDeviceMotionData):
 95 (WebKit::WebDeviceMotionData::operator=):
 96 (WebKit::WebDeviceMotionData::operator PassRefPtr<WebCore::DeviceMotionData>):
 97 * src/WebViewImpl.cpp:
 98 (WebKit::WebViewImpl::WebViewImpl):
 99 * src/WebViewImpl.h:
 100 (WebKit):
 101
11022012-06-20 Hans Wennborg <hans@chromium.org>
2103
3104 Speech JavaScript API: add SpeechRecognition.maxAlternatives attribute

Source/WebKit/chromium/WebKit.gyp

133133 'public/WebDevToolsAgentClient.h',
134134 'public/WebDevToolsFrontend.h',
135135 'public/WebDevToolsFrontendClient.h',
 136 'public/WebDeviceMotionClient.h',
 137 'public/WebDeviceMotionClientMock.h',
 138 'public/WebDeviceMotionController.h',
 139 'public/WebDeviceMotionData.h',
136140 'public/WebDeviceOrientation.h',
137141 'public/WebDeviceOrientationClient.h',
138142 'public/WebDeviceOrientationClientMock.h',

379383 'src/DatabaseObserver.cpp',
380384 'src/DeliveredIntentClientImpl.cpp',
381385 'src/DeliveredIntentClientImpl.h',
 386 'src/DeviceMotionClientProxy.cpp',
 387 'src/DeviceMotionClientProxy.h',
382388 'src/DeviceOrientationClientProxy.cpp',
383389 'src/DeviceOrientationClientProxy.h',
384390 'src/DOMUtilitiesPrivate.cpp',

511517 'src/WebDevToolsAgentImpl.h',
512518 'src/WebDevToolsFrontendImpl.cpp',
513519 'src/WebDevToolsFrontendImpl.h',
 520 'src/WebDeviceMotionClientMock.cpp',
 521 'src/WebDeviceMotionController.cpp',
 522 'src/WebDeviceMotionData.cpp',
514523 'src/WebDeviceOrientation.cpp',
515524 'src/WebDeviceOrientationClientMock.cpp',
516525 'src/WebDeviceOrientationController.cpp',

Source/WebKit/chromium/public/WebDeviceMotionClient.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebDeviceMotionClient_h
 27#define WebDeviceMotionClient_h
 28
 29#include "WebDeviceMotionData.h"
 30#include "platform/WebCommon.h"
 31
 32namespace WebKit {
 33
 34class WebDeviceMotionController;
 35
 36class WebDeviceMotionClient {
 37public:
 38 virtual ~WebDeviceMotionClient() { }
 39
 40 virtual void setController(WebDeviceMotionController*) { WEBKIT_ASSERT_NOT_REACHED(); }
 41 virtual void startUpdating() { WEBKIT_ASSERT_NOT_REACHED(); }
 42 virtual void stopUpdating() { WEBKIT_ASSERT_NOT_REACHED(); }
 43
 44 virtual WebDeviceMotionData lastMotion() const
 45 {
 46 WEBKIT_ASSERT_NOT_REACHED();
 47 return WebDeviceMotionData::nullMotion();
 48 }
 49};
 50
 51} // namespace WebKit
 52
 53#endif // WebDeviceMotionClient_h

Source/WebKit/chromium/public/WebDeviceMotionClientMock.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebDeviceMotionClientMock_h
 27#define WebDeviceMotionClientMock_h
 28
 29#include "WebDeviceMotionClient.h"
 30#include "platform/WebCommon.h"
 31#include "platform/WebPrivateOwnPtr.h"
 32
 33namespace WebCore { class DeviceMotionClientMock; }
 34
 35namespace WebKit {
 36
 37class WebDeviceMotionClientMock : public WebDeviceMotionClient {
 38public:
 39 WEBKIT_EXPORT static WebDeviceMotionClientMock* create();
 40 ~WebDeviceMotionClientMock() { reset(); }
 41
 42 virtual void setController(WebDeviceMotionController*) OVERRIDE;
 43 virtual void startUpdating() OVERRIDE;
 44 virtual void stopUpdating() OVERRIDE;
 45 virtual WebDeviceMotionData lastMotion() const OVERRIDE;
 46
 47 WEBKIT_EXPORT void setMotion(WebDeviceMotionData&);
 48
 49private:
 50 WebDeviceMotionClientMock() { initialize(); }
 51 WEBKIT_EXPORT void initialize();
 52 WEBKIT_EXPORT void reset();
 53
 54 WebPrivateOwnPtr<WebCore::DeviceMotionClientMock> m_clientMock;
 55};
 56
 57} // namespace WebKit
 58
 59#endif // WebDeviceMotionClientMock_h

Source/WebKit/chromium/public/WebDeviceMotionController.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebDeviceMotionController_h
 27#define WebDeviceMotionController_h
 28
 29#include "platform/WebCommon.h"
 30
 31namespace WebCore { class DeviceMotionController; }
 32
 33namespace WebKit {
 34
 35class WebDeviceMotionData;
 36
 37class WebDeviceMotionController {
 38public:
 39 WebDeviceMotionController(WebCore::DeviceMotionController* c)
 40 : m_controller(c)
 41 {
 42 }
 43
 44 WEBKIT_EXPORT void didChangeDeviceMotion(const WebDeviceMotionData&);
 45
 46#if WEBKIT_IMPLEMENTATION
 47 WebCore::DeviceMotionController* controller() const;
 48#endif
 49
 50private:
 51 WebCore::DeviceMotionController* m_controller;
 52};
 53
 54} // namespace WebKit
 55
 56#endif // WebDeviceMotionController_h

Source/WebKit/chromium/public/WebDeviceMotionData.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef WebDeviceMotionData_h
 27#define WebDeviceMotionData_h
 28
 29#if WEBKIT_IMPLEMENTATION
 30namespace WTF { template <typename T> class PassRefPtr; }
 31namespace WebCore { class DeviceMotionData; }
 32#endif
 33
 34namespace WebKit {
 35
 36class WebDeviceMotionData {
 37public:
 38 WebDeviceMotionData()
 39 : m_isNull(true)
 40 , m_canProvideAccelerationX(false)
 41 , m_accelerationX(0)
 42 , m_canProvideAccelerationY(false)
 43 , m_accelerationY(0)
 44 , m_canProvideAccelerationZ(false)
 45 , m_accelerationZ(0)
 46 , m_canProvideAccelerationIncludingGravityX(false)
 47 , m_accelerationIncludingGravityX(0)
 48 , m_canProvideAccelerationIncludingGravityY(false)
 49 , m_accelerationIncludingGravityY(0)
 50 , m_canProvideAccelerationIncludingGravityZ(false)
 51 , m_accelerationIncludingGravityZ(0)
 52 , m_canProvideRotationRateAlpha(false)
 53 , m_rotationRateAlpha(0)
 54 , m_canProvideRotationRateBeta(false)
 55 , m_rotationRateBeta(0)
 56 , m_canProvideRotationRateGamma(false)
 57 , m_rotationRateGamma(0)
 58 , m_canProvideInterval(false)
 59 , m_interval(0)
 60 {
 61 }
 62
 63 static WebDeviceMotionData nullMotion() { return WebDeviceMotionData(); }
 64
 65 void setNull(bool isNull) { m_isNull = isNull; }
 66 bool isNull() const { return m_isNull; }
 67
 68 void setAccelerationX(double accelerationX)
 69 {
 70 m_canProvideAccelerationX = true;
 71 m_accelerationX = accelerationX;
 72 }
 73 bool canProvideAccelerationX() const { return m_canProvideAccelerationX; }
 74 double accelerationX() const { return m_accelerationX; }
 75
 76 void setAccelerationY(double accelerationY)
 77 {
 78 m_canProvideAccelerationY = true;
 79 m_accelerationY = accelerationY;
 80 }
 81 bool canProvideAccelerationY() const { return m_canProvideAccelerationY; }
 82 double accelerationY() const { return m_accelerationY; }
 83
 84 void setAccelerationZ(double accelerationZ)
 85 {
 86 m_canProvideAccelerationZ = true;
 87 m_accelerationZ = accelerationZ;
 88 }
 89 bool canProvideAccelerationZ() const { return m_canProvideAccelerationZ; }
 90 double accelerationZ() const { return m_accelerationZ; }
 91
 92 void setAccelerationIncludingGravityX(double accelerationIncludingGravityX)
 93 {
 94 m_canProvideAccelerationIncludingGravityX = true;
 95 m_accelerationIncludingGravityX = accelerationIncludingGravityX;
 96 }
 97 bool canProvideAccelerationIncludingGravityX() const { return m_canProvideAccelerationIncludingGravityX; }
 98 double accelerationIncludingGravityX() const { return m_accelerationIncludingGravityX; }
 99
 100 void setAccelerationIncludingGravityY(double accelerationIncludingGravityY)
 101 {
 102 m_canProvideAccelerationIncludingGravityY = true;
 103 m_accelerationIncludingGravityY = accelerationIncludingGravityY;
 104 }
 105 bool canProvideAccelerationIncludingGravityY() const { return m_canProvideAccelerationIncludingGravityY; }
 106 double accelerationIncludingGravityY() const { return m_accelerationIncludingGravityY; }
 107
 108 void setAccelerationIncludingGravityZ(double accelerationIncludingGravityZ)
 109 {
 110 m_canProvideAccelerationIncludingGravityZ = true;
 111 m_accelerationIncludingGravityZ = accelerationIncludingGravityZ;
 112 }
 113 bool canProvideAccelerationIncludingGravityZ() const { return m_canProvideAccelerationIncludingGravityZ; }
 114 double accelerationIncludingGravityZ() const { return m_accelerationIncludingGravityZ; }
 115
 116 void setRotationRateAlpha(double rotationRateAlpha)
 117 {
 118 m_canProvideRotationRateAlpha = true;
 119 m_rotationRateAlpha = rotationRateAlpha;
 120 }
 121 bool canProvideRotationRateAlpha() const { return m_canProvideRotationRateAlpha; }
 122 double rotationRateAlpha() const { return m_rotationRateAlpha; }
 123
 124 void setRotationRateBeta(double rotationRateBeta)
 125 {
 126 m_canProvideRotationRateBeta = true;
 127 m_rotationRateBeta = rotationRateBeta;
 128 }
 129 bool canProvideRotationRateBeta() const { return m_canProvideRotationRateBeta; }
 130 double rotationRateBeta() const { return m_rotationRateBeta; }
 131
 132 void setRotationRateGamma(double rotationRateGamma)
 133 {
 134 m_canProvideRotationRateGamma = true;
 135 m_rotationRateGamma = rotationRateGamma;
 136 }
 137 bool canProvideRotationRateGamma() const { return m_canProvideRotationRateGamma; }
 138 double rotationRateGamma() const { return m_rotationRateGamma; }
 139
 140 void setInterval(double interval)
 141 {
 142 m_canProvideInterval = true;
 143 m_interval = interval;
 144 }
 145 bool canProvideInterval() const { return m_canProvideInterval; }
 146 double interval() const { return m_interval; }
 147
 148#if WEBKIT_IMPLEMENTATION
 149 WebDeviceMotionData(const WebCore::DeviceMotionData*);
 150 WebDeviceMotionData& operator=(const WebCore::DeviceMotionData*);
 151 operator WTF::PassRefPtr<WebCore::DeviceMotionData>() const;
 152#endif
 153
 154private:
 155 bool m_isNull;
 156
 157 bool m_canProvideAccelerationX;
 158 double m_accelerationX;
 159 bool m_canProvideAccelerationY;
 160 double m_accelerationY;
 161 bool m_canProvideAccelerationZ;
 162 double m_accelerationZ;
 163
 164 bool m_canProvideAccelerationIncludingGravityX;
 165 double m_accelerationIncludingGravityX;
 166 bool m_canProvideAccelerationIncludingGravityY;
 167 double m_accelerationIncludingGravityY;
 168 bool m_canProvideAccelerationIncludingGravityZ;
 169 double m_accelerationIncludingGravityZ;
 170
 171 bool m_canProvideRotationRateAlpha;
 172 double m_rotationRateAlpha;
 173 bool m_canProvideRotationRateBeta;
 174 double m_rotationRateBeta;
 175 bool m_canProvideRotationRateGamma;
 176 double m_rotationRateGamma;
 177
 178 bool m_canProvideInterval;
 179 double m_interval;
 180};
 181
 182} // namespace WebKit
 183
 184#endif // WebDeviceMotionData_h

Source/WebKit/chromium/public/WebViewClient.h

@@class WebAccessibilityObject;
5151class WebBatteryStatusClient;
5252class WebColorChooser;
5353class WebColorChooserClient;
 54class WebDeviceMotionClient;
5455class WebDeviceOrientationClient;
5556class WebDragData;
5657class WebElement;

@@public:
327328
328329 // Device Orientation --------------------------------------------------
329330
 331 // Access the embedder API for device motion services.
 332 virtual WebDeviceMotionClient* deviceMotionClient() { return 0; }
 333
330334 // Access the embedder API for device orientation services.
331335 virtual WebDeviceOrientationClient* deviceOrientationClient() { return 0; }
332336

Source/WebKit/chromium/src/DeviceMotionClientProxy.cpp

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "DeviceMotionClientProxy.h"
 28
 29#include "DeviceMotionData.h"
 30#include "WebDeviceMotionController.h"
 31#include "WebDeviceMotionData.h"
 32#include <wtf/OwnPtr.h>
 33#include <wtf/PassRefPtr.h>
 34#include <wtf/RefPtr.h>
 35
 36namespace WebCore {
 37class DeviceMotionController;
 38}
 39
 40namespace WebKit {
 41
 42void DeviceMotionClientProxy::setController(WebCore::DeviceMotionController* c)
 43{
 44 if (!m_client) // FIXME: Get rid of these null checks once device motion is enabled by default.
 45 return;
 46 m_client->setController(new WebDeviceMotionController(c));
 47}
 48
 49void DeviceMotionClientProxy::startUpdating()
 50{
 51 if (!m_client)
 52 return;
 53 m_client->startUpdating();
 54}
 55
 56void DeviceMotionClientProxy::stopUpdating()
 57{
 58 if (!m_client)
 59 return;
 60 m_client->stopUpdating();
 61}
 62
 63WebCore::DeviceMotionData* DeviceMotionClientProxy::lastMotion() const
 64{
 65 if (!m_client)
 66 return 0;
 67
 68 // Cache the DeviceMotion pointer so its reference count does not drop to zero upon return.
 69 m_lastMotion = m_client->lastMotion();
 70
 71 return m_lastMotion.get();
 72}
 73
 74void DeviceMotionClientProxy::deviceMotionControllerDestroyed()
 75{
 76 // Our lifetime is bound to the WebViewImpl.
 77}
 78
 79} // namespace WebKit

Source/WebKit/chromium/src/DeviceMotionClientProxy.h

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#ifndef DeviceMotionClientProxy_h
 27#define DeviceMotionClientProxy_h
 28
 29#include "DeviceMotionClient.h"
 30#include "DeviceMotionData.h"
 31#include "WebDeviceMotionClient.h"
 32#include <wtf/RefPtr.h>
 33
 34namespace WebCore {
 35class DeviceMotionController;
 36}
 37
 38namespace WebKit {
 39
 40class DeviceMotionClientProxy : public WebCore::DeviceMotionClient {
 41public:
 42 DeviceMotionClientProxy(WebDeviceMotionClient* client)
 43 : m_client(client)
 44 {
 45 }
 46
 47 virtual void setController(WebCore::DeviceMotionController*) OVERRIDE;
 48 virtual void startUpdating() OVERRIDE;
 49 virtual void stopUpdating() OVERRIDE;
 50 virtual WebCore::DeviceMotionData* lastMotion() const OVERRIDE;
 51 virtual void deviceMotionControllerDestroyed() OVERRIDE;
 52
 53private:
 54 WebDeviceMotionClient* m_client;
 55 mutable RefPtr<WebCore::DeviceMotionData> m_lastMotion;
 56};
 57
 58} // namespace WebKit
 59
 60#endif // DeviceMotionClientProxy_h

Source/WebKit/chromium/src/WebDeviceMotionClientMock.cpp

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "WebDeviceMotionClientMock.h"
 28
 29#include "DeviceMotionClientMock.h"
 30#include "WebDeviceMotionController.h"
 31#include "WebDeviceMotionData.h"
 32
 33namespace WebKit {
 34
 35WebDeviceMotionClientMock* WebDeviceMotionClientMock::create()
 36{
 37 return new WebDeviceMotionClientMock();
 38}
 39
 40void WebDeviceMotionClientMock::setController(WebDeviceMotionController* controller)
 41{
 42 m_clientMock->setController(controller->controller());
 43 delete controller;
 44}
 45
 46void WebDeviceMotionClientMock::startUpdating()
 47{
 48 m_clientMock->startUpdating();
 49}
 50
 51void WebDeviceMotionClientMock::stopUpdating()
 52{
 53 m_clientMock->stopUpdating();
 54}
 55
 56WebDeviceMotionData WebDeviceMotionClientMock::lastMotion() const
 57{
 58 return WebDeviceMotionData(m_clientMock->lastMotion());
 59}
 60
 61void WebDeviceMotionClientMock::setMotion(WebDeviceMotionData& motion)
 62{
 63 m_clientMock->setMotion(motion);
 64}
 65
 66void WebDeviceMotionClientMock::initialize()
 67{
 68 m_clientMock.reset(new WebCore::DeviceMotionClientMock());
 69}
 70
 71void WebDeviceMotionClientMock::reset()
 72{
 73 m_clientMock.reset(0);
 74}
 75
 76} // namespace WebKit

Source/WebKit/chromium/src/WebDeviceMotionController.cpp

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "WebDeviceMotionController.h"
 28
 29#include "DeviceMotionController.h"
 30#include "DeviceMotionData.h"
 31#include "WebDeviceMotionData.h"
 32#include <wtf/PassRefPtr.h>
 33
 34namespace WebKit {
 35
 36void WebDeviceMotionController::didChangeDeviceMotion(const WebDeviceMotionData& motion)
 37{
 38 RefPtr<WebCore::DeviceMotionData> deviceMotionData = PassRefPtr<WebCore::DeviceMotionData>(motion);
 39 m_controller->didChangeDeviceMotion(deviceMotionData.get());
 40}
 41
 42WebCore::DeviceMotionController* WebDeviceMotionController::controller() const
 43{
 44 return m_controller;
 45}
 46
 47} // namespace WebKit

Source/WebKit/chromium/src/WebDeviceMotionData.cpp

 1/*
 2 * Copyright (C) 2012 Google Inc. All rights reserved.
 3 *
 4 * Redistribution and use in source and binary forms, with or without
 5 * modification, are permitted provided that the following conditions
 6 * are met:
 7 *
 8 * 1. Redistributions of source code must retain the above copyright
 9 * notice, this list of conditions and the following disclaimer.
 10 * 2. Redistributions in binary form must reproduce the above copyright
 11 * notice, this list of conditions and the following disclaimer in the
 12 * documentation and/or other materials provided with the distribution.
 13 *
 14 * THIS SOFTWARE IS PROVIDED BY APPLE AND ITS CONTRIBUTORS "AS IS" AND ANY
 15 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 16 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 17 * DISCLAIMED. IN NO EVENT SHALL APPLE OR ITS CONTRIBUTORS BE LIABLE FOR ANY
 18 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
 19 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
 20 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
 21 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
 22 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
 23 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 24 */
 25
 26#include "config.h"
 27#include "WebDeviceMotionData.h"
 28
 29#include "DeviceMotionData.h"
 30#include <wtf/PassRefPtr.h>
 31
 32namespace WebKit {
 33
 34WebDeviceMotionData::WebDeviceMotionData(const WebCore::DeviceMotionData* motion)
 35{
 36 if (!motion) {
 37 m_isNull = true;
 38 m_canProvideAccelerationX = false;
 39 m_accelerationX = 0;
 40 m_canProvideAccelerationY = false;
 41 m_accelerationY = 0;
 42 m_canProvideAccelerationZ = false;
 43 m_accelerationZ = 0;
 44 m_canProvideAccelerationIncludingGravityX = false;
 45 m_accelerationIncludingGravityX = 0;
 46 m_canProvideAccelerationIncludingGravityY = false;
 47 m_accelerationIncludingGravityY = 0;
 48 m_canProvideAccelerationIncludingGravityZ = false;
 49 m_accelerationIncludingGravityZ = 0;
 50 m_canProvideRotationRateAlpha = false;
 51 m_rotationRateAlpha = 0;
 52 m_canProvideRotationRateBeta = false;
 53 m_rotationRateBeta = 0;
 54 m_canProvideRotationRateGamma = false;
 55 m_rotationRateGamma = 0;
 56 m_canProvideInterval = false;
 57 m_interval = 0;
 58 return;
 59 }
 60
 61 m_isNull = false;
 62
 63 const WebCore::DeviceMotionData::Acceleration* acceleration = motion->acceleration();
 64 if (!acceleration) {
 65 m_canProvideAccelerationX = false;
 66 m_accelerationX = 0;
 67 m_canProvideAccelerationY = false;
 68 m_accelerationY = 0;
 69 m_canProvideAccelerationZ = false;
 70 m_accelerationZ = 0;
 71 } else {
 72 m_canProvideAccelerationX = acceleration->canProvideX();
 73 m_accelerationX = acceleration->x();
 74 m_canProvideAccelerationY = acceleration->canProvideY();
 75 m_accelerationY = acceleration->y();
 76 m_canProvideAccelerationZ = acceleration->canProvideZ();
 77 m_accelerationZ = acceleration->z();
 78 }
 79
 80 const WebCore::DeviceMotionData::Acceleration* accelerationIncludingGravity = motion->accelerationIncludingGravity();
 81 if (!accelerationIncludingGravity) {
 82 m_canProvideAccelerationIncludingGravityX = false;
 83 m_accelerationIncludingGravityX = 0;
 84 m_canProvideAccelerationIncludingGravityY = false;
 85 m_accelerationIncludingGravityY = 0;
 86 m_canProvideAccelerationIncludingGravityZ = false;
 87 m_accelerationIncludingGravityZ = 0;
 88 } else {
 89 m_canProvideAccelerationIncludingGravityX = accelerationIncludingGravity->canProvideX();
 90 m_accelerationIncludingGravityX = accelerationIncludingGravity->x();
 91 m_canProvideAccelerationIncludingGravityY = accelerationIncludingGravity->canProvideY();
 92 m_accelerationIncludingGravityY = accelerationIncludingGravity->y();
 93 m_canProvideAccelerationIncludingGravityZ = accelerationIncludingGravity->canProvideZ();
 94 m_accelerationIncludingGravityZ = accelerationIncludingGravity->z();
 95 }
 96
 97 const WebCore::DeviceMotionData::RotationRate* rotationRate = motion->rotationRate();
 98 if (!rotationRate) {
 99 m_canProvideRotationRateAlpha = false;
 100 m_rotationRateAlpha = 0;
 101 m_canProvideRotationRateBeta = false;
 102 m_rotationRateBeta = 0;
 103 m_canProvideRotationRateGamma = false;
 104 m_rotationRateGamma = 0;
 105 } else {
 106 m_canProvideRotationRateAlpha = rotationRate->canProvideAlpha();
 107 m_rotationRateAlpha = rotationRate->alpha();
 108 m_canProvideRotationRateBeta = rotationRate->canProvideBeta();
 109 m_rotationRateBeta = rotationRate->beta();
 110 m_canProvideRotationRateGamma = rotationRate->canProvideGamma();
 111 m_rotationRateGamma = rotationRate->gamma();
 112 }
 113
 114 m_canProvideInterval = motion->canProvideInterval();
 115 m_interval = motion->interval();
 116}
 117
 118WebDeviceMotionData& WebDeviceMotionData::operator=(const WebCore::DeviceMotionData* motion)
 119{
 120 if (!motion) {
 121 m_isNull = true;
 122 m_canProvideAccelerationX = false;
 123 m_accelerationX = 0;
 124 m_canProvideAccelerationY = false;
 125 m_accelerationY = 0;
 126 m_canProvideAccelerationZ = false;
 127 m_accelerationZ = 0;
 128 m_canProvideAccelerationIncludingGravityX = false;
 129 m_accelerationIncludingGravityX = 0;
 130 m_canProvideAccelerationIncludingGravityY = false;
 131 m_accelerationIncludingGravityY = 0;
 132 m_canProvideAccelerationIncludingGravityZ = false;
 133 m_accelerationIncludingGravityZ = 0;
 134 m_canProvideRotationRateAlpha = false;
 135 m_rotationRateAlpha = 0;
 136 m_canProvideRotationRateBeta = false;
 137 m_rotationRateBeta = 0;
 138 m_canProvideRotationRateGamma = false;
 139 m_rotationRateGamma = 0;
 140 m_canProvideInterval = false;
 141 m_interval = 0;
 142 return *this;
 143 }
 144
 145 m_isNull = false;
 146
 147 const WebCore::DeviceMotionData::Acceleration* acceleration = motion->acceleration();
 148 if (!acceleration) {
 149 m_canProvideAccelerationX = false;
 150 m_accelerationX = 0;
 151 m_canProvideAccelerationY = false;
 152 m_accelerationY = 0;
 153 m_canProvideAccelerationZ = false;
 154 m_accelerationZ = 0;
 155 } else {
 156 m_canProvideAccelerationX = acceleration->canProvideX();
 157 m_accelerationX = acceleration->x();
 158 m_canProvideAccelerationY = acceleration->canProvideY();
 159 m_accelerationY = acceleration->y();
 160 m_canProvideAccelerationZ = acceleration->canProvideZ();
 161 m_accelerationZ = acceleration->z();
 162 }
 163
 164 const WebCore::DeviceMotionData::Acceleration* accelerationIncludingGravity = motion->accelerationIncludingGravity();
 165 if (!accelerationIncludingGravity) {
 166 m_canProvideAccelerationIncludingGravityX = false;
 167 m_accelerationIncludingGravityX = 0;
 168 m_canProvideAccelerationIncludingGravityY = false;
 169 m_accelerationIncludingGravityY = 0;
 170 m_canProvideAccelerationIncludingGravityZ = false;
 171 m_accelerationIncludingGravityZ = 0;
 172 } else {
 173 m_canProvideAccelerationX = acceleration->canProvideX();
 174 m_accelerationX = acceleration->x();
 175 m_canProvideAccelerationY = acceleration->canProvideY();
 176 m_accelerationY = acceleration->y();
 177 m_canProvideAccelerationZ = acceleration->canProvideZ();
 178 m_accelerationZ = acceleration->z();
 179 }
 180
 181 const WebCore::DeviceMotionData::RotationRate* rotationRate = motion->rotationRate();
 182 if (!rotationRate) {
 183 m_canProvideRotationRateAlpha = false;
 184 m_rotationRateAlpha = 0;
 185 m_canProvideRotationRateBeta = false;
 186 m_rotationRateBeta = 0;
 187 m_canProvideRotationRateGamma = false;
 188 m_rotationRateGamma = 0;
 189 } else {
 190 m_canProvideRotationRateAlpha = rotationRate->canProvideAlpha();
 191 m_rotationRateAlpha = rotationRate->alpha();
 192 m_canProvideRotationRateBeta = rotationRate->canProvideBeta();
 193 m_rotationRateBeta = rotationRate->beta();
 194 m_canProvideRotationRateGamma = rotationRate->canProvideGamma();
 195 m_rotationRateGamma = rotationRate->gamma();
 196 }
 197
 198 m_canProvideInterval = motion->canProvideInterval();
 199 m_interval = motion->interval();
 200
 201 return *this;
 202}
 203
 204WebDeviceMotionData::operator PassRefPtr<WebCore::DeviceMotionData>() const
 205{
 206 if (m_isNull)
 207 return 0;
 208
 209 RefPtr<WebCore::DeviceMotionData::Acceleration> acceleration =
 210 WebCore::DeviceMotionData::Acceleration::create(m_canProvideAccelerationX, m_accelerationX, m_canProvideAccelerationY, m_accelerationY, m_canProvideAccelerationZ, m_accelerationZ);
 211 RefPtr<WebCore::DeviceMotionData::Acceleration> accelerationIncludingGravity =
 212 WebCore::DeviceMotionData::Acceleration::create(m_canProvideAccelerationIncludingGravityX, m_accelerationIncludingGravityX, m_canProvideAccelerationIncludingGravityY, m_accelerationIncludingGravityY, m_canProvideAccelerationIncludingGravityZ, m_accelerationIncludingGravityZ);
 213 RefPtr<WebCore::DeviceMotionData::RotationRate> rotationRate =
 214 WebCore::DeviceMotionData::RotationRate::create(m_canProvideRotationRateAlpha, m_rotationRateAlpha, m_canProvideRotationRateBeta, m_rotationRateBeta, m_canProvideRotationRateGamma, m_rotationRateGamma);
 215
 216 return WebCore::DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, m_canProvideInterval, m_interval);
 217}
 218
 219} // namespace WebKit

Source/WebKit/chromium/src/WebViewImpl.cpp

4747#include "ContextMenuItem.h"
4848#include "Cursor.h"
4949#include "DOMUtilitiesPrivate.h"
 50#include "DeviceMotionClientProxy.h"
5051#include "DeviceOrientationClientProxy.h"
5152#include "Document.h"
5253#include "DocumentLoader.h"

@@WebViewImpl::WebViewImpl(WebViewClient* client)
416417#if ENABLE(SCRIPTED_SPEECH)
417418 , m_speechRecognitionClient(SpeechRecognitionClientProxy::create(client ? client->speechRecognizer() : 0))
418419#endif
 420 , m_deviceMotionClientProxy(adoptPtr(new DeviceMotionClientProxy(client ? client->deviceMotionClient() : 0)))
419421 , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0)))
420422 , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0)))
421423#if ENABLE(BATTERY_STATUS)

@@WebViewImpl::WebViewImpl(WebViewClient* client)
456458#endif
457459
458460 provideContextFeaturesTo(m_page.get(), m_featureSwitchClient.get());
 461 provideDeviceMotionTo(m_page.get(), m_deviceMotionClientProxy.get());
459462 provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get());
460463 provideGeolocationTo(m_page.get(), m_geolocationClientProxy.get());
461464 m_geolocationClientProxy->setController(GeolocationController::from(m_page.get()));

Source/WebKit/chromium/src/WebViewImpl.h

@@class AutofillPopupMenuClient;
8888class BatteryClientImpl;
8989class ContextFeaturesClientImpl;
9090class ContextMenuClientImpl;
 91class DeviceMotionClientProxy;
9192class DeviceOrientationClientProxy;
9293class DragScrollTimer;
9394class GeolocationClientProxy;

@@private:
812813 // the compositor has been turned on, we need to instantiate it
813814 // early. This member holds on to the GC3D in this case.
814815 OwnPtr<WebGraphicsContext3D> m_temporaryOnscreenGraphicsContext3D;
 816 OwnPtr<DeviceMotionClientProxy> m_deviceMotionClientProxy;
815817 OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy;
816818 OwnPtr<GeolocationClientProxy> m_geolocationClientProxy;
817819#if ENABLE(BATTERY_STATUS)

Tools/ChangeLog

 12012-06-20 Amy Ousterhout <aousterh@chromium.org>
 2
 3 [Chromium] Implements DeviceMotion
 4 https://bugs.webkit.org/show_bug.cgi?id=89197
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Adds functionality for testing DeviceMotion using WebDeviceMotionClientMock.
 9
 10 * DumpRenderTree/chromium/LayoutTestController.cpp:
 11 (LayoutTestController::LayoutTestController):
 12 (LayoutTestController::setMockDeviceMotion):
 13 * DumpRenderTree/chromium/LayoutTestController.h:
 14 (LayoutTestController):
 15 * DumpRenderTree/chromium/WebViewHost.cpp:
 16 (WebViewHost::deviceMotionClientMock):
 17 (WebViewHost::deviceMotionClient):
 18 * DumpRenderTree/chromium/WebViewHost.h:
 19 (WebKit):
 20 (WebViewHost):
 21
1222012-06-20 Simon Hausmann <simon.hausmann@nokia.com>
223
324 Unreviewed trivial permissions fix.

Tools/DumpRenderTree/chromium/LayoutTestController.cpp

4141#include "WebWorkerInfo.h"
4242#include "WebConsoleMessage.h"
4343#include "platform/WebData.h"
 44#include "WebDeviceMotionClientMock.h"
 45#include "WebDeviceMotionData.h"
4446#include "WebDeviceOrientation.h"
4547#include "WebDeviceOrientationClientMock.h"
4648#include "WebDocument.h"

@@LayoutTestController::LayoutTestController(TestShell* shell)
205207 bindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled);
206208 bindMethod("setJavaScriptCanAccessClipboard", &LayoutTestController::setJavaScriptCanAccessClipboard);
207209 bindMethod("setMinimumTimerInterval", &LayoutTestController::setMinimumTimerInterval);
 210 bindMethod("setMockDeviceMotion", &LayoutTestController::setMockDeviceMotion);
208211 bindMethod("setMockDeviceOrientation", &LayoutTestController::setMockDeviceOrientation);
209212 bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError);
210213 bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition);

@@void LayoutTestController::addUserStyleSheet(const CppArgumentList& arguments, C
18661869 WebView::UserStyleInjectInExistingDocuments);
18671870}
18681871
 1872void LayoutTestController::setMockDeviceMotion(const CppArgumentList& arguments, CppVariant* result)
 1873{
 1874 result->setNull();
 1875 if (arguments.size() < 20 || !arguments[0].isBool() || !arguments[1].isNumber() || !arguments[2].isBool() || !arguments[3].isNumber() || !arguments[4].isBool() || !arguments[5].isNumber() || !arguments[6].isBool() || !arguments[7].isNumber() || !arguments[8].isBool() || !arguments[9].isNumber() || !arguments[10].isBool() || !arguments[11].isNumber() || !arguments[12].isBool() || !arguments[13].isNumber() || !arguments[14].isBool() || !arguments[15].isNumber() || !arguments[16].isBool() || !arguments[17].isNumber() || !arguments[18].isBool() || !arguments[19].isNumber())
 1876 return;
 1877
 1878 WebDeviceMotionData motion;
 1879 motion.setNull(false);
 1880 if (arguments[0].toBoolean())
 1881 motion.setAccelerationX(arguments[1].toDouble());
 1882 if (arguments[2].toBoolean())
 1883 motion.setAccelerationY(arguments[3].toDouble());
 1884 if (arguments[4].toBoolean())
 1885 motion.setAccelerationZ(arguments[5].toDouble());
 1886
 1887 if (arguments[6].toBoolean())
 1888 motion.setAccelerationIncludingGravityX(arguments[7].toDouble());
 1889 if (arguments[8].toBoolean())
 1890 motion.setAccelerationIncludingGravityY(arguments[9].toDouble());
 1891 if (arguments[10].toBoolean())
 1892 motion.setAccelerationIncludingGravityZ(arguments[11].toDouble());
 1893
 1894 if (arguments[12].toBoolean())
 1895 motion.setRotationRateAlpha(arguments[13].toDouble());
 1896 if (arguments[14].toBoolean())
 1897 motion.setRotationRateBeta(arguments[15].toDouble());
 1898 if (arguments[16].toBoolean())
 1899 motion.setRotationRateGamma(arguments[17].toDouble());
 1900
 1901 if (arguments[18].toBoolean())
 1902 motion.setInterval(arguments[19].toDouble());
 1903
 1904 // Note that we only call setMotion on the main page's mock since this is all that the
 1905 // tests require. If necessary, we could get a list of WebViewHosts from the TestShell and
 1906 // call setMotion on each DeviceMotionClientMock.
 1907 m_shell->webViewHost()->deviceMotionClientMock()->setMotion(motion);
 1908}
 1909
18691910void LayoutTestController::setMockDeviceOrientation(const CppArgumentList& arguments, CppVariant* result)
18701911{
18711912 result->setNull();

Tools/DumpRenderTree/chromium/LayoutTestController.h

@@public:
357357 void addUserStyleSheet(const CppArgumentList&, CppVariant*);
358358
359359 // DeviceOrientation related functions
 360 void setMockDeviceMotion(const CppArgumentList&, CppVariant*);
360361 void setMockDeviceOrientation(const CppArgumentList&, CppVariant*);
361362
362363 // Geolocation related functions.

Tools/DumpRenderTree/chromium/WebViewHost.cpp

4343#include "WebContextMenuData.h"
4444#include "WebDOMMessageEvent.h"
4545#include "WebDataSource.h"
 46#include "WebDeviceMotionClientMock.h"
4647#include "WebDeviceOrientationClientMock.h"
4748#include "WebDocument.h"
4849#include "platform/WebDragData.h"

@@WebSpeechRecognizer* WebViewHost::speechRecognizer()
751752}
752753#endif
753754
 755WebDeviceMotionClientMock* WebViewHost::deviceMotionClientMock()
 756{
 757 if (!m_deviceMotionClientMock.get())
 758 m_deviceMotionClientMock = adoptPtr(WebDeviceMotionClientMock::create());
 759 return m_deviceMotionClientMock.get();
 760}
 761
754762WebDeviceOrientationClientMock* WebViewHost::deviceOrientationClientMock()
755763{
756764 if (!m_deviceOrientationClientMock.get())

@@MockSpellCheck* WebViewHost::mockSpellCheck()
763771 return &m_spellcheck;
764772}
765773
 774WebDeviceMotionClient* WebViewHost::deviceMotionClient()
 775{
 776 return deviceMotionClientMock();
 777}
 778
766779WebDeviceOrientationClient* WebViewHost::deviceOrientationClient()
767780{
768781 return deviceOrientationClientMock();

Tools/DumpRenderTree/chromium/WebViewHost.h

@@class TestShell;
5454
5555namespace WebKit {
5656class WebFrame;
 57class WebDeviceMotionClient;
 58class WebDeviceMotionClientMock;
5759class WebDeviceOrientationClient;
5860class WebDeviceOrientationClientMock;
5961class WebGeolocationClient;

@@class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
185187#if ENABLE(SCRIPTED_SPEECH)
186188 virtual WebKit::WebSpeechRecognizer* speechRecognizer() OVERRIDE;
187189#endif
 190 virtual WebKit::WebDeviceMotionClient* deviceMotionClient() OVERRIDE;
188191 virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient() OVERRIDE;
189192#if ENABLE(MEDIA_STREAM)
190193 virtual WebKit::WebUserMediaClient* userMediaClient();

@@class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient,
266269 virtual void deliveredIntentResult(WebKit::WebFrame*, int, const WebKit::WebSerializedScriptValue&);
267270 virtual void deliveredIntentFailure(WebKit::WebFrame*, int, const WebKit::WebSerializedScriptValue&);
268271
 272 WebKit::WebDeviceMotionClientMock* deviceMotionClientMock();
269273 WebKit::WebDeviceOrientationClientMock* deviceOrientationClientMock();
270274
271275 // Spellcheck related helper APIs

@@private:
416420 // Geolocation
417421 OwnPtr<WebKit::WebGeolocationClientMock> m_geolocationClientMock;
418422
 423 OwnPtr<WebKit::WebDeviceMotionClientMock> m_deviceMotionClientMock;
419424 OwnPtr<WebKit::WebDeviceOrientationClientMock> m_deviceOrientationClientMock;
420425#if ENABLE(INPUT_SPEECH)
421426 OwnPtr<MockWebSpeechInputController> m_speechInputControllerMock;

LayoutTests/ChangeLog

 12012-06-20 Amy Ousterhout <aousterh@chromium.org>
 2
 3 [Chromium] Implements DeviceMotion
 4 https://bugs.webkit.org/show_bug.cgi?id=89197
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 Adds seven new tests for DeviceMotion.
 9 Each tests corresponds to a similar existing test for DeviceOrientation, since they are part of the same spec and work very similarly.
 10
 11 * fast/dom/DeviceMotion/add-listener-from-callback-expected.txt: Added.
 12 * fast/dom/DeviceMotion/add-listener-from-callback.html: Added.
 13 * fast/dom/DeviceMotion/basic-operation-expected.txt: Added.
 14 * fast/dom/DeviceMotion/basic-operation.html: Added.
 15 * fast/dom/DeviceMotion/event-after-navigation-expected.txt: Added.
 16 * fast/dom/DeviceMotion/event-after-navigation.html: Added.
 17 * fast/dom/DeviceMotion/multiple-frames-expected.txt: Added.
 18 * fast/dom/DeviceMotion/multiple-frames.html: Added.
 19 * fast/dom/DeviceMotion/no-synchronous-events-expected.txt: Added.
 20 * fast/dom/DeviceMotion/no-synchronous-events.html: Added.
 21 * fast/dom/DeviceMotion/null-values-expected.txt: Added.
 22 * fast/dom/DeviceMotion/null-values.html: Added.
 23 * fast/dom/DeviceMotion/resources/event-after-navigation-new.html: Added.
 24 * fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js: Added.
 25 (checkMotion):
 26 (firstListener):
 27 (secondListener):
 28 (maybeFinishTest):
 29 * fast/dom/DeviceMotion/script-tests/basic-operation.js: Added.
 30 * fast/dom/DeviceMotion/script-tests/event-after-navigation.js: Added.
 31 * fast/dom/DeviceMotion/script-tests/multiple-frames.js: Added.
 32 (checkMotion):
 33 (mainFrameListener):
 34 (childFrameListener):
 35 (maybeFinishTest):
 36 * fast/dom/DeviceMotion/script-tests/no-synchronous-events.js: Added.
 37 * fast/dom/DeviceMotion/script-tests/null-values.js: Added.
 38 (setMockMotion):
 39 (checkMotion):
 40 (firstListener):
 41 (secondListener):
 42 (thirdListener):
 43 (fourthListener):
 44 (fifthListener):
 45 (sixthListener):
 46 (seventhListener):
 47 (eighthListener):
 48 (ninthListener):
 49 (tenthListener):
 50 (eleventhListener):
 51 * fast/dom/DeviceMotion/script-tests/updates.js: Added.
 52 (setMockMotion):
 53 (checkMotion):
 54 (firstListener):
 55 (updateListener):
 56 * fast/dom/DeviceMotion/updates-expected.txt: Added.
 57 * fast/dom/DeviceMotion/updates.html: Added.
 58
1592012-06-20 Hans Wennborg <hans@chromium.org>
260
361 Speech JavaScript API: add SpeechRecognition.maxAlternatives attribute

LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback-expected.txt

 1Tests that adding a new event listener from a callback works as expected.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS deviceMotionEvent.acceleration.x is mockAccelerationX
 7PASS deviceMotionEvent.acceleration.y is mockAccelerationY
 8PASS deviceMotionEvent.acceleration.z is mockAccelerationZ
 9PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX
 10PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY
 11PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ
 12PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha
 13PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta
 14PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma
 15PASS deviceMotionEvent.interval is mockInterval
 16PASS deviceMotionEvent.acceleration.x is mockAccelerationX
 17PASS deviceMotionEvent.acceleration.y is mockAccelerationY
 18PASS deviceMotionEvent.acceleration.z is mockAccelerationZ
 19PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX
 20PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY
 21PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ
 22PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha
 23PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta
 24PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma
 25PASS deviceMotionEvent.interval is mockInterval
 26PASS deviceMotionEvent.acceleration.x is mockAccelerationX
 27PASS deviceMotionEvent.acceleration.y is mockAccelerationY
 28PASS deviceMotionEvent.acceleration.z is mockAccelerationZ
 29PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX
 30PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY
 31PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ
 32PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha
 33PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta
 34PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma
 35PASS deviceMotionEvent.interval is mockInterval
 36PASS successfullyParsed is true
 37
 38TEST COMPLETE
 39

LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/add-listener-from-callback.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/basic-operation-expected.txt

 1Tests the basic operation of DeviceMotion using the mock.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS deviceMotionEvent.acceleration.x is mockAccelerationX
 7PASS deviceMotionEvent.acceleration.y is mockAccelerationY
 8PASS deviceMotionEvent.acceleration.z is mockAccelerationZ
 9PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX
 10PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY
 11PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ
 12PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha
 13PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta
 14PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma
 15PASS deviceMotionEvent.interval is mockInterval
 16PASS successfullyParsed is true
 17
 18TEST COMPLETE
 19

LayoutTests/fast/dom/DeviceMotion/basic-operation.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/basic-operation.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/event-after-navigation-expected.txt

 1Tests for a crash where an event is fired after the page has been navigated away when the original page is in the page cache.
 2
 3SUCCESS

LayoutTests/fast/dom/DeviceMotion/event-after-navigation.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/event-after-navigation.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/multiple-frames-expected.txt

 1Tests using DeviceMotion from multiple frames.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 7PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 8PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 9PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 10PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 11PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 12PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 13PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 14PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 15PASS deviceMotionEvent.interval is mockEvent.interval
 16PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 17PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 18PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 19PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 20PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 21PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 22PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 23PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 24PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 25PASS deviceMotionEvent.interval is mockEvent.interval
 26PASS successfullyParsed is true
 27
 28TEST COMPLETE
 29

LayoutTests/fast/dom/DeviceMotion/multiple-frames.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/multiple-frames.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/no-synchronous-events-expected.txt

 1Tests that events are never fired synchronously from a call to window.addEventListener().
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS hasAddEventListenerReturned is true
 7PASS successfullyParsed is true
 8
 9TEST COMPLETE
 10

LayoutTests/fast/dom/DeviceMotion/no-synchronous-events.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/no-synchronous-events.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/null-values-expected.txt

 1Tests using null values for some of the event properties.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 7PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 8PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 9PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 10PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 11PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 12PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 13PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 14PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 15PASS deviceMotionEvent.interval is mockEvent.interval
 16PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 17PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 18PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 19PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 20PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 21PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 22PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 23PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 24PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 25PASS deviceMotionEvent.interval is mockEvent.interval
 26PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 27PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 28PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 29PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 30PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 31PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 32PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 33PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 34PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 35PASS deviceMotionEvent.interval is mockEvent.interval
 36PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 37PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 38PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 39PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 40PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 41PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 42PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 43PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 44PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 45PASS deviceMotionEvent.interval is mockEvent.interval
 46PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 47PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 48PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 49PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 50PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 51PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 52PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 53PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 54PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 55PASS deviceMotionEvent.interval is mockEvent.interval
 56PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 57PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 58PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 59PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 60PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 61PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 62PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 63PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 64PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 65PASS deviceMotionEvent.interval is mockEvent.interval
 66PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 67PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 68PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 69PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 70PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 71PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 72PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 73PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 74PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 75PASS deviceMotionEvent.interval is mockEvent.interval
 76PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 77PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 78PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 79PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 80PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 81PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 82PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 83PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 84PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 85PASS deviceMotionEvent.interval is mockEvent.interval
 86PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 87PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 88PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 89PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 90PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 91PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 92PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 93PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 94PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 95PASS deviceMotionEvent.interval is mockEvent.interval
 96PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 97PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 98PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 99PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 100PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 101PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 102PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 103PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 104PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 105PASS deviceMotionEvent.interval is mockEvent.interval
 106PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 107PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 108PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 109PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 110PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 111PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 112PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 113PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 114PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 115PASS deviceMotionEvent.interval is mockEvent.interval
 116PASS successfullyParsed is true
 117
 118TEST COMPLETE
 119

LayoutTests/fast/dom/DeviceMotion/null-values.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/null-values.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>

LayoutTests/fast/dom/DeviceMotion/resources/event-after-navigation-new.html

 1<html>
 2 <head>
 3 </head>
 4 <body>
 5 Tests for a crash where an event is fired after the page has been navigated
 6 away when the original page is in the page cache.<br><br>
 7 SUCCESS
 8 <script>
 9 if (window.layoutTestController) {
 10 layoutTestController.setMockDeviceMotion(true, 1.01, true, 2.02, true, 3.03, true, 4.04, true, 5.05, true, 6.06, true, 7.07, true, 8.08, true, 9.09, true, 10.10);
 11 layoutTestController.notifyDone();
 12 }
 13 </script>
 14 </body>
 15</html>

LayoutTests/fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js

 1description('Tests that adding a new event listener from a callback works as expected.');
 2
 3var mockAccelerationX = 1.01;
 4var mockAccelerationY = 2.02;
 5var mockAccelerationZ = 3.03;
 6
 7var mockAccelerationIncludingGravityX = 4.04;
 8var mockAccelerationIncludingGravityY = 5.05;
 9var mockAccelerationIncludingGravityZ = 6.06;
 10
 11var mockRotationRateAlpha = 7.07;
 12var mockRotationRateBeta = 8.08;
 13var mockRotationRateGamma = 9.09;
 14
 15var mockInterval = 10.10;
 16
 17if (window.layoutTestController) {
 18 layoutTestController.setMockDeviceMotion(true, mockAccelerationX, true, mockAccelerationY, true, mockAccelerationZ, true, mockAccelerationIncludingGravityX, true, mockAccelerationIncludingGravityY, true, mockAccelerationIncludingGravityZ, true, mockRotationRateAlpha, true, mockRotationRateBeta, true, mockRotationRateGamma, true, mockInterval);
 19} else
 20 debug('This test can not be run without the LayoutTestController');
 21
 22var deviceMotionEvent;
 23function checkMotion(event) {
 24 deviceMotionEvent = event;
 25 shouldBe('deviceMotionEvent.acceleration.x', 'mockAccelerationX');
 26 shouldBe('deviceMotionEvent.acceleration.y', 'mockAccelerationY');
 27 shouldBe('deviceMotionEvent.acceleration.z', 'mockAccelerationZ');
 28 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockAccelerationIncludingGravityX');
 29 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockAccelerationIncludingGravityY');
 30 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockAccelerationIncludingGravityZ');
 31 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockRotationRateAlpha');
 32 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockRotationRateBeta');
 33 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockRotationRateGamma');
 34 shouldBe('deviceMotionEvent.interval', 'mockInterval');
 35}
 36
 37var firstListenerEvents = 0;
 38function firstListener(event) {
 39 checkMotion(event);
 40 if (++firstListenerEvents == 1)
 41 window.addEventListener('devicemotion', secondListener);
 42 else if (firstListenerEvents > 2)
 43 testFailed('Too many events for first listener.');
 44 maybeFinishTest();
 45}
 46
 47var secondListenerEvents = 0;
 48function secondListener(event) {
 49 checkMotion(event);
 50 if (++secondListenerEvents > 1)
 51 testFailed('Too many events for second listener.');
 52 maybeFinishTest();
 53}
 54
 55function maybeFinishTest() {
 56 if (firstListenerEvents == 2 && secondListenerEvents == 1)
 57 finishJSTest();
 58}
 59
 60window.addEventListener('devicemotion', firstListener);
 61
 62window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/basic-operation.js

 1description('Tests the basic operation of DeviceMotion using the mock.');
 2
 3var mockAccelerationX = 1.01;
 4var mockAccelerationY = 2.02;
 5var mockAccelerationZ = 3.03;
 6
 7var mockAccelerationIncludingGravityX = 4.04;
 8var mockAccelerationIncludingGravityY = 5.05;
 9var mockAccelerationIncludingGravityZ = 6.06;
 10
 11var mockRotationRateAlpha = 7.07;
 12var mockRotationRateBeta = 8.08;
 13var mockRotationRateGamma = 9.09;
 14
 15var mockInterval = 10.10;
 16
 17if (window.layoutTestController) {
 18 layoutTestController.setMockDeviceMotion(true, mockAccelerationX, true, mockAccelerationY, true, mockAccelerationZ, true, mockAccelerationIncludingGravityX, true, mockAccelerationIncludingGravityY, true, mockAccelerationIncludingGravityZ, true, mockRotationRateAlpha, true, mockRotationRateBeta, true, mockRotationRateGamma, true, mockInterval);
 19} else
 20 debug('This test can not be run without the LayoutTestController');
 21
 22var deviceMotionEvent;
 23window.addEventListener('devicemotion', function(e) {
 24 deviceMotionEvent = e;
 25 shouldBe('deviceMotionEvent.acceleration.x', 'mockAccelerationX');
 26 shouldBe('deviceMotionEvent.acceleration.y', 'mockAccelerationY');
 27 shouldBe('deviceMotionEvent.acceleration.z', 'mockAccelerationZ');
 28 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockAccelerationIncludingGravityX');
 29 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockAccelerationIncludingGravityY');
 30 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockAccelerationIncludingGravityZ');
 31 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockRotationRateAlpha');
 32 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockRotationRateBeta');
 33 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockRotationRateGamma');
 34 shouldBe('deviceMotionEvent.interval', 'mockInterval');
 35 finishJSTest();
 36});
 37
 38window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/event-after-navigation.js

 1description('Tests for a crash where an event is fired after the page has been navigated away when the original page is in the page cache.');
 2
 3if (window.layoutTestController)
 4 layoutTestController.overridePreference('WebKitUsesPageCachePreferenceKey', 1);
 5else
 6 debug('This test can not be run without the LayoutTestController');
 7
 8document.body.onload = function() {
 9 window.addEventListener('devicemotion', function() { } );
 10 window.location = "resources/event-after-navigation-new.html";
 11}
 12
 13window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/multiple-frames.js

 1description('Tests using DeviceMotion from multiple frames.');
 2
 3var deviceMotionEvent;
 4function checkMotion(event) {
 5 deviceMotionEvent = event;
 6 shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX');
 7 shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY');
 8 shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ');
 9 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.accelerationIncludingGravityX');
 10 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.accelerationIncludingGravityY');
 11 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.accelerationIncludingGravityZ');
 12 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlpha');
 13 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta');
 14 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamma');
 15 shouldBe('deviceMotionEvent.interval', 'mockEvent.interval');
 16}
 17
 18var hasMainFrameEventFired = false;
 19function mainFrameListener(event) {
 20 checkMotion(event);
 21 hasMainFrameEventFired = true;
 22 maybeFinishTest();
 23}
 24
 25var hasChildFrameEventFired = false;
 26function childFrameListener(event) {
 27 checkMotion(event);
 28 hasChildFrameEventFired = true;
 29 maybeFinishTest();
 30}
 31
 32function maybeFinishTest() {
 33 if (hasMainFrameEventFired && hasChildFrameEventFired)
 34 finishJSTest();
 35}
 36
 37var mockEvent = {accelerationX: 1.01, accelerationY: 2.02, accelerationZ: 3.03, accelerationIncludingGravityX: 4.04, accelerationIncludingGravityY: 5.05, accelerationIncludingGravityZ: 6.06, rotationRateAlpha: 7.07, rotationRateBeta: 8.08, rotationRateGamma: 9.09, interval: 10.10};
 38if (window.layoutTestController)
 39 layoutTestController.setMockDeviceMotion(true, mockEvent.accelerationX, true, mockEvent.accelerationY, true, mockEvent.accelerationZ, true, mockEvent.accelerationIncludingGravityX, true, mockEvent.accelerationIncludingGravityY, true, mockEvent.accelerationIncludingGravityZ, true, mockEvent.rotationRateAlpha, true, mockEvent.rotationRateBeta, true, mockEvent.rotationRateGamma, true, mockEvent.interval);
 40else
 41 debug('This test can not be run without the LayoutTestController');
 42
 43var childFrame = document.createElement('iframe');
 44document.body.appendChild(childFrame);
 45childFrame.contentWindow.addEventListener('devicemotion', childFrameListener);
 46
 47window.addEventListener('devicemotion', mainFrameListener);
 48
 49window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/no-synchronous-events.js

 1description('Tests that events are never fired synchronously from a call to window.addEventListener().');
 2
 3if (window.layoutTestController)
 4 layoutTestController.setMockDeviceMotion(true, 1.01, true, 2.02, true, 3.03, true, 4.04, true, 5.05, true, 6.06, true, 7.07, true, 8.08, true, 9.09, true, 10.10, true);
 5else
 6 debug('This test can not be run without the LayoutTestController');
 7
 8var hasAddEventListenerReturned = false;
 9window.addEventListener('devicemotion', function() {
 10 shouldBeTrue('hasAddEventListenerReturned');
 11 finishJSTest();
 12});
 13hasAddEventListenerReturned = true;
 14
 15window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/null-values.js

 1description('Tests using null values for some of the event properties.');
 2
 3var mockEvent;
 4function setMockMotion(accelerationX, accelerationY, accelerationZ, accelerationIncludingGravityX, accelerationIncludingGravityY, accelerationIncludingGravityZ, rotationRateAlpha, rotationRateBeta, rotationRateGamma, interval) {
 5 mockEvent = {accelerationX: accelerationX, accelerationY: accelerationY, accelerationZ: accelerationZ, accelerationIncludingGravityX: accelerationIncludingGravityX, accelerationIncludingGravityY: accelerationIncludingGravityY, accelerationIncludingGravityZ: accelerationIncludingGravityZ, rotationRateAlpha: rotationRateAlpha, rotationRateBeta: rotationRateBeta, rotationRateGamma: rotationRateGamma, interval: interval};
 6 if (window.layoutTestController)
 7 layoutTestController.setMockDeviceMotion(
 8 null != mockEvent.accelerationX, null == mockEvent.accelerationX ? 0 : mockEvent.accelerationX,
 9 null != mockEvent.accelerationY, null == mockEvent.accelerationY ? 0 : mockEvent.accelerationY,
 10 null != mockEvent.accelerationZ, null == mockEvent.accelerationZ ? 0 : mockEvent.accelerationZ,
 11 null != mockEvent.accelerationIncludingGravityX, null == mockEvent.accelerationIncludingGravityX ? 0 : mockEvent.accelerationIncludingGravityX,
 12 null != mockEvent.accelerationIncludingGravityY, null == mockEvent.accelerationIncludingGravityY ? 0 : mockEvent.accelerationIncludingGravityY,
 13 null != mockEvent.accelerationIncludingGravityZ, null == mockEvent.accelerationIncludingGravityZ ? 0 : mockEvent.accelerationIncludingGravityZ,
 14 null != mockEvent.rotationRateAlpha, null == mockEvent.rotationRateAlpha ? 0 : mockEvent.rotationRateAlpha,
 15 null != mockEvent.rotationRateBeta, null == mockEvent.rotationRateBeta ? 0 : mockEvent.rotationRateBeta,
 16 null != mockEvent.rotationRateGamma, null == mockEvent.rotationRateGamma ? 0 : mockEvent.rotationRateGamma,
 17 null != mockEvent.interval, null == mockEvent.interval ? 0 : mockEvent.interval);
 18 else
 19 debug('This test can not be run without the LayoutTestController');
 20}
 21
 22var deviceMotionEvent;
 23function checkMotion(event) {
 24 deviceMotionEvent = event;
 25 shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX');
 26 shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY');
 27 shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ');
 28 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.accelerationIncludingGravityX');
 29 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.accelerationIncludingGravityY');
 30 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.accelerationIncludingGravityZ');
 31 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlpha');
 32 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta');
 33 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamma');
 34 shouldBe('deviceMotionEvent.interval', 'mockEvent.interval');
 35}
 36
 37function firstListener(event) {
 38 checkMotion(event);
 39 window.removeEventListener('devicemotion', firstListener);
 40
 41 setMockMotion(1.01, null, null, null, null, null, null, null, null, null);
 42 window.addEventListener('devicemotion', secondListener);
 43}
 44
 45function secondListener(event) {
 46 checkMotion(event);
 47 window.removeEventListener('devicemotion', secondListener);
 48
 49 setMockMotion(null, 2.02, null, null, null, null, null, null, null, null);
 50 window.addEventListener('devicemotion', thirdListener);
 51}
 52
 53function thirdListener(event) {
 54 checkMotion(event);
 55 window.removeEventListener('devicemotion', thirdListener);
 56
 57 setMockMotion(null, null, 3.03, null, null, null, null, null, null, null);
 58 window.addEventListener('devicemotion', fourthListener);
 59}
 60
 61function fourthListener(event) {
 62 checkMotion(event);
 63 window.removeEventListener('devicemotion', fourthListener);
 64
 65 setMockMotion(null, null, null, 4.04, null, null, null, null, null, null);
 66 window.addEventListener('devicemotion', fifthListener);
 67}
 68
 69function fifthListener(event) {
 70 checkMotion(event);
 71 window.removeEventListener('devicemotion', fifthListener);
 72
 73 setMockMotion(null, null, null, null, 5.05, null, null, null, null, null);
 74 window.addEventListener('devicemotion', sixthListener);
 75}
 76
 77function sixthListener(event) {
 78 checkMotion(event);
 79 window.removeEventListener('devicemotion', sixthListener);
 80
 81 setMockMotion(null, null, null, null, null, 6.06, null, null, null, null);
 82 window.addEventListener('devicemotion', seventhListener);
 83}
 84
 85function seventhListener(event) {
 86 checkMotion(event);
 87 window.removeEventListener('devicemotion', seventhListener);
 88
 89 setMockMotion(null, null, null, null, null, null, 7.07, null, null, null);
 90 window.addEventListener('devicemotion', eighthListener);
 91}
 92
 93function eighthListener(event) {
 94 checkMotion(event);
 95 window.removeEventListener('devicemotion', eighthListener);
 96
 97 setMockMotion(null, null, null, null, null, null, null, 8.08, null, null);
 98 window.addEventListener('devicemotion', ninthListener);
 99}
 100
 101function ninthListener(event) {
 102 checkMotion(event);
 103 window.removeEventListener('devicemotion', ninthListener);
 104
 105 setMockMotion(null, null, null, null, null, null, null, null, 9.09, null);
 106 window.addEventListener('devicemotion', tenthListener);
 107}
 108
 109function tenthListener(event) {
 110 checkMotion(event);
 111 window.removeEventListener('devicemotion', tenthListener);
 112
 113 setMockMotion(null, null, null, null, null, null, null, null, null, 10.10);
 114 window.addEventListener('devicemotion', eleventhListener);
 115}
 116
 117function eleventhListener(event) {
 118 checkMotion(event);
 119 finishJSTest();
 120}
 121
 122setMockMotion(null, null, null, null, null, null, null, null, null, null);
 123window.addEventListener('devicemotion', firstListener);
 124
 125window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/script-tests/updates.js

 1description('Tests that updates to the motion causes new events to fire.');
 2
 3var mockEvent;
 4function setMockMotion(accelerationX, accelerationY, accelerationZ, accelerationIncludingGravityX, accelerationIncludingGravityY, accelerationIncludingGravityZ, rotationRateAlpha, rotationRateBeta, rotationRateGamma, interval) {
 5 mockEvent = {accelerationX: accelerationX, accelerationY: accelerationY, accelerationZ: accelerationZ, accelerationIncludingGravityX: accelerationIncludingGravityX, accelerationIncludingGravityY: accelerationIncludingGravityY, accelerationIncludingGravityZ: accelerationIncludingGravityZ, rotationRateAlpha: rotationRateAlpha, rotationRateBeta: rotationRateBeta, rotationRateGamma: rotationRateGamma, interval: interval};
 6 if (window.layoutTestController)
 7 layoutTestController.setMockDeviceMotion(
 8 null != mockEvent.accelerationX, null == mockEvent.accelerationX ? 0 : mockEvent.accelerationX,
 9 null != mockEvent.accelerationY, null == mockEvent.accelerationY ? 0 : mockEvent.accelerationY,
 10 null != mockEvent.accelerationZ, null == mockEvent.accelerationZ ? 0 : mockEvent.accelerationZ,
 11 null != mockEvent.accelerationIncludingGravityX, null == mockEvent.accelerationIncludingGravityX ? 0 : mockEvent.accelerationIncludingGravityX,
 12 null != mockEvent.accelerationIncludingGravityY, null == mockEvent.accelerationIncludingGravityY ? 0 : mockEvent.accelerationIncludingGravityY,
 13 null != mockEvent.accelerationIncludingGravityZ, null == mockEvent.accelerationIncludingGravityZ ? 0 : mockEvent.accelerationIncludingGravityZ,
 14 null != mockEvent.rotationRateAlpha, null == mockEvent.rotationRateAlpha ? 0 : mockEvent.rotationRateAlpha,
 15 null != mockEvent.rotationRateBeta, null == mockEvent.rotationRateBeta ? 0 : mockEvent.rotationRateBeta,
 16 null != mockEvent.rotationRateGamma, null == mockEvent.rotationRateGamma ? 0 : mockEvent.rotationRateGamma,
 17 null != mockEvent.interval, null == mockEvent.interval ? 0 : mockEvent.interval);
 18 else
 19 debug('This test can not be run without the LayoutTestController');
 20}
 21
 22var deviceMotionEvent;
 23function checkMotion(event) {
 24 deviceMotionEvent = event;
 25 shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX');
 26 shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY');
 27 shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ');
 28 shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.accelerationIncludingGravityX');
 29 shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.accelerationIncludingGravityY');
 30 shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.accelerationIncludingGravityZ');
 31 shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlpha');
 32 shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta');
 33 shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamma');
 34 shouldBe('deviceMotionEvent.interval', 'mockEvent.interval');
 35}
 36
 37function firstListener(event) {
 38 checkMotion(event);
 39 window.removeEventListener('devicemotion', firstListener);
 40
 41 setMockMotion(11.01, 22.02, 33.03, 44.04, 55.05, 66.06, 77.07, 88.08, 99.09, 110.10);
 42 window.addEventListener('devicemotion', updateListener);
 43}
 44
 45function updateListener(event) {
 46 checkMotion(event);
 47 finishJSTest();
 48}
 49
 50setMockMotion(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.10);
 51window.addEventListener('devicemotion', firstListener);
 52
 53window.jsTestIsAsync = true;

LayoutTests/fast/dom/DeviceMotion/updates-expected.txt

 1Tests that updates to the motion causes new events to fire.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 7PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 8PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 9PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 10PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 11PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 12PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 13PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 14PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 15PASS deviceMotionEvent.interval is mockEvent.interval
 16PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX
 17PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY
 18PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ
 19PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX
 20PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY
 21PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ
 22PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha
 23PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta
 24PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma
 25PASS deviceMotionEvent.interval is mockEvent.interval
 26PASS successfullyParsed is true
 27
 28TEST COMPLETE
 29

LayoutTests/fast/dom/DeviceMotion/updates.html

 1<html>
 2<head>
 3<script src="../../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script src="script-tests/updates.js"></script>
 7<script src="../../js/resources/js-test-post.js"></script>
 8</body>
 9</html>