WebKit Bugzilla
New
Browse
Search+
Log In
×
Sign in with GitHub
or
Remember my login
Create Account
·
Forgot Password
Forgotten password account recovery
[patch]
Patch
bug-89197-20120615141512.patch (text/plain), 114.65 KB, created by
Amy Ousterhout
on 2012-06-15 06:15:13 PDT
(
hide
)
Description:
Patch
Filename:
MIME Type:
Creator:
Amy Ousterhout
Created:
2012-06-15 06:15:13 PDT
Size:
114.65 KB
patch
obsolete
>Subversion Revision: 120435 >diff --git a/Source/WebCore/ChangeLog b/Source/WebCore/ChangeLog >index 6eec6e5242007e39f711fd208e3f2528b61859d1..8c03cd996a74138950264b579e868a8665009857 100644 >--- a/Source/WebCore/ChangeLog >+++ b/Source/WebCore/ChangeLog >@@ -1,3 +1,38 @@ >+2012-06-15 Amy Ousterhout <aousterh@chromium.org> >+ >+ [Chromium] Implemented DeviceMotion >+ https://bugs.webkit.org/show_bug.cgi?id=89197 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Tests: fast/dom/DeviceMotion/add-listener-from-callback.html >+ fast/dom/DeviceMotion/basic-operation.html >+ fast/dom/DeviceMotion/event-after-navigation.html >+ fast/dom/DeviceMotion/multiple-frames.html >+ fast/dom/DeviceMotion/no-synchronous-events.html >+ fast/dom/DeviceMotion/null-values.html >+ fast/dom/DeviceMotion/updates.html >+ >+ Added DeviceMotionClientMock to enable testing of DeviceMotion. >+ >+ * CMakeLists.txt: >+ * GNUmakefile.list.am: >+ * Target.pri: >+ * WebCore.gypi: >+ * platform/mock/DeviceMotionClientMock.cpp: Added. >+ (WebCore): >+ (WebCore::DeviceMotionClientMock::DeviceMotionClientMock): >+ (WebCore::DeviceMotionClientMock::setController): >+ (WebCore::DeviceMotionClientMock::startUpdating): >+ (WebCore::DeviceMotionClientMock::stopUpdating): >+ (WebCore::DeviceMotionClientMock::setMotion): >+ (WebCore::DeviceMotionClientMock::timerFired): >+ * platform/mock/DeviceMotionClientMock.h: Added. >+ (WebCore): >+ (DeviceMotionClientMock): >+ (WebCore::DeviceMotionClientMock::lastMotion): >+ (WebCore::DeviceMotionClientMock::deviceMotionControllerDestroyed): >+ > 2012-06-15 Jian Li <jianli@chromium.org> > > FileReader is dysfunctional in documents with "null" origin string >diff --git a/Source/WebKit/chromium/ChangeLog b/Source/WebKit/chromium/ChangeLog >index 8606c4ff088b7f91c3d0742780f1701e83c638fc..7bb2a66ae7bfd4b8e6fc235b3af6dac3d8cbd6e3 100644 >--- a/Source/WebKit/chromium/ChangeLog >+++ b/Source/WebKit/chromium/ChangeLog >@@ -1,3 +1,106 @@ >+2012-06-15 Amy Ousterhout <aousterh@chromium.org> >+ >+ [Chromium] Implemented DeviceMotion >+ https://bugs.webkit.org/show_bug.cgi?id=89197 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Implemented DeviceMotion in a very similar manner to DeviceOrientation, since they are part of the same spec and work very similarly. >+ >+ * WebKit.gyp: >+ * public/WebDeviceMotion.h: Added. >+ (WebKit): >+ (WebDeviceMotion): >+ (WebKit::WebDeviceMotion::WebDeviceMotion): >+ (WebKit::WebDeviceMotion::nullMotion): >+ (WebKit::WebDeviceMotion::setNull): >+ (WebKit::WebDeviceMotion::isNull): >+ (WebKit::WebDeviceMotion::setAccelerationX): >+ (WebKit::WebDeviceMotion::canProvideAcclerationX): >+ (WebKit::WebDeviceMotion::accelerationX): >+ (WebKit::WebDeviceMotion::setAccelerationY): >+ (WebKit::WebDeviceMotion::canProvideAcclerationY): >+ (WebKit::WebDeviceMotion::accelerationY): >+ (WebKit::WebDeviceMotion::setAccelerationZ): >+ (WebKit::WebDeviceMotion::canProvideAcclerationZ): >+ (WebKit::WebDeviceMotion::accelerationZ): >+ (WebKit::WebDeviceMotion::setAccelerationIncludingGravityX): >+ (WebKit::WebDeviceMotion::canProvideAcclerationIncludingGravityX): >+ (WebKit::WebDeviceMotion::accelerationIncludingGravityX): >+ (WebKit::WebDeviceMotion::setAccelerationIncludingGravityY): >+ (WebKit::WebDeviceMotion::canProvideAcclerationIncludingGravityY): >+ (WebKit::WebDeviceMotion::accelerationIncludingGravityY): >+ (WebKit::WebDeviceMotion::setAccelerationIncludingGravityZ): >+ (WebKit::WebDeviceMotion::canProvideAcclerationIncludingGravityZ): >+ (WebKit::WebDeviceMotion::accelerationIncludingGravityZ): >+ (WebKit::WebDeviceMotion::setRotationRateAlpha): >+ (WebKit::WebDeviceMotion::canProvideRotationRateAlpha): >+ (WebKit::WebDeviceMotion::rotationRateAlpha): >+ (WebKit::WebDeviceMotion::setRotationRateBeta): >+ (WebKit::WebDeviceMotion::canProvideRotationRateBeta): >+ (WebKit::WebDeviceMotion::rotationRateBeta): >+ (WebKit::WebDeviceMotion::setRotationRateGamma): >+ (WebKit::WebDeviceMotion::canProvideRotationRateGamma): >+ (WebKit::WebDeviceMotion::rotationRateGamma): >+ (WebKit::WebDeviceMotion::setInterval): >+ (WebKit::WebDeviceMotion::canProvideInterval): >+ (WebKit::WebDeviceMotion::interval): >+ * public/WebDeviceMotionClient.h: Added. >+ (WebKit): >+ (WebDeviceMotionClient): >+ (WebKit::WebDeviceMotionClient::~WebDeviceMotionClient): >+ * public/WebDeviceMotionClientMock.h: Added. >+ (WebKit): >+ (WebDeviceMotionClientMock): >+ (WebKit::WebDeviceMotionClientMock::~WebDeviceMotionClientMock): >+ (WebKit::WebDeviceMotionClientMock::WebDeviceMotionClientMock): >+ * public/WebDeviceMotionController.h: Added. >+ (WebKit): >+ (WebDeviceMotionController): >+ (WebKit::WebDeviceMotionController::WebDeviceMotionController): >+ * public/WebViewClient.h: >+ (WebKit): >+ (WebViewClient): >+ (WebKit::WebViewClient::deviceMotionClient): >+ * src/DeviceMotionClientProxy.cpp: Added. >+ (WebCore): >+ (WebKit): >+ (WebKit::DeviceMotionClientProxy::setController): >+ (WebKit::DeviceMotionClientProxy::startUpdating): >+ (WebKit::DeviceMotionClientProxy::stopUpdating): >+ (WebKit::DeviceMotionClientProxy::lastMotion): >+ (WebKit::DeviceMotionClientProxy::deviceMotionControllerDestroyed): >+ * src/DeviceMotionClientProxy.h: Added. >+ (WebCore): >+ (WebKit): >+ (DeviceMotionClientProxy): >+ (WebKit::DeviceMotionClientProxy::DeviceMotionClientProxy): >+ * src/WebDeviceMotion.cpp: Added. >+ (WebKit): >+ (WebKit::WebDeviceMotion::WebDeviceMotion): >+ (WebKit::WebDeviceMotion::operator=): >+ (WebKit::WebDeviceMotion::operator PassRefPtr<WebCore::DeviceMotionData>): >+ * src/WebDeviceMotionClientMock.cpp: Added. >+ (WebKit): >+ (WebKit::WebDeviceMotionClientMock::create): >+ (WebKit::WebDeviceMotionClientMock::setController): >+ (WebKit::WebDeviceMotionClientMock::startUpdating): >+ (WebKit::WebDeviceMotionClientMock::stopUpdating): >+ (WebKit::WebDeviceMotionClientMock::lastMotion): >+ (WebKit::WebDeviceMotionClientMock::setMotion): >+ (WebKit::WebDeviceMotionClientMock::initialize): >+ (WebKit::WebDeviceMotionClientMock::reset): >+ * src/WebDeviceMotionController.cpp: Added. >+ (WebKit): >+ (WebKit::WebDeviceMotionController::didChangeDeviceMotion): >+ (WebKit::WebDeviceMotionController::controller): >+ * src/WebDeviceOrientationController.cpp: >+ (WebKit::WebDeviceOrientationController::didChangeDeviceOrientation): Removed a local variable that was a PassRefPtr in order to be consistent with WebDeviceMotionController.cpp and to pass the style check. >+ * src/WebViewImpl.cpp: >+ (WebKit::WebViewImpl::WebViewImpl): >+ * src/WebViewImpl.h: >+ (WebKit): >+ > 2012-06-15 Hironori Bono <hbono@chromium.org> > > Allow platforms to choose whether to remove markers on editing >diff --git a/Source/WebCore/CMakeLists.txt b/Source/WebCore/CMakeLists.txt >index 9ad85bb9422504dc32cd6d1ff88f34683aed46fa..ac19d92f95abefd65bbd25c9655d77490fb1b6dc 100644 >--- a/Source/WebCore/CMakeLists.txt >+++ b/Source/WebCore/CMakeLists.txt >@@ -1247,6 +1247,7 @@ SET(WebCore_SOURCES > platform/graphics/transforms/TransformState.cpp > platform/graphics/transforms/TranslateTransformOperation.cpp > >+ platform/mock/DeviceMotionClientMock.cpp > platform/mock/DeviceOrientationClientMock.cpp > platform/mock/GeolocationClientMock.cpp > platform/mock/ScrollbarThemeMock.cpp >diff --git a/Source/WebCore/GNUmakefile.list.am b/Source/WebCore/GNUmakefile.list.am >index 37b7e5ac2997ea3161e94ac86461a6ce6765b340..a3ea6b111b06b1226818de6a502ab65443529783 100644 >--- a/Source/WebCore/GNUmakefile.list.am >+++ b/Source/WebCore/GNUmakefile.list.am >@@ -3472,6 +3472,8 @@ webcore_sources += \ > Source/WebCore/platform/mediastream/gstreamer/DeprecatedPeerConnectionHandler.cpp \ > Source/WebCore/platform/mediastream/gstreamer/MediaStreamCenterGStreamer.cpp \ > Source/WebCore/platform/mediastream/gstreamer/MediaStreamCenterGStreamer.h \ >+ Source/WebCore/platform/mock/DeviceMotionClientMock.cpp \ >+ Source/WebCore/platform/mock/DeviceMotionClientMock.h \ > Source/WebCore/platform/mock/DeviceOrientationClientMock.cpp \ > Source/WebCore/platform/mock/DeviceOrientationClientMock.h \ > Source/WebCore/platform/mock/GeolocationClientMock.cpp \ >diff --git a/Source/WebCore/Target.pri b/Source/WebCore/Target.pri >index 69baa929fd672c9261648f8b220f57bce67d3fd1..10295a065bf20a9efc23230983aef406b654686f 100644 >--- a/Source/WebCore/Target.pri >+++ b/Source/WebCore/Target.pri >@@ -1163,6 +1163,7 @@ SOURCES += \ > platform/MemoryPressureHandler.cpp \ > platform/MemoryUsageSupport.cpp \ > platform/MIMETypeRegistry.cpp \ >+ platform/mock/DeviceMotionClientMock.cpp \ > platform/mock/DeviceOrientationClientMock.cpp \ > platform/mock/GeolocationClientMock.cpp \ > platform/mock/ScrollbarThemeMock.cpp \ >@@ -2219,6 +2220,7 @@ HEADERS += \ > platform/FileSystem.h \ > platform/HistogramSupport.h \ > platform/image-decoders/ImageDecoder.h \ >+ platform/mock/DeviceMotionClientMock.h \ > platform/mock/DeviceOrientationClientMock.h \ > platform/mock/GeolocationClientMock.cpp \ > platform/mock/ScrollbarThemeMock.h \ >diff --git a/Source/WebCore/WebCore.gypi b/Source/WebCore/WebCore.gypi >index 5bb6dda54dbf96b47dc1cba1395a123a3f660a3a..11ea2c0d5020167b8192cd08c457bfbfeff87958 100644 >--- a/Source/WebCore/WebCore.gypi >+++ b/Source/WebCore/WebCore.gypi >@@ -456,6 +456,7 @@ > 'platform/mediastream/chromium/PeerConnection00Handler.cpp', > 'platform/mediastream/chromium/PeerConnection00HandlerInternal.cpp', > 'platform/mediastream/chromium/PeerConnection00HandlerInternal.h', >+ 'platform/mock/DeviceMotionClientMock.h', > 'platform/mock/DeviceOrientationClientMock.h', > 'platform/mock/GeolocationClientMock.h', > 'platform/network/AuthenticationChallengeBase.h', >@@ -622,6 +623,8 @@ > 'dom/ContextFeatures.cpp', > 'dom/DOMImplementation.h', > 'dom/DOMTimeStamp.h', >+ 'dom/DeviceMotion.h', >+ 'dom/DeviceMotionClient.h', > 'dom/DeviceOrientation.h', > 'dom/DeviceOrientationClient.h', > 'dom/Document.h', >@@ -4336,6 +4339,7 @@ > 'platform/mac/WebCoreView.m', > 'platform/mac/WebFontCache.mm', > 'platform/mac/WidgetMac.mm', >+ 'platform/mock/DeviceMotionClientMock.cpp', > 'platform/mock/DeviceOrientationClientMock.cpp', > 'platform/mock/GeolocationClientMock.cpp', > 'platform/mock/ScrollbarThemeMock.cpp', >diff --git a/Source/WebCore/platform/mock/DeviceMotionClientMock.cpp b/Source/WebCore/platform/mock/DeviceMotionClientMock.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..ecc4b13fd0234435fc81652a08943c8969f14013 >--- /dev/null >+++ b/Source/WebCore/platform/mock/DeviceMotionClientMock.cpp >@@ -0,0 +1,72 @@ >+/* >+ * Copyright (C) 2012 Google 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 "config.h" >+#include "DeviceMotionClientMock.h" >+ >+#include "DeviceMotionController.h" >+ >+namespace WebCore { >+ >+DeviceMotionClientMock::DeviceMotionClientMock() >+ : m_controller(0) >+ , m_timer(this, &DeviceMotionClientMock::timerFired) >+ , m_isUpdating(false) >+{ >+} >+ >+void DeviceMotionClientMock::setController(DeviceMotionController* controller) >+{ >+ ASSERT(!m_controller); >+ m_controller = controller; >+ ASSERT(m_controller); >+} >+ >+void DeviceMotionClientMock::startUpdating() >+{ >+ m_isUpdating = true; >+} >+ >+void DeviceMotionClientMock::stopUpdating() >+{ >+ m_isUpdating = false; >+ m_timer.stop(); >+} >+ >+void DeviceMotionClientMock::setMotion(PassRefPtr<DeviceMotionData> motion) >+{ >+ m_motion = motion; >+ if (m_isUpdating && !m_timer.isActive()) >+ m_timer.startOneShot(0); >+} >+ >+void DeviceMotionClientMock::timerFired(Timer<DeviceMotionClientMock>* timer) >+{ >+ ASSERT_UNUSED(timer, timer == &m_timer); >+ m_timer.stop(); >+ m_controller->didChangeDeviceMotion(m_motion.get()); >+} >+ >+} // namespace WebCore >diff --git a/Source/WebCore/platform/mock/DeviceMotionClientMock.h b/Source/WebCore/platform/mock/DeviceMotionClientMock.h >new file mode 100644 >index 0000000000000000000000000000000000000000..fe957668fd7d41166bd2225a397d64e789c10f84 >--- /dev/null >+++ b/Source/WebCore/platform/mock/DeviceMotionClientMock.h >@@ -0,0 +1,67 @@ >+/* >+ * Copyright (C) 2012 Google 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. >+ */ >+ >+#ifndef DeviceMotionClientMock_h >+#define DeviceMotionClientMock_h >+ >+#include "DeviceMotionClient.h" >+#include "DeviceMotionData.h" >+#include "Timer.h" >+ >+#include <wtf/PassRefPtr.h> >+#include <wtf/RefPtr.h> >+ >+namespace WebCore { >+ >+class DeviceMotionController; >+ >+// A mock implementation of DeviceMotionClient used to test the feature in >+// DumpRenderTree. Embedders should should configure the Page object to use this >+// client when running DumpRenderTree. >+class DeviceMotionClientMock : public DeviceMotionClient { >+public: >+ DeviceMotionClientMock(); >+ >+ // DeviceMotionClient >+ virtual void setController(DeviceMotionController*); >+ virtual void startUpdating(); >+ virtual void stopUpdating(); >+ virtual DeviceMotionData* lastMotion() const { return m_motion.get(); } >+ virtual void deviceMotionControllerDestroyed() { } >+ >+ void setMotion(PassRefPtr<DeviceMotionData>); >+ >+private: >+ void timerFired(Timer<DeviceMotionClientMock>*); >+ >+ RefPtr<DeviceMotionData> m_motion; >+ DeviceMotionController* m_controller; >+ Timer<DeviceMotionClientMock> m_timer; >+ bool m_isUpdating; >+}; >+ >+} // namespace WebCore >+ >+#endif // DeviceMotionClientMock_h >diff --git a/Source/WebKit/chromium/WebKit.gyp b/Source/WebKit/chromium/WebKit.gyp >index 276c5a45efae008b21f74db41a34df40366877f7..99a309d0c11b490b6b7d5acd67bf3b38d2216e44 100644 >--- a/Source/WebKit/chromium/WebKit.gyp >+++ b/Source/WebKit/chromium/WebKit.gyp >@@ -133,6 +133,10 @@ > 'public/WebDevToolsAgentClient.h', > 'public/WebDevToolsFrontend.h', > 'public/WebDevToolsFrontendClient.h', >+ 'public/WebDeviceMotion.h', >+ 'public/WebDeviceMotionClient.h', >+ 'public/WebDeviceMotionClientMock.h', >+ 'public/WebDeviceMotionController.h', > 'public/WebDeviceOrientation.h', > 'public/WebDeviceOrientationClient.h', > 'public/WebDeviceOrientationClientMock.h', >@@ -378,6 +382,8 @@ > 'src/DatabaseObserver.cpp', > 'src/DeliveredIntentClientImpl.cpp', > 'src/DeliveredIntentClientImpl.h', >+ 'src/DeviceMotionClientProxy.cpp', >+ 'src/DeviceMotionClientProxy.h', > 'src/DeviceOrientationClientProxy.cpp', > 'src/DeviceOrientationClientProxy.h', > 'src/DOMUtilitiesPrivate.cpp', >@@ -510,6 +516,9 @@ > 'src/WebDevToolsAgentImpl.h', > 'src/WebDevToolsFrontendImpl.cpp', > 'src/WebDevToolsFrontendImpl.h', >+ 'src/WebDeviceMotion.cpp', >+ 'src/WebDeviceMotionClientMock.cpp', >+ 'src/WebDeviceMotionController.cpp', > 'src/WebDeviceOrientation.cpp', > 'src/WebDeviceOrientationClientMock.cpp', > 'src/WebDeviceOrientationController.cpp', >diff --git a/Source/WebKit/chromium/public/WebDeviceMotion.h b/Source/WebKit/chromium/public/WebDeviceMotion.h >new file mode 100644 >index 0000000000000000000000000000000000000000..fde2a76564865f8e5ef2d74f4cf06034ef18a43c >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebDeviceMotion.h >@@ -0,0 +1,202 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. 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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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. >+ */ >+ >+#ifndef WebDeviceMotion_h >+#define WebDeviceMotion_h >+ >+#if WEBKIT_IMPLEMENTATION >+namespace WTF { template <typename T> class PassRefPtr; } >+namespace WebCore { class DeviceMotionData; } >+#endif >+ >+namespace WebKit { >+ >+class WebDeviceMotion { >+public: >+ WebDeviceMotion() >+ : m_isNull(true) >+ , m_canProvideAccelerationX(false) >+ , m_accelerationX(0) >+ , m_canProvideAccelerationY(false) >+ , m_accelerationY(0) >+ , m_canProvideAccelerationZ(false) >+ , m_accelerationZ(0) >+ , m_canProvideAccelerationIncludingGravityX(false) >+ , m_accelerationIncludingGravityX(0) >+ , m_canProvideAccelerationIncludingGravityY(false) >+ , m_accelerationIncludingGravityY(0) >+ , m_canProvideAccelerationIncludingGravityZ(false) >+ , m_accelerationIncludingGravityZ(0) >+ , m_canProvideRotationRateAlpha(false) >+ , m_rotationRateAlpha(0) >+ , m_canProvideRotationRateBeta(false) >+ , m_rotationRateBeta(0) >+ , m_canProvideRotationRateGamma(false) >+ , m_rotationRateGamma(0) >+ , m_canProvideInterval(false) >+ , m_interval(0) >+ { >+ } >+ >+ static WebDeviceMotion nullMotion() { return WebDeviceMotion(); } >+ >+ void setNull(bool isNull) { m_isNull = isNull; } >+ bool isNull() { return m_isNull; } >+ >+ void setAccelerationX(double accelerationX) >+ { >+ m_canProvideAccelerationX = true; >+ m_accelerationX = accelerationX; >+ } >+ bool canProvideAcclerationX() { return m_canProvideAccelerationX; } >+ double accelerationX() { return m_accelerationX; } >+ >+ void setAccelerationY(double accelerationY) >+ { >+ m_canProvideAccelerationY = true; >+ m_accelerationY = accelerationY; >+ } >+ bool canProvideAcclerationY() { return m_canProvideAccelerationY; } >+ double accelerationY() { return m_accelerationY; } >+ >+ void setAccelerationZ(double accelerationZ) >+ { >+ m_canProvideAccelerationZ = true; >+ m_accelerationZ = accelerationZ; >+ } >+ bool canProvideAcclerationZ() { return m_canProvideAccelerationZ; } >+ double accelerationZ() { return m_accelerationZ; } >+ >+ void setAccelerationIncludingGravityX(double accelerationIncludingGravityX) >+ { >+ m_canProvideAccelerationIncludingGravityX = true; >+ m_accelerationIncludingGravityX = accelerationIncludingGravityX; >+ } >+ bool canProvideAcclerationIncludingGravityX() >+ { >+ return m_canProvideAccelerationIncludingGravityX; >+ } >+ double accelerationIncludingGravityX() >+ { >+ return m_accelerationIncludingGravityX; >+ } >+ >+ void setAccelerationIncludingGravityY(double accelerationIncludingGravityY) >+ { >+ m_canProvideAccelerationIncludingGravityY = true; >+ m_accelerationIncludingGravityY = accelerationIncludingGravityY; >+ } >+ bool canProvideAcclerationIncludingGravityY() >+ { >+ return m_canProvideAccelerationIncludingGravityY; >+ } >+ double accelerationIncludingGravityY() >+ { >+ return m_accelerationIncludingGravityY; >+ } >+ >+ void setAccelerationIncludingGravityZ(double accelerationIncludingGravityZ) >+ { >+ m_canProvideAccelerationIncludingGravityZ = true; >+ m_accelerationIncludingGravityZ = accelerationIncludingGravityZ; >+ } >+ bool canProvideAcclerationIncludingGravityZ() >+ { >+ return m_canProvideAccelerationIncludingGravityZ; >+ } >+ double accelerationIncludingGravityZ() >+ { >+ return m_accelerationIncludingGravityZ; >+ } >+ >+ void setRotationRateAlpha(double rotationRateAlpha) >+ { >+ m_canProvideRotationRateAlpha = true; >+ m_rotationRateAlpha = rotationRateAlpha; >+ } >+ bool canProvideRotationRateAlpha() { return m_canProvideRotationRateAlpha; } >+ double rotationRateAlpha() { return m_rotationRateAlpha; } >+ >+ void setRotationRateBeta(double rotationRateBeta) >+ { >+ m_canProvideRotationRateBeta = true; >+ m_rotationRateBeta = rotationRateBeta; >+ } >+ bool canProvideRotationRateBeta() { return m_canProvideRotationRateBeta; } >+ double rotationRateBeta() { return m_rotationRateBeta; } >+ >+ void setRotationRateGamma(double rotationRateGamma) >+ { >+ m_canProvideRotationRateGamma = true; >+ m_rotationRateGamma = rotationRateGamma; >+ } >+ bool canProvideRotationRateGamma() { return m_canProvideRotationRateGamma; } >+ double rotationRateGamma() { return m_rotationRateGamma; } >+ >+ void setInterval(double interval) >+ { >+ m_canProvideInterval = true; >+ m_interval = interval; >+ } >+ bool canProvideInterval() { return m_canProvideInterval; } >+ double interval() { return m_interval; } >+ >+#if WEBKIT_IMPLEMENTATION >+ WebDeviceMotion(const WTF::PassRefPtr<WebCore::DeviceMotionData>&); >+ WebDeviceMotion& operator=(const WTF::PassRefPtr<WebCore::DeviceMotionData>&); >+ operator WTF::PassRefPtr<WebCore::DeviceMotionData>() const; >+#endif >+ >+private: >+ bool m_isNull; >+ >+ bool m_canProvideAccelerationX; >+ double m_accelerationX; >+ bool m_canProvideAccelerationY; >+ double m_accelerationY; >+ bool m_canProvideAccelerationZ; >+ double m_accelerationZ; >+ >+ bool m_canProvideAccelerationIncludingGravityX; >+ double m_accelerationIncludingGravityX; >+ bool m_canProvideAccelerationIncludingGravityY; >+ double m_accelerationIncludingGravityY; >+ bool m_canProvideAccelerationIncludingGravityZ; >+ double m_accelerationIncludingGravityZ; >+ >+ bool m_canProvideRotationRateAlpha; >+ double m_rotationRateAlpha; >+ bool m_canProvideRotationRateBeta; >+ double m_rotationRateBeta; >+ bool m_canProvideRotationRateGamma; >+ double m_rotationRateGamma; >+ >+ bool m_canProvideInterval; >+ double m_interval; >+}; >+ >+} // namespace WebKit >+ >+#endif // WebDeviceMotion_h >diff --git a/Source/WebKit/chromium/public/WebDeviceMotionClient.h b/Source/WebKit/chromium/public/WebDeviceMotionClient.h >new file mode 100644 >index 0000000000000000000000000000000000000000..a7654462615cf1f3427cf6b1dd1f284805bd44e1 >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebDeviceMotionClient.h >@@ -0,0 +1,47 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. 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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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. >+ */ >+ >+#ifndef WebDeviceMotionClient_h >+#define WebDeviceMotionClient_h >+ >+namespace WebKit { >+ >+class WebDeviceMotion; >+class WebDeviceMotionController; >+ >+class WebDeviceMotionClient { >+public: >+ virtual ~WebDeviceMotionClient() { } >+ >+ virtual void setController(WebDeviceMotionController*) = 0; >+ virtual void startUpdating() = 0; >+ virtual void stopUpdating() = 0; >+ >+ virtual WebDeviceMotion lastMotion() const = 0; >+}; >+ >+} // namespace WebKit >+ >+#endif // WebDeviceMotionClient_h >diff --git a/Source/WebKit/chromium/public/WebDeviceMotionClientMock.h b/Source/WebKit/chromium/public/WebDeviceMotionClientMock.h >new file mode 100644 >index 0000000000000000000000000000000000000000..67006d98155896e4c31feaa9455b6bdf4d19da66 >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebDeviceMotionClientMock.h >@@ -0,0 +1,59 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. 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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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. >+ */ >+ >+#ifndef WebDeviceMotionClientMock_h >+#define WebDeviceMotionClientMock_h >+ >+#include "WebDeviceMotionClient.h" >+#include "platform/WebCommon.h" >+#include "platform/WebPrivateOwnPtr.h" >+ >+namespace WebCore { class DeviceMotionClientMock; } >+ >+namespace WebKit { >+ >+class WebDeviceMotionClientMock : public WebDeviceMotionClient { >+public: >+ WEBKIT_EXPORT static WebDeviceMotionClientMock* create(); >+ ~WebDeviceMotionClientMock() { reset(); } >+ >+ virtual void setController(WebDeviceMotionController*); >+ virtual void startUpdating(); >+ virtual void stopUpdating(); >+ virtual WebDeviceMotion lastMotion() const; >+ >+ WEBKIT_EXPORT void setMotion(WebDeviceMotion&); >+ >+private: >+ WebDeviceMotionClientMock() { initialize(); } >+ WEBKIT_EXPORT void initialize(); >+ WEBKIT_EXPORT void reset(); >+ >+ WebPrivateOwnPtr<WebCore::DeviceMotionClientMock> m_clientMock; >+}; >+ >+} // namespace WebKit >+ >+#endif // WebDeviceMotionClientMock_h >diff --git a/Source/WebKit/chromium/public/WebDeviceMotionController.h b/Source/WebKit/chromium/public/WebDeviceMotionController.h >new file mode 100644 >index 0000000000000000000000000000000000000000..aa1981d9ec277109d61b88205e13052e55cdc345 >--- /dev/null >+++ b/Source/WebKit/chromium/public/WebDeviceMotionController.h >@@ -0,0 +1,56 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. 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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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. >+ */ >+ >+#ifndef WebDeviceMotionController_h >+#define WebDeviceMotionController_h >+ >+#include "platform/WebCommon.h" >+ >+namespace WebCore { class DeviceMotionController; } >+ >+namespace WebKit { >+ >+class WebDeviceMotion; >+ >+class WebDeviceMotionController { >+public: >+ WebDeviceMotionController(WebCore::DeviceMotionController* c) >+ : m_controller(c) >+ { >+ } >+ >+ WEBKIT_EXPORT void didChangeDeviceMotion(const WebDeviceMotion&); >+ >+#if WEBKIT_IMPLEMENTATION >+ WebCore::DeviceMotionController* controller() const; >+#endif >+ >+private: >+ WebCore::DeviceMotionController* m_controller; >+}; >+ >+} // namespace WebKit >+ >+#endif // WebDeviceMotionController_h >diff --git a/Source/WebKit/chromium/public/WebViewClient.h b/Source/WebKit/chromium/public/WebViewClient.h >index 9b39da7dd1988365b6a422e3fae21d01b187813c..2f35f4549e41777f717b56d1b6ec9df0b12a8da5 100644 >--- a/Source/WebKit/chromium/public/WebViewClient.h >+++ b/Source/WebKit/chromium/public/WebViewClient.h >@@ -51,6 +51,7 @@ class WebAccessibilityObject; > class WebBatteryStatusClient; > class WebColorChooser; > class WebColorChooserClient; >+class WebDeviceMotionClient; > class WebDeviceOrientationClient; > class WebDragData; > class WebElement; >@@ -325,6 +326,11 @@ public: > // Access the embedder API for speech recognition services. > virtual WebSpeechRecognizer* speechRecognizer() { return 0; } > >+ // Device Motion -------------------------------------------------- >+ >+ // Access the embedder API for device motion services. >+ virtual WebDeviceMotionClient* deviceMotionClient() { return 0; } >+ > // Device Orientation -------------------------------------------------- > > // Access the embedder API for device orientation services. >diff --git a/Source/WebKit/chromium/src/DeviceMotionClientProxy.cpp b/Source/WebKit/chromium/src/DeviceMotionClientProxy.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..7c0319e0302ca0a071d9ba79c15a35e589f478b8 >--- /dev/null >+++ b/Source/WebKit/chromium/src/DeviceMotionClientProxy.cpp >@@ -0,0 +1,79 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. 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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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 "config.h" >+#include "DeviceMotionClientProxy.h" >+ >+#include "DeviceMotionData.h" >+#include "WebDeviceMotion.h" >+#include "WebDeviceMotionController.h" >+#include <wtf/OwnPtr.h> >+#include <wtf/PassRefPtr.h> >+#include <wtf/RefPtr.h> >+ >+namespace WebCore { >+class DeviceMotionController; >+} >+ >+namespace WebKit { >+ >+void DeviceMotionClientProxy::setController(WebCore::DeviceMotionController* c) >+{ >+ if (!m_client) // FIXME: Get rid of these null checks once device motion is enabled by default. >+ return; >+ m_client->setController(new WebDeviceMotionController(c)); >+} >+ >+void DeviceMotionClientProxy::startUpdating() >+{ >+ if (!m_client) >+ return; >+ m_client->startUpdating(); >+} >+ >+void DeviceMotionClientProxy::stopUpdating() >+{ >+ if (!m_client) >+ return; >+ m_client->stopUpdating(); >+} >+ >+WebCore::DeviceMotionData* DeviceMotionClientProxy::lastMotion() const >+{ >+ if (!m_client) >+ return 0; >+ >+ // Cache the DeviceMotion pointer so its reference count does not drop to zero upon return. >+ m_lastMotion = m_client->lastMotion(); >+ >+ return m_lastMotion.get(); >+} >+ >+void DeviceMotionClientProxy::deviceMotionControllerDestroyed() >+{ >+ // Our lifetime is bound to the WebViewImpl. >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/chromium/src/DeviceMotionClientProxy.h b/Source/WebKit/chromium/src/DeviceMotionClientProxy.h >new file mode 100644 >index 0000000000000000000000000000000000000000..f443f7944fd4d79952de6c678aa5dda812cadede >--- /dev/null >+++ b/Source/WebKit/chromium/src/DeviceMotionClientProxy.h >@@ -0,0 +1,60 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. 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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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. >+ */ >+ >+#ifndef DeviceMotionClientProxy_h >+#define DeviceMotionClientProxy_h >+ >+#include "DeviceMotionClient.h" >+#include "DeviceMotionData.h" >+#include "WebDeviceMotionClient.h" >+#include <wtf/RefPtr.h> >+ >+namespace WebCore { >+class DeviceMotionController; >+} >+ >+namespace WebKit { >+ >+class DeviceMotionClientProxy : public WebCore::DeviceMotionClient { >+public: >+ DeviceMotionClientProxy(WebDeviceMotionClient* client) >+ : m_client(client) >+ { >+ } >+ >+ void setController(WebCore::DeviceMotionController*); >+ void startUpdating(); >+ void stopUpdating(); >+ WebCore::DeviceMotionData* lastMotion() const; >+ virtual void deviceMotionControllerDestroyed(); >+ >+private: >+ WebDeviceMotionClient* m_client; >+ mutable RefPtr<WebCore::DeviceMotionData> m_lastMotion; >+}; >+ >+} // namespace WebKit >+ >+#endif // DeviceMotionClientProxy_h >diff --git a/Source/WebKit/chromium/src/WebDeviceMotion.cpp b/Source/WebKit/chromium/src/WebDeviceMotion.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..c016da8005f3d2b788fa34d2d5710231737e3b30 >--- /dev/null >+++ b/Source/WebKit/chromium/src/WebDeviceMotion.cpp >@@ -0,0 +1,221 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. 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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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 "config.h" >+#include "WebDeviceMotion.h" >+ >+#include "DeviceMotionData.h" >+#include <wtf/PassRefPtr.h> >+ >+namespace WebKit { >+ >+WebDeviceMotion::WebDeviceMotion(const PassRefPtr<WebCore::DeviceMotionData>& motion) >+{ >+ if (!motion) { >+ m_isNull = true; >+ m_canProvideAccelerationX = false; >+ m_accelerationX = 0; >+ m_canProvideAccelerationY = false; >+ m_accelerationY = 0; >+ m_canProvideAccelerationZ = false; >+ m_accelerationZ = 0; >+ m_canProvideAccelerationIncludingGravityX = false; >+ m_accelerationIncludingGravityX = 0; >+ m_canProvideAccelerationIncludingGravityY = false; >+ m_accelerationIncludingGravityY = 0; >+ m_canProvideAccelerationIncludingGravityZ = false; >+ m_accelerationIncludingGravityZ = 0; >+ m_canProvideRotationRateAlpha = false; >+ m_rotationRateAlpha = 0; >+ m_canProvideRotationRateBeta = false; >+ m_rotationRateBeta = 0; >+ m_canProvideRotationRateGamma = false; >+ m_rotationRateGamma = 0; >+ m_canProvideInterval = false; >+ m_interval = 0; >+ return; >+ } >+ >+ m_isNull = false; >+ >+ const WebCore::DeviceMotionData::Acceleration* acceleration = motion->acceleration(); >+ if (!acceleration) { >+ m_canProvideAccelerationX = false; >+ m_accelerationX = 0; >+ m_canProvideAccelerationY = false; >+ m_accelerationY = 0; >+ m_canProvideAccelerationZ = false; >+ m_accelerationZ = 0; >+ } else { >+ m_canProvideAccelerationX = acceleration->canProvideX(); >+ m_accelerationX = acceleration->x(); >+ m_canProvideAccelerationY = acceleration->canProvideY(); >+ m_accelerationY = acceleration->y(); >+ m_canProvideAccelerationZ = acceleration->canProvideZ(); >+ m_accelerationZ = acceleration->z(); >+ } >+ >+ const WebCore::DeviceMotionData::Acceleration* accelerationIncludingGravity = >+ motion->accelerationIncludingGravity(); >+ if (!accelerationIncludingGravity) { >+ m_canProvideAccelerationIncludingGravityX = false; >+ m_accelerationIncludingGravityX = 0; >+ m_canProvideAccelerationIncludingGravityY = false; >+ m_accelerationIncludingGravityY = 0; >+ m_canProvideAccelerationIncludingGravityZ = false; >+ m_accelerationIncludingGravityZ = 0; >+ } else { >+ m_canProvideAccelerationIncludingGravityX = accelerationIncludingGravity->canProvideX(); >+ m_accelerationIncludingGravityX = accelerationIncludingGravity->x(); >+ m_canProvideAccelerationIncludingGravityY = accelerationIncludingGravity->canProvideY(); >+ m_accelerationIncludingGravityY = accelerationIncludingGravity->y(); >+ m_canProvideAccelerationIncludingGravityZ = accelerationIncludingGravity->canProvideZ(); >+ m_accelerationIncludingGravityZ = accelerationIncludingGravity->z(); >+ } >+ >+ const WebCore::DeviceMotionData::RotationRate* rotationRate = motion->rotationRate(); >+ if (!rotationRate) { >+ m_canProvideRotationRateAlpha = false; >+ m_rotationRateAlpha = 0; >+ m_canProvideRotationRateBeta = false; >+ m_rotationRateBeta = 0; >+ m_canProvideRotationRateGamma = false; >+ m_rotationRateGamma = 0; >+ } else { >+ m_canProvideRotationRateAlpha = rotationRate->canProvideAlpha(); >+ m_rotationRateAlpha = rotationRate->alpha(); >+ m_canProvideRotationRateBeta = rotationRate->canProvideBeta(); >+ m_rotationRateBeta = rotationRate->beta(); >+ m_canProvideRotationRateGamma = rotationRate->canProvideGamma(); >+ m_rotationRateGamma = rotationRate->gamma(); >+ } >+ >+ m_canProvideInterval = motion->canProvideInterval(); >+ m_interval = motion->interval(); >+} >+ >+WebDeviceMotion& WebDeviceMotion::operator=(const PassRefPtr<WebCore::DeviceMotionData>& motion) >+{ >+ if (!motion) { >+ m_isNull = true; >+ m_canProvideAccelerationX = false; >+ m_accelerationX = 0; >+ m_canProvideAccelerationY = false; >+ m_accelerationY = 0; >+ m_canProvideAccelerationZ = false; >+ m_accelerationZ = 0; >+ m_canProvideAccelerationIncludingGravityX = false; >+ m_accelerationIncludingGravityX = 0; >+ m_canProvideAccelerationIncludingGravityY = false; >+ m_accelerationIncludingGravityY = 0; >+ m_canProvideAccelerationIncludingGravityZ = false; >+ m_accelerationIncludingGravityZ = 0; >+ m_canProvideRotationRateAlpha = false; >+ m_rotationRateAlpha = 0; >+ m_canProvideRotationRateBeta = false; >+ m_rotationRateBeta = 0; >+ m_canProvideRotationRateGamma = false; >+ m_rotationRateGamma = 0; >+ m_canProvideInterval = false; >+ m_interval = 0; >+ return *this; >+ } >+ >+ m_isNull = false; >+ >+ const WebCore::DeviceMotionData::Acceleration* acceleration = motion->acceleration(); >+ if (!acceleration) { >+ m_canProvideAccelerationX = false; >+ m_accelerationX = 0; >+ m_canProvideAccelerationY = false; >+ m_accelerationY = 0; >+ m_canProvideAccelerationZ = false; >+ m_accelerationZ = 0; >+ } else { >+ m_canProvideAccelerationX = acceleration->canProvideX(); >+ m_accelerationX = acceleration->x(); >+ m_canProvideAccelerationY = acceleration->canProvideY(); >+ m_accelerationY = acceleration->y(); >+ m_canProvideAccelerationZ = acceleration->canProvideZ(); >+ m_accelerationZ = acceleration->z(); >+ } >+ >+ const WebCore::DeviceMotionData::Acceleration* accelerationIncludingGravity = >+ motion->accelerationIncludingGravity(); >+ if (!accelerationIncludingGravity) { >+ m_canProvideAccelerationIncludingGravityX = false; >+ m_accelerationIncludingGravityX = 0; >+ m_canProvideAccelerationIncludingGravityY = false; >+ m_accelerationIncludingGravityY = 0; >+ m_canProvideAccelerationIncludingGravityZ = false; >+ m_accelerationIncludingGravityZ = 0; >+ } else { >+ m_canProvideAccelerationX = acceleration->canProvideX(); >+ m_accelerationX = acceleration->x(); >+ m_canProvideAccelerationY = acceleration->canProvideY(); >+ m_accelerationY = acceleration->y(); >+ m_canProvideAccelerationZ = acceleration->canProvideZ(); >+ m_accelerationZ = acceleration->z(); >+ } >+ >+ const WebCore::DeviceMotionData::RotationRate* rotationRate = motion->rotationRate(); >+ if (!rotationRate) { >+ m_canProvideRotationRateAlpha = false; >+ m_rotationRateAlpha = 0; >+ m_canProvideRotationRateBeta = false; >+ m_rotationRateBeta = 0; >+ m_canProvideRotationRateGamma = false; >+ m_rotationRateGamma = 0; >+ } else { >+ m_canProvideRotationRateAlpha = rotationRate->canProvideAlpha(); >+ m_rotationRateAlpha = rotationRate->alpha(); >+ m_canProvideRotationRateBeta = rotationRate->canProvideBeta(); >+ m_rotationRateBeta = rotationRate->beta(); >+ m_canProvideRotationRateGamma = rotationRate->canProvideGamma(); >+ m_rotationRateGamma = rotationRate->gamma(); >+ } >+ >+ m_canProvideInterval = motion->canProvideInterval(); >+ m_interval = motion->interval(); >+ >+ return *this; >+} >+ >+WebDeviceMotion::operator PassRefPtr<WebCore::DeviceMotionData>() const >+{ >+ if (m_isNull) >+ return 0; >+ >+ RefPtr<WebCore::DeviceMotionData::Acceleration> acceleration = >+ WebCore::DeviceMotionData::Acceleration::create(m_canProvideAccelerationX, m_accelerationX, m_canProvideAccelerationY, m_accelerationY, m_canProvideAccelerationZ, m_accelerationZ); >+ RefPtr<WebCore::DeviceMotionData::Acceleration> accelerationIncludingGravity = >+ WebCore::DeviceMotionData::Acceleration::create(m_canProvideAccelerationIncludingGravityX, m_accelerationIncludingGravityX, m_canProvideAccelerationIncludingGravityY, m_accelerationIncludingGravityY, m_canProvideAccelerationIncludingGravityZ, m_accelerationIncludingGravityZ); >+ RefPtr<WebCore::DeviceMotionData::RotationRate> rotationRate = >+ WebCore::DeviceMotionData::RotationRate::create(m_canProvideRotationRateAlpha, m_rotationRateAlpha, m_canProvideRotationRateBeta, m_rotationRateBeta, m_canProvideRotationRateGamma, m_rotationRateGamma); >+ >+ return WebCore::DeviceMotionData::create(acceleration, accelerationIncludingGravity, rotationRate, m_canProvideInterval, m_interval); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebDeviceMotionClientMock.cpp b/Source/WebKit/chromium/src/WebDeviceMotionClientMock.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..da6fa7d3836377d21244c81640c6573205bf4e3e >--- /dev/null >+++ b/Source/WebKit/chromium/src/WebDeviceMotionClientMock.cpp >@@ -0,0 +1,76 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. 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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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 "config.h" >+#include "WebDeviceMotionClientMock.h" >+ >+#include "DeviceMotionClientMock.h" >+#include "WebDeviceMotion.h" >+#include "WebDeviceMotionController.h" >+ >+namespace WebKit { >+ >+WebDeviceMotionClientMock* WebDeviceMotionClientMock::create() >+{ >+ return new WebDeviceMotionClientMock(); >+} >+ >+void WebDeviceMotionClientMock::setController(WebDeviceMotionController* controller) >+{ >+ m_clientMock->setController(controller->controller()); >+ delete controller; >+} >+ >+void WebDeviceMotionClientMock::startUpdating() >+{ >+ m_clientMock->startUpdating(); >+} >+ >+void WebDeviceMotionClientMock::stopUpdating() >+{ >+ m_clientMock->stopUpdating(); >+} >+ >+WebDeviceMotion WebDeviceMotionClientMock::lastMotion() const >+{ >+ return WebDeviceMotion(m_clientMock->lastMotion()); >+} >+ >+void WebDeviceMotionClientMock::setMotion(WebDeviceMotion& motion) >+{ >+ m_clientMock->setMotion(motion); >+} >+ >+void WebDeviceMotionClientMock::initialize() >+{ >+ m_clientMock.reset(new WebCore::DeviceMotionClientMock()); >+} >+ >+void WebDeviceMotionClientMock::reset() >+{ >+ m_clientMock.reset(0); >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebDeviceMotionController.cpp b/Source/WebKit/chromium/src/WebDeviceMotionController.cpp >new file mode 100644 >index 0000000000000000000000000000000000000000..c18824270e52a85580e5ee6307be0a3fbcf93d46 >--- /dev/null >+++ b/Source/WebKit/chromium/src/WebDeviceMotionController.cpp >@@ -0,0 +1,46 @@ >+/* >+ * Copyright (C) 2012 Google 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: >+ * >+ * 1. Redistributions of source code must retain the above copyright >+ * notice, this list of conditions and the following disclaimer. >+ * 2. 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 APPLE AND ITS CONTRIBUTORS "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 APPLE OR ITS 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 "config.h" >+#include "WebDeviceMotionController.h" >+ >+#include "DeviceMotionController.h" >+#include "DeviceMotionData.h" >+#include "WebDeviceMotion.h" >+#include <wtf/PassRefPtr.h> >+ >+namespace WebKit { >+ >+void WebDeviceMotionController::didChangeDeviceMotion(const WebDeviceMotion& motion) >+{ >+ m_controller->didChangeDeviceMotion(static_cast<PassRefPtr<WebCore::DeviceMotionData> >(motion).get()); >+} >+ >+WebCore::DeviceMotionController* WebDeviceMotionController::controller() const >+{ >+ return m_controller; >+} >+ >+} // namespace WebKit >diff --git a/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp b/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp >index aa9249f76710f870c03bd391d1fe1c8713fe2fb2..537f0654302e8b475b25c85e0d1badfc5b238637 100644 >--- a/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp >+++ b/Source/WebKit/chromium/src/WebDeviceOrientationController.cpp >@@ -35,8 +35,7 @@ namespace WebKit { > > void WebDeviceOrientationController::didChangeDeviceOrientation(const WebDeviceOrientation& orientation) > { >- PassRefPtr<WebCore::DeviceOrientation> deviceOrientation(orientation); >- m_controller->didChangeDeviceOrientation(deviceOrientation.get()); >+ m_controller->didChangeDeviceOrientation(static_cast<PassRefPtr<WebCore::DeviceOrientation> >(orientation).get()); > } > > WebCore::DeviceOrientationController* WebDeviceOrientationController::controller() const >diff --git a/Source/WebKit/chromium/src/WebViewImpl.cpp b/Source/WebKit/chromium/src/WebViewImpl.cpp >index 3d3226560a372b53a5f343bd8b048fdf26ed2877..ed2b31a014f51d3ae92590300c3360306c4ce484 100644 >--- a/Source/WebKit/chromium/src/WebViewImpl.cpp >+++ b/Source/WebKit/chromium/src/WebViewImpl.cpp >@@ -47,6 +47,7 @@ > #include "ContextMenuItem.h" > #include "Cursor.h" > #include "DOMUtilitiesPrivate.h" >+#include "DeviceMotionClientProxy.h" > #include "DeviceOrientationClientProxy.h" > #include "Document.h" > #include "DocumentLoader.h" >@@ -416,6 +417,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) > #if ENABLE(SCRIPTED_SPEECH) > , m_speechRecognitionClient(SpeechRecognitionClientProxy::create(client ? client->speechRecognizer() : 0)) > #endif >+ , m_deviceMotionClientProxy(adoptPtr(new DeviceMotionClientProxy(client ? client->deviceMotionClient() : 0))) > , m_deviceOrientationClientProxy(adoptPtr(new DeviceOrientationClientProxy(client ? client->deviceOrientationClient() : 0))) > , m_geolocationClientProxy(adoptPtr(new GeolocationClientProxy(client ? client->geolocationClient() : 0))) > #if ENABLE(BATTERY_STATUS) >@@ -456,6 +458,7 @@ WebViewImpl::WebViewImpl(WebViewClient* client) > #endif > > provideContextFeaturesTo(m_page.get(), m_featureSwitchClient.get()); >+ provideDeviceMotionTo(m_page.get(), m_deviceMotionClientProxy.get()); > provideDeviceOrientationTo(m_page.get(), m_deviceOrientationClientProxy.get()); > provideGeolocationTo(m_page.get(), m_geolocationClientProxy.get()); > m_geolocationClientProxy->setController(GeolocationController::from(m_page.get())); >diff --git a/Source/WebKit/chromium/src/WebViewImpl.h b/Source/WebKit/chromium/src/WebViewImpl.h >index 4f5c048d97742ad59b15ecb343d85c8d3a03186f..e76fd8f23ec4bcf3531a7f8c0f48cfad4ab6e845 100644 >--- a/Source/WebKit/chromium/src/WebViewImpl.h >+++ b/Source/WebKit/chromium/src/WebViewImpl.h >@@ -88,6 +88,7 @@ class AutofillPopupMenuClient; > class BatteryClientImpl; > class ContextFeaturesClientImpl; > class ContextMenuClientImpl; >+class DeviceMotionClientProxy; > class DeviceOrientationClientProxy; > class DragScrollTimer; > class GeolocationClientProxy; >@@ -812,6 +813,7 @@ private: > // the compositor has been turned on, we need to instantiate it > // early. This member holds on to the GC3D in this case. > OwnPtr<WebGraphicsContext3D> m_temporaryOnscreenGraphicsContext3D; >+ OwnPtr<DeviceMotionClientProxy> m_deviceMotionClientProxy; > OwnPtr<DeviceOrientationClientProxy> m_deviceOrientationClientProxy; > OwnPtr<GeolocationClientProxy> m_geolocationClientProxy; > #if ENABLE(BATTERY_STATUS) >diff --git a/Tools/ChangeLog b/Tools/ChangeLog >index 4d261a20197b16c5d8417600dfb87b3b31674fc2..871c75858340356b861f10a517dc099c26b265fc 100644 >--- a/Tools/ChangeLog >+++ b/Tools/ChangeLog >@@ -1,3 +1,24 @@ >+2012-06-15 Amy Ousterhout <aousterh@chromium.org> >+ >+ [Chromium] Implemented DeviceMotion >+ https://bugs.webkit.org/show_bug.cgi?id=89197 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added functionality for testing DeviceMotion using WebDeviceMotionClientMock. >+ >+ * DumpRenderTree/chromium/LayoutTestController.cpp: >+ (LayoutTestController::LayoutTestController): >+ (LayoutTestController::setMockDeviceMotion): >+ * DumpRenderTree/chromium/LayoutTestController.h: >+ (LayoutTestController): >+ * DumpRenderTree/chromium/WebViewHost.cpp: >+ (WebViewHost::deviceMotionClientMock): >+ (WebViewHost::deviceMotionClient): >+ * DumpRenderTree/chromium/WebViewHost.h: >+ (WebKit): >+ (WebViewHost): >+ > 2012-06-15 Christophe Dumez <christophe.dumez@intel.com> > > [EFL] EFL's LayoutTestController does not support titleTextDirection >diff --git a/Tools/DumpRenderTree/chromium/LayoutTestController.cpp b/Tools/DumpRenderTree/chromium/LayoutTestController.cpp >index 1f64d65afddbe83b5d1ffb5ef8cc11975c181ffb..29692ad7332b755d8f9cb2383aa36f78f8238de3 100644 >--- a/Tools/DumpRenderTree/chromium/LayoutTestController.cpp >+++ b/Tools/DumpRenderTree/chromium/LayoutTestController.cpp >@@ -41,6 +41,8 @@ > #include "WebWorkerInfo.h" > #include "WebConsoleMessage.h" > #include "platform/WebData.h" >+#include "WebDeviceMotion.h" >+#include "WebDeviceMotionClientMock.h" > #include "WebDeviceOrientation.h" > #include "WebDeviceOrientationClientMock.h" > #include "WebDocument.h" >@@ -205,6 +207,7 @@ LayoutTestController::LayoutTestController(TestShell* shell) > bindMethod("setIconDatabaseEnabled", &LayoutTestController::setIconDatabaseEnabled); > bindMethod("setJavaScriptCanAccessClipboard", &LayoutTestController::setJavaScriptCanAccessClipboard); > bindMethod("setMinimumTimerInterval", &LayoutTestController::setMinimumTimerInterval); >+ bindMethod("setMockDeviceMotion", &LayoutTestController::setMockDeviceMotion); > bindMethod("setMockDeviceOrientation", &LayoutTestController::setMockDeviceOrientation); > bindMethod("setMockGeolocationError", &LayoutTestController::setMockGeolocationError); > bindMethod("setMockGeolocationPosition", &LayoutTestController::setMockGeolocationPosition); >@@ -1866,6 +1869,44 @@ void LayoutTestController::addUserStyleSheet(const CppArgumentList& arguments, C > WebView::UserStyleInjectInExistingDocuments); > } > >+void LayoutTestController::setMockDeviceMotion(const CppArgumentList& arguments, CppVariant* result) >+{ >+ result->setNull(); >+ 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()) >+ return; >+ >+ WebDeviceMotion motion; >+ motion.setNull(false); >+ if (arguments[0].toBoolean()) >+ motion.setAccelerationX(arguments[1].toDouble()); >+ if (arguments[2].toBoolean()) >+ motion.setAccelerationY(arguments[3].toDouble()); >+ if (arguments[4].toBoolean()) >+ motion.setAccelerationZ(arguments[5].toDouble()); >+ >+ if (arguments[6].toBoolean()) >+ motion.setAccelerationIncludingGravityX(arguments[7].toDouble()); >+ if (arguments[8].toBoolean()) >+ motion.setAccelerationIncludingGravityY(arguments[9].toDouble()); >+ if (arguments[10].toBoolean()) >+ motion.setAccelerationIncludingGravityZ(arguments[11].toDouble()); >+ >+ if (arguments[12].toBoolean()) >+ motion.setRotationRateAlpha(arguments[13].toDouble()); >+ if (arguments[14].toBoolean()) >+ motion.setRotationRateBeta(arguments[15].toDouble()); >+ if (arguments[16].toBoolean()) >+ motion.setRotationRateGamma(arguments[17].toDouble()); >+ >+ if (arguments[18].toBoolean()) >+ motion.setInterval(arguments[19].toDouble()); >+ >+ // Note that we only call setMotion on the main page's mock since this is all that the >+ // tests require. If necessary, we could get a list of WebViewHosts from the TestShell and >+ // call setMotion on each DeviceMotionClientMock. >+ m_shell->webViewHost()->deviceMotionClientMock()->setMotion(motion); >+} >+ > void LayoutTestController::setMockDeviceOrientation(const CppArgumentList& arguments, CppVariant* result) > { > result->setNull(); >diff --git a/Tools/DumpRenderTree/chromium/LayoutTestController.h b/Tools/DumpRenderTree/chromium/LayoutTestController.h >index 5a872938887a2b211610b8c6c651be1b6ea9a55b..4eefef801366cda8b763aa4261ee32a87164d942 100644 >--- a/Tools/DumpRenderTree/chromium/LayoutTestController.h >+++ b/Tools/DumpRenderTree/chromium/LayoutTestController.h >@@ -356,6 +356,9 @@ public: > void addUserScript(const CppArgumentList&, CppVariant*); > void addUserStyleSheet(const CppArgumentList&, CppVariant*); > >+ // DeviceMotion related functions >+ void setMockDeviceMotion(const CppArgumentList&, CppVariant*); >+ > // DeviceOrientation related functions > void setMockDeviceOrientation(const CppArgumentList&, CppVariant*); > >diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.cpp b/Tools/DumpRenderTree/chromium/WebViewHost.cpp >index c861308e0833f0479247f2a27d1676808814a6b5..1ea767accb65b659790a8ac1aa9e846331bb9442 100644 >--- a/Tools/DumpRenderTree/chromium/WebViewHost.cpp >+++ b/Tools/DumpRenderTree/chromium/WebViewHost.cpp >@@ -43,6 +43,7 @@ > #include "WebContextMenuData.h" > #include "WebDOMMessageEvent.h" > #include "WebDataSource.h" >+#include "WebDeviceMotionClientMock.h" > #include "WebDeviceOrientationClientMock.h" > #include "WebDocument.h" > #include "platform/WebDragData.h" >@@ -751,6 +752,13 @@ WebSpeechRecognizer* WebViewHost::speechRecognizer() > } > #endif > >+WebDeviceMotionClientMock* WebViewHost::deviceMotionClientMock() >+{ >+ if (!m_deviceMotionClientMock.get()) >+ m_deviceMotionClientMock = adoptPtr(WebDeviceMotionClientMock::create()); >+ return m_deviceMotionClientMock.get(); >+} >+ > WebDeviceOrientationClientMock* WebViewHost::deviceOrientationClientMock() > { > if (!m_deviceOrientationClientMock.get()) >@@ -763,6 +771,11 @@ MockSpellCheck* WebViewHost::mockSpellCheck() > return &m_spellcheck; > } > >+WebDeviceMotionClient* WebViewHost::deviceMotionClient() >+{ >+ return deviceMotionClientMock(); >+} >+ > WebDeviceOrientationClient* WebViewHost::deviceOrientationClient() > { > return deviceOrientationClientMock(); >diff --git a/Tools/DumpRenderTree/chromium/WebViewHost.h b/Tools/DumpRenderTree/chromium/WebViewHost.h >index e613bfa094bb1966be8b8738c4a31e0a2e62373b..5bb175500cb08e0909de89e2d7dfeb5af8954e72 100644 >--- a/Tools/DumpRenderTree/chromium/WebViewHost.h >+++ b/Tools/DumpRenderTree/chromium/WebViewHost.h >@@ -54,6 +54,8 @@ class TestShell; > > namespace WebKit { > class WebFrame; >+class WebDeviceMotionClient; >+class WebDeviceMotionClientMock; > class WebDeviceOrientationClient; > class WebDeviceOrientationClientMock; > class WebGeolocationClient; >@@ -185,6 +187,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, > #if ENABLE(SCRIPTED_SPEECH) > virtual WebKit::WebSpeechRecognizer* speechRecognizer() OVERRIDE; > #endif >+ virtual WebKit::WebDeviceMotionClient* deviceMotionClient(); > virtual WebKit::WebDeviceOrientationClient* deviceOrientationClient(); > #if ENABLE(MEDIA_STREAM) > virtual WebKit::WebUserMediaClient* userMediaClient(); >@@ -266,6 +269,7 @@ class WebViewHost : public WebKit::WebViewClient, public WebKit::WebFrameClient, > virtual void deliveredIntentResult(WebKit::WebFrame*, int, const WebKit::WebSerializedScriptValue&); > virtual void deliveredIntentFailure(WebKit::WebFrame*, int, const WebKit::WebSerializedScriptValue&); > >+ WebKit::WebDeviceMotionClientMock* deviceMotionClientMock(); > WebKit::WebDeviceOrientationClientMock* deviceOrientationClientMock(); > > // Spellcheck related helper APIs >@@ -416,6 +420,7 @@ private: > // Geolocation > OwnPtr<WebKit::WebGeolocationClientMock> m_geolocationClientMock; > >+ OwnPtr<WebKit::WebDeviceMotionClientMock> m_deviceMotionClientMock; > OwnPtr<WebKit::WebDeviceOrientationClientMock> m_deviceOrientationClientMock; > #if ENABLE(INPUT_SPEECH) > OwnPtr<MockWebSpeechInputController> m_speechInputControllerMock; >diff --git a/LayoutTests/ChangeLog b/LayoutTests/ChangeLog >index 121c9f029fa3f4cc9d660d0f888ed2b4f40e631f..7d867c821c07141dcade8e4dbb5eb563b00bba43 100644 >--- a/LayoutTests/ChangeLog >+++ b/LayoutTests/ChangeLog >@@ -1,3 +1,66 @@ >+2012-06-15 Amy Ousterhout <aousterh@chromium.org> >+ >+ [Chromium] Implemented DeviceMotion >+ https://bugs.webkit.org/show_bug.cgi?id=89197 >+ >+ Reviewed by NOBODY (OOPS!). >+ >+ Added seven new tests for DeviceMotion. >+ Each tests corresponds to a similar existing test for DeviceOrientation, since they are part of the same spec and work very similarly. >+ Also made small modifications to a couple of existing DeviceMotion tests. >+ >+ * fast/dom/DeviceMotion/add-listener-from-callback-expected.txt: Added. >+ * fast/dom/DeviceMotion/add-listener-from-callback.html: Added. >+ * fast/dom/DeviceMotion/basic-operation-expected.txt: Added. >+ * fast/dom/DeviceMotion/basic-operation.html: Added. >+ * fast/dom/DeviceMotion/create-event-expected.txt: Fixed a typo. >+ * fast/dom/DeviceMotion/event-after-navigation-expected.txt: Added. >+ * fast/dom/DeviceMotion/event-after-navigation.html: Added. >+ * fast/dom/DeviceMotion/multiple-frames-expected.txt: Added. >+ * fast/dom/DeviceMotion/multiple-frames.html: Added. >+ * fast/dom/DeviceMotion/no-synchronous-events-expected.txt: Added. >+ * fast/dom/DeviceMotion/no-synchronous-events.html: Added. >+ * fast/dom/DeviceMotion/null-values-expected.txt: Added. >+ * fast/dom/DeviceMotion/null-values.html: Added. >+ * fast/dom/DeviceMotion/resources/event-after-navigation-new.html: Added. >+ * fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js: Added. >+ (checkMotion): >+ (firstListener): >+ (secondListener): >+ (maybeFinishTest): >+ * fast/dom/DeviceMotion/script-tests/basic-operation.js: Added. >+ * fast/dom/DeviceMotion/script-tests/create-event.js: Fixed a typo. >+ * fast/dom/DeviceMotion/script-tests/event-after-navigation.js: Added. >+ * fast/dom/DeviceMotion/script-tests/multiple-frames.js: Added. >+ (checkMotion): >+ (mainFrameListener): >+ (childFrameListener): >+ (maybeFinishTest): >+ * fast/dom/DeviceMotion/script-tests/no-synchronous-events.js: Added. >+ * fast/dom/DeviceMotion/script-tests/null-values.js: Added. >+ (setMockMotion): >+ (checkMotion): >+ (firstListener): >+ (secondListener): >+ (thirdListener): >+ (fourthListener): >+ (fifthListener): >+ (sixthListener): >+ (seventhListener): >+ (eighthListener): >+ (ninthListener): >+ (tenthListener): >+ (eleventhListener): >+ * fast/dom/DeviceMotion/script-tests/updates.js: Added. >+ (setMockMotion): >+ (checkMotion): >+ (firstListener): >+ (updateListener): >+ * fast/dom/DeviceMotion/updates-expected.txt: Added. >+ * fast/dom/DeviceMotion/updates.html: Added. >+ * fast/dom/DeviceOrientation/no-synchronous-events-expected.txt: Fixed a typo. >+ * fast/dom/DeviceOrientation/script-tests/no-synchronous-events.js: Fixed a typo. >+ > 2012-06-15 Kent Tamura <tkent@chromium.org> > > [Chromium] Fix a syntax error of TestExpectations. >diff --git a/LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback-expected.txt b/LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..8c887b9661cfb91ae90cdb0af1c7400b6da2aa9e >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback-expected.txt >@@ -0,0 +1,39 @@ >+Tests that adding a new event listener from a callback works as expected. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS deviceMotionEvent.acceleration.x is mockAccelerationX >+PASS deviceMotionEvent.acceleration.y is mockAccelerationY >+PASS deviceMotionEvent.acceleration.z is mockAccelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma >+PASS deviceMotionEvent.interval is mockInterval >+PASS deviceMotionEvent.acceleration.x is mockAccelerationX >+PASS deviceMotionEvent.acceleration.y is mockAccelerationY >+PASS deviceMotionEvent.acceleration.z is mockAccelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma >+PASS deviceMotionEvent.interval is mockInterval >+PASS deviceMotionEvent.acceleration.x is mockAccelerationX >+PASS deviceMotionEvent.acceleration.y is mockAccelerationY >+PASS deviceMotionEvent.acceleration.z is mockAccelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma >+PASS deviceMotionEvent.interval is mockInterval >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback.html b/LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback.html >new file mode 100644 >index 0000000000000000000000000000000000000000..fad9984b041540251fa4102e8c9c16df74cd7c68 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/add-listener-from-callback.html >@@ -0,0 +1,9 @@ >+<html> >+<head> >+<script src="../../js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<script src="script-tests/add-listener-from-callback.js"></script> >+<script src="../../js/resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/fast/dom/DeviceMotion/basic-operation-expected.txt b/LayoutTests/fast/dom/DeviceMotion/basic-operation-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..f6d378bbe9dc0d47df7eef0b872725974882d91d >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/basic-operation-expected.txt >@@ -0,0 +1,19 @@ >+Tests the basic operation of DeviceMotion using the mock. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS deviceMotionEvent.acceleration.x is mockAccelerationX >+PASS deviceMotionEvent.acceleration.y is mockAccelerationY >+PASS deviceMotionEvent.acceleration.z is mockAccelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockAccelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockAccelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockAccelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockRotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockRotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockRotationRateGamma >+PASS deviceMotionEvent.interval is mockInterval >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/dom/DeviceMotion/basic-operation.html b/LayoutTests/fast/dom/DeviceMotion/basic-operation.html >new file mode 100644 >index 0000000000000000000000000000000000000000..9157be6e69eca964c7ef48956964ae48608dd438 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/basic-operation.html >@@ -0,0 +1,9 @@ >+<html> >+<head> >+<script src="../../js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<script src="script-tests/basic-operation.js"></script> >+<script src="../../js/resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/fast/dom/DeviceMotion/create-event-expected.txt b/LayoutTests/fast/dom/DeviceMotion/create-event-expected.txt >index f8908612497e5d3b829f45c9050a42cb222b276d..9f4db01f013aaf06fd35c9788b78c34610f29741 100644 >--- a/LayoutTests/fast/dom/DeviceMotion/create-event-expected.txt >+++ b/LayoutTests/fast/dom/DeviceMotion/create-event-expected.txt >@@ -1,4 +1,4 @@ >-Tests that document.createEvent() works with DeviceMotinEvent. >+Tests that document.createEvent() works with DeviceMotionEvent. > > On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". > >diff --git a/LayoutTests/fast/dom/DeviceMotion/event-after-navigation-expected.txt b/LayoutTests/fast/dom/DeviceMotion/event-after-navigation-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..8e6bc39826777b183e4b0fcbecce7ec26fd0fd1d >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/event-after-navigation-expected.txt >@@ -0,0 +1,3 @@ >+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. >+ >+SUCCESS >diff --git a/LayoutTests/fast/dom/DeviceMotion/event-after-navigation.html b/LayoutTests/fast/dom/DeviceMotion/event-after-navigation.html >new file mode 100644 >index 0000000000000000000000000000000000000000..7057aefeb85e68a541727aad8f7ebfe9abdf6fd8 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/event-after-navigation.html >@@ -0,0 +1,9 @@ >+<html> >+<head> >+<script src="../../js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<script src="script-tests/event-after-navigation.js"></script> >+<script src="../../js/resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/fast/dom/DeviceMotion/multiple-frames-expected.txt b/LayoutTests/fast/dom/DeviceMotion/multiple-frames-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..b7699fedaf208049b1bda261af933fac451ec8e6 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/multiple-frames-expected.txt >@@ -0,0 +1,29 @@ >+Tests using DeviceMotion from multiple frames. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/dom/DeviceMotion/multiple-frames.html b/LayoutTests/fast/dom/DeviceMotion/multiple-frames.html >new file mode 100644 >index 0000000000000000000000000000000000000000..4f79cacf66282c1f3421356ccd71688bd5c1eb56 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/multiple-frames.html >@@ -0,0 +1,9 @@ >+<html> >+<head> >+<script src="../../js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<script src="script-tests/multiple-frames.js"></script> >+<script src="../../js/resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/fast/dom/DeviceMotion/no-synchronous-events-expected.txt b/LayoutTests/fast/dom/DeviceMotion/no-synchronous-events-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..9fd8a11b44797f38207e4b64c0e3ce6d6cad8fc7 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/no-synchronous-events-expected.txt >@@ -0,0 +1,10 @@ >+Tests that events are never fired synchronously from a call to window.addEventListener(). >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS hasAddEventListenerReturned is true >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/dom/DeviceMotion/no-synchronous-events.html b/LayoutTests/fast/dom/DeviceMotion/no-synchronous-events.html >new file mode 100644 >index 0000000000000000000000000000000000000000..f3175ea33e9ad71842b9e779105c48b36cee2bfa >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/no-synchronous-events.html >@@ -0,0 +1,9 @@ >+<html> >+<head> >+<script src="../../js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<script src="script-tests/no-synchronous-events.js"></script> >+<script src="../../js/resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/fast/dom/DeviceMotion/null-values-expected.txt b/LayoutTests/fast/dom/DeviceMotion/null-values-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..2635438b910df06ad6e3d765bb7dde58960a527a >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/null-values-expected.txt >@@ -0,0 +1,119 @@ >+Tests using null values for some of the event properties. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/dom/DeviceMotion/null-values.html b/LayoutTests/fast/dom/DeviceMotion/null-values.html >new file mode 100644 >index 0000000000000000000000000000000000000000..753ccbd0b3a733a46ba01179cbe3633f2209e561 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/null-values.html >@@ -0,0 +1,9 @@ >+<html> >+<head> >+<script src="../../js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<script src="script-tests/null-values.js"></script> >+<script src="../../js/resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/fast/dom/DeviceMotion/resources/event-after-navigation-new.html b/LayoutTests/fast/dom/DeviceMotion/resources/event-after-navigation-new.html >new file mode 100644 >index 0000000000000000000000000000000000000000..f631c28fb6e09b6005ec46714ab017cb01ed7cfe >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/resources/event-after-navigation-new.html >@@ -0,0 +1,15 @@ >+<html> >+ <head> >+ </head> >+ <body> >+ 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.<br><br> >+ SUCCESS >+ <script> >+ if (window.layoutTestController) { >+ 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); >+ layoutTestController.notifyDone(); >+ } >+ </script> >+ </body> >+</html> >diff --git a/LayoutTests/fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js b/LayoutTests/fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js >new file mode 100644 >index 0000000000000000000000000000000000000000..feb7b1918d782478a60a550bbedb60c94e88c8cb >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/script-tests/add-listener-from-callback.js >@@ -0,0 +1,62 @@ >+description('Tests that adding a new event listener from a callback works as expected.'); >+ >+var mockAccelerationX = 1.01; >+var mockAccelerationY = 2.02; >+var mockAccelerationZ = 3.03; >+ >+var mockAccelerationIncludingGravityX = 4.04; >+var mockAccelerationIncludingGravityY = 5.05; >+var mockAccelerationIncludingGravityZ = 6.06; >+ >+var mockRotationRateAlpha = 7.07; >+var mockRotationRateBeta = 8.08; >+var mockRotationRateGamma = 9.09; >+ >+var mockInterval = 10.10; >+ >+if (window.layoutTestController) { >+ layoutTestController.setMockDeviceMotion(true, mockAccelerationX, true, mockAccelerationY, true, mockAccelerationZ, true, mockAccelerationIncludingGravityX, true, mockAccelerationIncludingGravityY, true, mockAccelerationIncludingGravityZ, true, mockRotationRateAlpha, true, mockRotationRateBeta, true, mockRotationRateGamma, true, mockInterval); >+} else >+ debug('This test can not be run without the LayoutTestController'); >+ >+var deviceMotionEvent; >+function checkMotion(event) { >+ deviceMotionEvent = event; >+ shouldBe('deviceMotionEvent.acceleration.x', 'mockAccelerationX'); >+ shouldBe('deviceMotionEvent.acceleration.y', 'mockAccelerationY'); >+ shouldBe('deviceMotionEvent.acceleration.z', 'mockAccelerationZ'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockAccelerationIncludingGravityX'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockAccelerationIncludingGravityY'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockAccelerationIncludingGravityZ'); >+ shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockRotationRateAlpha'); >+ shouldBe('deviceMotionEvent.rotationRate.beta', 'mockRotationRateBeta'); >+ shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockRotationRateGamma'); >+ shouldBe('deviceMotionEvent.interval', 'mockInterval'); >+} >+ >+var firstListenerEvents = 0; >+function firstListener(event) { >+ checkMotion(event); >+ if (++firstListenerEvents == 1) >+ window.addEventListener('devicemotion', secondListener); >+ else if (firstListenerEvents > 2) >+ testFailed('Too many events for first listener.'); >+ maybeFinishTest(); >+} >+ >+var secondListenerEvents = 0; >+function secondListener(event) { >+ checkMotion(event); >+ if (++secondListenerEvents > 1) >+ testFailed('Too many events for second listener.'); >+ maybeFinishTest(); >+} >+ >+function maybeFinishTest() { >+ if (firstListenerEvents == 2 && secondListenerEvents == 1) >+ finishJSTest(); >+} >+ >+window.addEventListener('devicemotion', firstListener); >+ >+window.jsTestIsAsync = true; >diff --git a/LayoutTests/fast/dom/DeviceMotion/script-tests/basic-operation.js b/LayoutTests/fast/dom/DeviceMotion/script-tests/basic-operation.js >new file mode 100644 >index 0000000000000000000000000000000000000000..0a535408c205a5cfcdfad26eb2e6e35e89b1d097 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/script-tests/basic-operation.js >@@ -0,0 +1,38 @@ >+description('Tests the basic operation of DeviceMotion using the mock.'); >+ >+var mockAccelerationX = 1.01; >+var mockAccelerationY = 2.02; >+var mockAccelerationZ = 3.03; >+ >+var mockAccelerationIncludingGravityX = 4.04; >+var mockAccelerationIncludingGravityY = 5.05; >+var mockAccelerationIncludingGravityZ = 6.06; >+ >+var mockRotationRateAlpha = 7.07; >+var mockRotationRateBeta = 8.08; >+var mockRotationRateGamma = 9.09; >+ >+var mockInterval = 10.10; >+ >+if (window.layoutTestController) { >+ layoutTestController.setMockDeviceMotion(true, mockAccelerationX, true, mockAccelerationY, true, mockAccelerationZ, true, mockAccelerationIncludingGravityX, true, mockAccelerationIncludingGravityY, true, mockAccelerationIncludingGravityZ, true, mockRotationRateAlpha, true, mockRotationRateBeta, true, mockRotationRateGamma, true, mockInterval); >+} else >+ debug('This test can not be run without the LayoutTestController'); >+ >+var deviceMotionEvent; >+window.addEventListener('devicemotion', function(e) { >+ deviceMotionEvent = e; >+ shouldBe('deviceMotionEvent.acceleration.x', 'mockAccelerationX'); >+ shouldBe('deviceMotionEvent.acceleration.y', 'mockAccelerationY'); >+ shouldBe('deviceMotionEvent.acceleration.z', 'mockAccelerationZ'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockAccelerationIncludingGravityX'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockAccelerationIncludingGravityY'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockAccelerationIncludingGravityZ'); >+ shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockRotationRateAlpha'); >+ shouldBe('deviceMotionEvent.rotationRate.beta', 'mockRotationRateBeta'); >+ shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockRotationRateGamma'); >+ shouldBe('deviceMotionEvent.interval', 'mockInterval'); >+ finishJSTest(); >+}); >+ >+window.jsTestIsAsync = true; >diff --git a/LayoutTests/fast/dom/DeviceMotion/script-tests/create-event.js b/LayoutTests/fast/dom/DeviceMotion/script-tests/create-event.js >index b27ac61d86a9755f91ea120577027ced32b09b64..4c83ff3f2d50cf247434ead9911bedf2e13300cb 100644 >--- a/LayoutTests/fast/dom/DeviceMotion/script-tests/create-event.js >+++ b/LayoutTests/fast/dom/DeviceMotion/script-tests/create-event.js >@@ -1,4 +1,4 @@ >-description("Tests that document.createEvent() works with DeviceMotinEvent."); >+description("Tests that document.createEvent() works with DeviceMotionEvent."); > > var event = document.createEvent('DeviceMotionEvent'); > >diff --git a/LayoutTests/fast/dom/DeviceMotion/script-tests/event-after-navigation.js b/LayoutTests/fast/dom/DeviceMotion/script-tests/event-after-navigation.js >new file mode 100644 >index 0000000000000000000000000000000000000000..d133138eb0ab2d73c7f3c20cb0dcb19dd75cfe69 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/script-tests/event-after-navigation.js >@@ -0,0 +1,13 @@ >+description('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.'); >+ >+if (window.layoutTestController) >+ layoutTestController.overridePreference('WebKitUsesPageCachePreferenceKey', 1); >+else >+ debug('This test can not be run without the LayoutTestController'); >+ >+document.body.onload = function() { >+ window.addEventListener('devicemotion', function() { } ); >+ window.location = "resources/event-after-navigation-new.html"; >+} >+ >+window.jsTestIsAsync = true; >diff --git a/LayoutTests/fast/dom/DeviceMotion/script-tests/multiple-frames.js b/LayoutTests/fast/dom/DeviceMotion/script-tests/multiple-frames.js >new file mode 100644 >index 0000000000000000000000000000000000000000..1e827cd232b6c7f75dd039c05a416160ad9e7e25 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/script-tests/multiple-frames.js >@@ -0,0 +1,49 @@ >+description('Tests using DeviceMotion from multiple frames.'); >+ >+var deviceMotionEvent; >+function checkMotion(event) { >+ deviceMotionEvent = event; >+ shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX'); >+ shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY'); >+ shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.accelerationIncludingGravityX'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.accelerationIncludingGravityY'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.accelerationIncludingGravityZ'); >+ shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlpha'); >+ shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta'); >+ shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamma'); >+ shouldBe('deviceMotionEvent.interval', 'mockEvent.interval'); >+} >+ >+var hasMainFrameEventFired = false; >+function mainFrameListener(event) { >+ checkMotion(event); >+ hasMainFrameEventFired = true; >+ maybeFinishTest(); >+} >+ >+var hasChildFrameEventFired = false; >+function childFrameListener(event) { >+ checkMotion(event); >+ hasChildFrameEventFired = true; >+ maybeFinishTest(); >+} >+ >+function maybeFinishTest() { >+ if (hasMainFrameEventFired && hasChildFrameEventFired) >+ finishJSTest(); >+} >+ >+var 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}; >+if (window.layoutTestController) >+ 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); >+else >+ debug('This test can not be run without the LayoutTestController'); >+ >+var childFrame = document.createElement('iframe'); >+document.body.appendChild(childFrame); >+childFrame.contentWindow.addEventListener('devicemotion', childFrameListener); >+ >+window.addEventListener('devicemotion', mainFrameListener); >+ >+window.jsTestIsAsync = true; >diff --git a/LayoutTests/fast/dom/DeviceMotion/script-tests/no-synchronous-events.js b/LayoutTests/fast/dom/DeviceMotion/script-tests/no-synchronous-events.js >new file mode 100644 >index 0000000000000000000000000000000000000000..e469271131f26c5b83e6dc51fafd020b512e8424 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/script-tests/no-synchronous-events.js >@@ -0,0 +1,15 @@ >+description('Tests that events are never fired synchronously from a call to window.addEventListener().'); >+ >+if (window.layoutTestController) >+ 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); >+else >+ debug('This test can not be run without the LayoutTestController'); >+ >+var hasAddEventListenerReturned = false; >+window.addEventListener('devicemotion', function() { >+ shouldBeTrue('hasAddEventListenerReturned'); >+ finishJSTest(); >+}); >+hasAddEventListenerReturned = true; >+ >+window.jsTestIsAsync = true; >diff --git a/LayoutTests/fast/dom/DeviceMotion/script-tests/null-values.js b/LayoutTests/fast/dom/DeviceMotion/script-tests/null-values.js >new file mode 100644 >index 0000000000000000000000000000000000000000..6efee1ce547536b449fe618c4daec2b4bb72a048 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/script-tests/null-values.js >@@ -0,0 +1,125 @@ >+description('Tests using null values for some of the event properties.'); >+ >+var mockEvent; >+function setMockMotion(accelerationX, accelerationY, accelerationZ, accelerationIncludingGravityX, accelerationIncludingGravityY, accelerationIncludingGravityZ, rotationRateAlpha, rotationRateBeta, rotationRateGamma, interval) { >+ mockEvent = {accelerationX: accelerationX, accelerationY: accelerationY, accelerationZ: accelerationZ, accelerationIncludingGravityX: accelerationIncludingGravityX, accelerationIncludingGravityY: accelerationIncludingGravityY, accelerationIncludingGravityZ: accelerationIncludingGravityZ, rotationRateAlpha: rotationRateAlpha, rotationRateBeta: rotationRateBeta, rotationRateGamma: rotationRateGamma, interval: interval}; >+ if (window.layoutTestController) >+ layoutTestController.setMockDeviceMotion( >+ null != mockEvent.accelerationX, null == mockEvent.accelerationX ? 0 : mockEvent.accelerationX, >+ null != mockEvent.accelerationY, null == mockEvent.accelerationY ? 0 : mockEvent.accelerationY, >+ null != mockEvent.accelerationZ, null == mockEvent.accelerationZ ? 0 : mockEvent.accelerationZ, >+ null != mockEvent.accelerationIncludingGravityX, null == mockEvent.accelerationIncludingGravityX ? 0 : mockEvent.accelerationIncludingGravityX, >+ null != mockEvent.accelerationIncludingGravityY, null == mockEvent.accelerationIncludingGravityY ? 0 : mockEvent.accelerationIncludingGravityY, >+ null != mockEvent.accelerationIncludingGravityZ, null == mockEvent.accelerationIncludingGravityZ ? 0 : mockEvent.accelerationIncludingGravityZ, >+ null != mockEvent.rotationRateAlpha, null == mockEvent.rotationRateAlpha ? 0 : mockEvent.rotationRateAlpha, >+ null != mockEvent.rotationRateBeta, null == mockEvent.rotationRateBeta ? 0 : mockEvent.rotationRateBeta, >+ null != mockEvent.rotationRateGamma, null == mockEvent.rotationRateGamma ? 0 : mockEvent.rotationRateGamma, >+ null != mockEvent.interval, null == mockEvent.interval ? 0 : mockEvent.interval); >+ else >+ debug('This test can not be run without the LayoutTestController'); >+} >+ >+var deviceMotionEvent; >+function checkMotion(event) { >+ deviceMotionEvent = event; >+ shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX'); >+ shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY'); >+ shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.accelerationIncludingGravityX'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.accelerationIncludingGravityY'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.accelerationIncludingGravityZ'); >+ shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlpha'); >+ shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta'); >+ shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamma'); >+ shouldBe('deviceMotionEvent.interval', 'mockEvent.interval'); >+} >+ >+function firstListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', firstListener); >+ >+ setMockMotion(1.01, null, null, null, null, null, null, null, null, null); >+ window.addEventListener('devicemotion', secondListener); >+} >+ >+function secondListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', secondListener); >+ >+ setMockMotion(null, 2.02, null, null, null, null, null, null, null, null); >+ window.addEventListener('devicemotion', thirdListener); >+} >+ >+function thirdListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', thirdListener); >+ >+ setMockMotion(null, null, 3.03, null, null, null, null, null, null, null); >+ window.addEventListener('devicemotion', fourthListener); >+} >+ >+function fourthListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', fourthListener); >+ >+ setMockMotion(null, null, null, 4.04, null, null, null, null, null, null); >+ window.addEventListener('devicemotion', fifthListener); >+} >+ >+function fifthListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', fifthListener); >+ >+ setMockMotion(null, null, null, null, 5.05, null, null, null, null, null); >+ window.addEventListener('devicemotion', sixthListener); >+} >+ >+function sixthListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', sixthListener); >+ >+ setMockMotion(null, null, null, null, null, 6.06, null, null, null, null); >+ window.addEventListener('devicemotion', seventhListener); >+} >+ >+function seventhListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', seventhListener); >+ >+ setMockMotion(null, null, null, null, null, null, 7.07, null, null, null); >+ window.addEventListener('devicemotion', eighthListener); >+} >+ >+function eighthListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', eighthListener); >+ >+ setMockMotion(null, null, null, null, null, null, null, 8.08, null, null); >+ window.addEventListener('devicemotion', ninthListener); >+} >+ >+function ninthListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', ninthListener); >+ >+ setMockMotion(null, null, null, null, null, null, null, null, 9.09, null); >+ window.addEventListener('devicemotion', tenthListener); >+} >+ >+function tenthListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', tenthListener); >+ >+ setMockMotion(null, null, null, null, null, null, null, null, null, 10.10); >+ window.addEventListener('devicemotion', eleventhListener); >+} >+ >+function eleventhListener(event) { >+ checkMotion(event); >+ finishJSTest(); >+} >+ >+setMockMotion(null, null, null, null, null, null, null, null, null, null); >+window.addEventListener('devicemotion', firstListener); >+ >+window.jsTestIsAsync = true; >diff --git a/LayoutTests/fast/dom/DeviceMotion/script-tests/updates.js b/LayoutTests/fast/dom/DeviceMotion/script-tests/updates.js >new file mode 100644 >index 0000000000000000000000000000000000000000..f4405541d6f9fdb711dcab16e57a538e183b34d6 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/script-tests/updates.js >@@ -0,0 +1,53 @@ >+description('Tests that updates to the motion causes new events to fire.'); >+ >+var mockEvent; >+function setMockMotion(accelerationX, accelerationY, accelerationZ, accelerationIncludingGravityX, accelerationIncludingGravityY, accelerationIncludingGravityZ, rotationRateAlpha, rotationRateBeta, rotationRateGamma, interval) { >+ mockEvent = {accelerationX: accelerationX, accelerationY: accelerationY, accelerationZ: accelerationZ, accelerationIncludingGravityX: accelerationIncludingGravityX, accelerationIncludingGravityY: accelerationIncludingGravityY, accelerationIncludingGravityZ: accelerationIncludingGravityZ, rotationRateAlpha: rotationRateAlpha, rotationRateBeta: rotationRateBeta, rotationRateGamma: rotationRateGamma, interval: interval}; >+ if (window.layoutTestController) >+ layoutTestController.setMockDeviceMotion( >+ null != mockEvent.accelerationX, null == mockEvent.accelerationX ? 0 : mockEvent.accelerationX, >+ null != mockEvent.accelerationY, null == mockEvent.accelerationY ? 0 : mockEvent.accelerationY, >+ null != mockEvent.accelerationZ, null == mockEvent.accelerationZ ? 0 : mockEvent.accelerationZ, >+ null != mockEvent.accelerationIncludingGravityX, null == mockEvent.accelerationIncludingGravityX ? 0 : mockEvent.accelerationIncludingGravityX, >+ null != mockEvent.accelerationIncludingGravityY, null == mockEvent.accelerationIncludingGravityY ? 0 : mockEvent.accelerationIncludingGravityY, >+ null != mockEvent.accelerationIncludingGravityZ, null == mockEvent.accelerationIncludingGravityZ ? 0 : mockEvent.accelerationIncludingGravityZ, >+ null != mockEvent.rotationRateAlpha, null == mockEvent.rotationRateAlpha ? 0 : mockEvent.rotationRateAlpha, >+ null != mockEvent.rotationRateBeta, null == mockEvent.rotationRateBeta ? 0 : mockEvent.rotationRateBeta, >+ null != mockEvent.rotationRateGamma, null == mockEvent.rotationRateGamma ? 0 : mockEvent.rotationRateGamma, >+ null != mockEvent.interval, null == mockEvent.interval ? 0 : mockEvent.interval); >+ else >+ debug('This test can not be run without the LayoutTestController'); >+} >+ >+var deviceMotionEvent; >+function checkMotion(event) { >+ deviceMotionEvent = event; >+ shouldBe('deviceMotionEvent.acceleration.x', 'mockEvent.accelerationX'); >+ shouldBe('deviceMotionEvent.acceleration.y', 'mockEvent.accelerationY'); >+ shouldBe('deviceMotionEvent.acceleration.z', 'mockEvent.accelerationZ'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.x', 'mockEvent.accelerationIncludingGravityX'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.y', 'mockEvent.accelerationIncludingGravityY'); >+ shouldBe('deviceMotionEvent.accelerationIncludingGravity.z', 'mockEvent.accelerationIncludingGravityZ'); >+ shouldBe('deviceMotionEvent.rotationRate.alpha', 'mockEvent.rotationRateAlpha'); >+ shouldBe('deviceMotionEvent.rotationRate.beta', 'mockEvent.rotationRateBeta'); >+ shouldBe('deviceMotionEvent.rotationRate.gamma', 'mockEvent.rotationRateGamma'); >+ shouldBe('deviceMotionEvent.interval', 'mockEvent.interval'); >+} >+ >+function firstListener(event) { >+ checkMotion(event); >+ window.removeEventListener('devicemotion', firstListener); >+ >+ setMockMotion(11.01, 22.02, 33.03, 44.04, 55.05, 66.06, 77.07, 88.08, 99.09, 110.10); >+ window.addEventListener('devicemotion', updateListener); >+} >+ >+function updateListener(event) { >+ checkMotion(event); >+ finishJSTest(); >+} >+ >+setMockMotion(1.1, 2.2, 3.3, 4.4, 5.5, 6.6, 7.7, 8.8, 9.9, 10.10); >+window.addEventListener('devicemotion', firstListener); >+ >+window.jsTestIsAsync = true; >diff --git a/LayoutTests/fast/dom/DeviceMotion/updates-expected.txt b/LayoutTests/fast/dom/DeviceMotion/updates-expected.txt >new file mode 100644 >index 0000000000000000000000000000000000000000..ed3b823ce9bcedb736522ca675df335a4a84a877 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/updates-expected.txt >@@ -0,0 +1,29 @@ >+Tests that updates to the motion causes new events to fire. >+ >+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". >+ >+ >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS deviceMotionEvent.acceleration.x is mockEvent.accelerationX >+PASS deviceMotionEvent.acceleration.y is mockEvent.accelerationY >+PASS deviceMotionEvent.acceleration.z is mockEvent.accelerationZ >+PASS deviceMotionEvent.accelerationIncludingGravity.x is mockEvent.accelerationIncludingGravityX >+PASS deviceMotionEvent.accelerationIncludingGravity.y is mockEvent.accelerationIncludingGravityY >+PASS deviceMotionEvent.accelerationIncludingGravity.z is mockEvent.accelerationIncludingGravityZ >+PASS deviceMotionEvent.rotationRate.alpha is mockEvent.rotationRateAlpha >+PASS deviceMotionEvent.rotationRate.beta is mockEvent.rotationRateBeta >+PASS deviceMotionEvent.rotationRate.gamma is mockEvent.rotationRateGamma >+PASS deviceMotionEvent.interval is mockEvent.interval >+PASS successfullyParsed is true >+ >+TEST COMPLETE >+ >diff --git a/LayoutTests/fast/dom/DeviceMotion/updates.html b/LayoutTests/fast/dom/DeviceMotion/updates.html >new file mode 100644 >index 0000000000000000000000000000000000000000..822526969004cbe9ae7a601e67619b8b1820cee6 >--- /dev/null >+++ b/LayoutTests/fast/dom/DeviceMotion/updates.html >@@ -0,0 +1,9 @@ >+<html> >+<head> >+<script src="../../js/resources/js-test-pre.js"></script> >+</head> >+<body> >+<script src="script-tests/updates.js"></script> >+<script src="../../js/resources/js-test-post.js"></script> >+</body> >+</html> >diff --git a/LayoutTests/fast/dom/DeviceOrientation/no-synchronous-events-expected.txt b/LayoutTests/fast/dom/DeviceOrientation/no-synchronous-events-expected.txt >index 0d95deea8b48ef7f13317b25e14339018f08e62c..9fd8a11b44797f38207e4b64c0e3ce6d6cad8fc7 100644 >--- a/LayoutTests/fast/dom/DeviceOrientation/no-synchronous-events-expected.txt >+++ b/LayoutTests/fast/dom/DeviceOrientation/no-synchronous-events-expected.txt >@@ -1,4 +1,4 @@ >-Tests that events are never fired sycnhronously from a call to window.addEventListener(). >+Tests that events are never fired synchronously from a call to window.addEventListener(). > > On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE". > >diff --git a/LayoutTests/fast/dom/DeviceOrientation/script-tests/no-synchronous-events.js b/LayoutTests/fast/dom/DeviceOrientation/script-tests/no-synchronous-events.js >index 2d7cb8155c4a5ce58a21ecf6b944f3dc5aef8edd..58362d78f476cb7c1276dc66d4d589f0e4eb5832 100644 >--- a/LayoutTests/fast/dom/DeviceOrientation/script-tests/no-synchronous-events.js >+++ b/LayoutTests/fast/dom/DeviceOrientation/script-tests/no-synchronous-events.js >@@ -1,4 +1,4 @@ >-description('Tests that events are never fired sycnhronously from a call to window.addEventListener().'); >+description('Tests that events are never fired synchronously from a call to window.addEventListener().'); > > if (window.layoutTestController) > layoutTestController.setMockDeviceOrientation(true, 1.1, true, 2.2, true, 3.3);
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Formatted Diff
|
Diff
Attachments on
bug 89197
:
147796
|
148105
|
148560
|
148790
|
149311
|
156704
|
157758
|
158780
|
158790
|
158834
|
158844
|
159132
|
159151
|
159450
|
166015
|
166259