LayoutTests/ChangeLog

 12012-02-17 Kihong Kwon <kihong.kwon@samsung.com>
 2
 3 Add a new test case for the Vibration API.
 4 https://bugs.webkit.org/show_bug.cgi?id=72010
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * fast/dom/navigator-vibration-expected.txt: Added.
 9 * fast/dom/navigator-vibration.html: Added.
 10 * platform/chromium/test_expectations.txt:
 11 * platform/gtk/Skipped:
 12 * platform/mac/Skipped:
 13 * platform/qt/Skipped:
 14 * platform/win/Skipped:
 15 * platform/wincairo/Skipped:
 16
1172012-02-17 Adam Klein <adamk@chromium.org>
218
319 Avoid inconsistency in Node::inDocument due to DOMSubtreeModified dispatch

LayoutTests/fast/dom/navigator-vibration-expected.txt

 1Test for the Vibration API.
 2
 3On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
 4
 5
 6PASS navigator.webkitVibrate(0); is undefined
 7PASS navigator.webkitVibrate([]); is undefined
 8PASS navigator.webkitVibrate(1000); is undefined
 9PASS navigator.webkitVibrate([1000, 300, 500]); is undefined
 10PASS navigator.webkitVibrate(4294967295); is undefined
 11PASS navigator.webkitVibrate(); threw exception TypeError: Type error.
 12PASS successfullyParsed is true
 13
 14TEST COMPLETE
 15

LayoutTests/fast/dom/navigator-vibration.html

 1<html>
 2<head>
 3<script src="../js/resources/js-test-pre.js"></script>
 4</head>
 5<body>
 6<script>
 7description('Test for the Vibration API.');
 8
 9shouldBe("navigator.webkitVibrate(0);", "undefined");
 10shouldBe("navigator.webkitVibrate([]);", "undefined");
 11shouldBe("navigator.webkitVibrate(1000);", "undefined");
 12shouldBe("navigator.webkitVibrate([1000, 300, 500]);", "undefined");
 13shouldBe("navigator.webkitVibrate(4294967295);", "undefined");
 14shouldThrow("navigator.webkitVibrate();");
 15</script>
 16<script src="../js/resources/js-test-post.js"></script>
 17</body>
 18</html>

LayoutTests/platform/chromium/test_expectations.txt

@@BUGNOEL : svg/carto.net/selectionlist.svg = IMAGE+TEXT IMAGE
111111// New test, needs baselines.
112112
113113
 114// Vibration API is not supported yet in the chromium port.
 115BUGWK72010 SKIP : fast/dom/navigator-vibration.html = FAIL
 116
114117// -----------------------------------------------------------------
115118// WONTFIX TESTS
116119// -----------------------------------------------------------------

LayoutTests/platform/gtk/Skipped

@@http/tests/security/webgl-remote-read-remote-image-allowed.html
393393http/tests/security/webgl-remote-read-remote-image-blocked-no-crossorigin.html
394394http/tests/security/webgl-remote-read-remote-image-allowed-with-credentials.html
395395
 396#Vibration API support not yet. http://webkit.org/b/72010
 397fast/dom/navigator-vibration.html
 398
396399###############################################################################
397400# TESTS FAILING
398401###############################################################################

LayoutTests/platform/mac/Skipped

@@media/W3C/video/canPlayType/canPlayType_two_implies_one_6.html
550550# Fails because MutationObservers are not notified at end-of-task
551551# https://bugs.webkit.org/show_bug.cgi?id=78290
552552fast/mutation/end-of-task-delivery.html
 553
 554# https://bugs.webkit.org/show_bug.cgi?id=72010
 555# Needs PageClients::vibrationClient() implementation.
 556fast/dom/navigator-vibration.html

LayoutTests/platform/qt/Skipped

@@fast/parser/pre-html5-parser-quirks.html
333333# https://bugs.webkit.org/show_bug.cgi?id=72363
334334fast/dom/Window/window-postmessage-arrays.html
335335
 336#Vibration API is not implemented.
 337fast/dom/navigator-vibration.html
 338
336339# =========================================================================== #
337340# Drag and Drop Support in DRT. #
338341# =========================================================================== #

LayoutTests/platform/win/Skipped

@@fast/repaint/table-section-repaint.html
16451645// Need rebaselining after bug 37244.
16461646tables/mozilla/bugs/bug27038-1.html
16471647tables/mozilla/bugs/bug27038-2.html
 1648
 1649#Vibration API is not implemented.
 1650fast/dom/navigator-vibration.html

LayoutTests/platform/wincairo/Skipped

@@fast/canvas/webgl/arraybuffer-transfer-of-control.html
20452045# Fails because MutationObservers are not notified at end-of-task
20462046# https://bugs.webkit.org/show_bug.cgi?id=78290
20472047fast/mutation/end-of-task-delivery.html
 2048
 2049#Vibration API is not implemented.
 2050fast/dom/navigator-vibration.html

Source/WebCore/CMakeLists.txt

@@IF (ENABLE_REQUEST_ANIMATION_FRAME)
22502250 )
22512251ENDIF ()
22522252
 2253IF (ENABLE_VIBRATION)
 2254 LIST(APPEND WebCore_INCLUDE_DIRECTORIES
 2255 ${WEBCORE_DIR}/Modules/vibration
 2256 )
 2257 LIST(APPEND WebCore_IDL_FILES
 2258 Modules/vibration/NavigatorVibration.idl
 2259 )
 2260 LIST(APPEND WebCore_SOURCES
 2261 Modules/vibration/NavigatorVibration.cpp
 2262 Modules/vibration/Vibration.cpp
 2263 )
 2264ENDIF ()
 2265
22532266# Modules that the bindings generator scripts may use
22542267SET(SCRIPTS_RESOLVE_SUPPLEMENTAL
22552268 ${WEBCORE_DIR}/bindings/scripts/IDLParser.pm

Source/WebCore/ChangeLog

 12012-02-17 Kihong Kwon <kihong.kwon@samsung.com>
 2
 3 http://dev.w3.org/2009/dap/vibration/
 4 This patch implements navigator.webkitvibrate() API.
 5 This API operates differently depending upon a given parameter:
 6 1. It cancels vibration when given 0 or [].
 7 2. It gives a vibration duration in milliseconds when given as a single integer value.
 8 3. It gives a vibration pattern when given as an integer array. For instance, [1000 300 1000] generates a vibration of 1000ms followed by 300ms of idle time, and then creates another vibration of 1000ms.
 9
 10 Reviewed by NOBODY (OOPS!).
 11
 12 Test: fast/dom/navigator-vibration.html
 13
 14 * CMakeLists.txt:
 15 * Modules/vibration/NavigatorVibration.cpp: Added.
 16 (WebCore):
 17 (WebCore::NavigatorVibration::NavigatorVibration):
 18 (WebCore::NavigatorVibration::~NavigatorVibration):
 19 (WebCore::NavigatorVibration::webkitVibrate):
 20 Add webkitVibrate method to get an array or single integer parameter for vibrating.
 21 They check vibration is activated in the platform, and then call vibrate() in the Vibration class.
 22 * Modules/vibration/NavigatorVibration.h: Added.
 23 (WebCore):
 24 (NavigatorVibration):
 25 * Modules/vibration/NavigatorVibration.idl: Added.
 26 * Modules/vibration/Vibration.cpp: Added.
 27 This class implements the entire vibration logic.
 28 (WebCore):
 29 (WebCore::Vibration::Vibration):
 30 (WebCore::Vibration::~Vibration):
 31 (WebCore::Vibration::create):
 32 (WebCore::Vibration::vibrate):
 33 (WebCore::Vibration::cancelVibration):
 34 (WebCore::Vibration::suspendVibration):
 35 (WebCore::Vibration::resumeVibration):
 36 (WebCore::Vibration::timerStartFired):
 37 (WebCore::Vibration::timerStopFired):
 38 (WebCore::Vibration::supplementName):
 39 (WebCore::Vibration::isActive):
 40 (WebCore::provideVibrationTo):
 41 * Modules/vibration/Vibration.h: Added.
 42 (WebCore):
 43 (Vibration):
 44 (WebCore::Vibration::from):
 45 * Modules/vibration/VibrationClient.h: Added.
 46 vibrate() and cancelVibrate() need to be implemented in the VibrationClient.
 47 (WebCore):
 48 (VibrationClient):
 49 (WebCore::VibrationClient::~VibrationClient):
 50
1512012-02-17 Adam Klein <adamk@chromium.org>
252
353 Avoid inconsistency in Node::inDocument due to DOMSubtreeModified dispatch

Source/WebCore/Modules/vibration/NavigatorVibration.cpp

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 */
 19
 20#include "config.h"
 21#include "NavigatorVibration.h"
 22
 23#if ENABLE(VIBRATION)
 24
 25#include "ExceptionCode.h"
 26#include "Frame.h"
 27#include "Navigator.h"
 28#include "Page.h"
 29#include "Vibration.h"
 30#include <wtf/Uint32Array.h>
 31
 32namespace WebCore {
 33
 34NavigatorVibration::NavigatorVibration()
 35{
 36}
 37
 38NavigatorVibration::~NavigatorVibration()
 39{
 40}
 41
 42void NavigatorVibration::webkitVibrate(Navigator* navigator, unsigned long time, ExceptionCode& ec)
 43{
 44 if (!navigator->frame()->page())
 45 return;
 46
 47#if ENABLE(PAGE_VISIBILITY_API)
 48 if (navigator->frame()->page()->visibilityState() == PageVisibilityStateHidden)
 49 return;
 50#endif
 51
 52 if (!Vibration::isActive(navigator->frame()->page())) {
 53 ec = NOT_SUPPORTED_ERR;
 54 return;
 55 }
 56
 57 Vibration::from(navigator->frame()->page())->vibrate(time);
 58}
 59
 60void NavigatorVibration::webkitVibrate(Navigator* navigator, const VibrationPattern& pattern, ExceptionCode& ec)
 61{
 62 if (!navigator->frame()->page())
 63 return;
 64
 65#if ENABLE(PAGE_VISIBILITY_API)
 66 if (navigator->frame()->page()->visibilityState() == PageVisibilityStateHidden)
 67 return;
 68#endif
 69
 70 if (!Vibration::isActive(navigator->frame()->page())) {
 71 ec = NOT_SUPPORTED_ERR;
 72 return;
 73 }
 74
 75 Vibration::from(navigator->frame()->page())->vibrate(pattern);
 76}
 77
 78} // namespace WebCore
 79
 80#endif // ENABLE(VIBRATION)
 81

Source/WebCore/Modules/vibration/NavigatorVibration.h

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 */
 19
 20#ifndef NavigatorVibration_h
 21#define NavigatorVibration_h
 22
 23#if ENABLE(VIBRATION)
 24
 25#include "ExceptionCode.h"
 26#include <wtf/Vector.h>
 27
 28namespace WebCore {
 29
 30class Navigator;
 31class Uint32Array;
 32
 33class NavigatorVibration {
 34public:
 35 typedef Vector<unsigned long> VibrationPattern;
 36
 37 static void webkitVibrate(Navigator*, unsigned long time, ExceptionCode&);
 38 static void webkitVibrate(Navigator*, const VibrationPattern&, ExceptionCode&);
 39
 40private:
 41 NavigatorVibration();
 42 ~NavigatorVibration();
 43};
 44
 45} // namespace WebCore
 46
 47#endif // ENABLE(VIBRATION)
 48
 49#endif // NavigatorVibration_h
 50

Source/WebCore/Modules/vibration/NavigatorVibration.idl

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 */
 19
 20module window {
 21
 22 interface [
 23 Conditional=VIBRATION,
 24 Supplemental=Navigator
 25 ] NavigatorVibration {
 26 void webkitVibrate(in unsigned long[] pattern) raises(DOMException);
 27 void webkitVibrate(in unsigned long time) raises(DOMException);
 28 };
 29
 30}

Source/WebCore/Modules/vibration/Vibration.cpp

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 */
 19
 20#include "config.h"
 21#include "Vibration.h"
 22
 23#if ENABLE(VIBRATION)
 24
 25#include "VibrationClient.h"
 26
 27namespace WebCore {
 28
 29Vibration::Vibration(VibrationClient* client)
 30 : m_vibrationClient(client)
 31 , m_timerStart(this, &Vibration::timerStartFired)
 32 , m_timerStop(this, &Vibration::timerStopFired)
 33 , m_isVibrating(false)
 34{
 35}
 36
 37Vibration::~Vibration()
 38{
 39 m_vibrationClient->vibrationDestroyed();
 40}
 41
 42PassOwnPtr<Vibration> Vibration::create(VibrationClient* client)
 43{
 44 return adoptPtr(new Vibration(client));
 45}
 46
 47void Vibration::vibrate(const unsigned long& time)
 48{
 49 if (!time) {
 50 cancelVibration();
 51 return;
 52 }
 53 m_pattern.append(time);
 54 m_timerStart.startOneShot(0);
 55}
 56
 57void Vibration::vibrate(const VibrationPattern& pattern)
 58{
 59 int length = pattern.size();
 60
 61 if (m_isVibrating)
 62 cancelVibration();
 63
 64 if (!length || (length == 1 && !pattern[0]))
 65 return;
 66
 67 if (m_timerStart.isActive())
 68 m_timerStart.stop();
 69
 70 m_pattern = pattern;
 71 m_timerStart.startOneShot(0);
 72}
 73
 74void Vibration::cancelVibration()
 75{
 76 if (m_isVibrating) {
 77 m_vibrationClient->cancelVibration();
 78 m_isVibrating = false;
 79 m_timerStop.stop();
 80 }
 81}
 82
 83void Vibration::suspendVibration()
 84{
 85 if (!m_isVibrating)
 86 return;
 87
 88 m_pattern.insert(0, m_timerStop.nextFireInterval());
 89 m_timerStop.stop();
 90 cancelVibration();
 91}
 92
 93void Vibration::resumeVibration()
 94{
 95 m_timerStart.startOneShot(0);
 96}
 97
 98void Vibration::timerStartFired(Timer<Vibration>* timer)
 99{
 100 ASSERT_UNUSED(timer, timer == &m_timerStart);
 101
 102 m_timerStart.stop();
 103
 104 if (m_pattern.size()) {
 105 m_isVibrating = true;
 106 m_vibrationClient->vibrate(m_pattern[0]);
 107 m_timerStop.startOneShot(m_pattern[0] / 1000.0);
 108 m_pattern.remove(0);
 109 }
 110}
 111
 112void Vibration::timerStopFired(Timer<Vibration>* timer)
 113{
 114 ASSERT_UNUSED(timer, timer == &m_timerStop);
 115
 116 m_timerStop.stop();
 117 m_isVibrating = false;
 118
 119 if (m_pattern.size()) {
 120 m_timerStart.startOneShot(m_pattern[0] / 1000.0);
 121 m_pattern.remove(0);
 122 }
 123}
 124
 125const AtomicString& Vibration::supplementName()
 126{
 127 DEFINE_STATIC_LOCAL(AtomicString, name, ("vibration"));
 128 return name;
 129}
 130
 131bool Vibration::isActive(Page* page)
 132{
 133 return static_cast<bool>(Vibration::from(page));
 134}
 135
 136void provideVibrationTo(Page* page, VibrationClient* client)
 137{
 138 PageSupplement::provideTo(page, Vibration::supplementName(), Vibration::create(client));
 139}
 140
 141} // namespace WebCore
 142
 143#endif // ENABLE(VIBRATION)
 144

Source/WebCore/Modules/vibration/Vibration.h

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 */
 19
 20#ifndef Vibration_h
 21#define Vibration_h
 22
 23#if ENABLE(VIBRATION)
 24
 25#include "PageSupplement.h"
 26#include "Timer.h"
 27#include <wtf/PassOwnPtr.h>
 28
 29namespace WebCore {
 30
 31class Navigator;
 32class Page;
 33class VibrationClient;
 34
 35class Vibration : public PageSupplement {
 36public:
 37 typedef Vector<unsigned long> VibrationPattern;
 38
 39 Vibration(VibrationClient*);
 40 ~Vibration();
 41
 42 static PassOwnPtr<Vibration> create(VibrationClient*);
 43
 44 void vibrate(const unsigned long& time);
 45 void vibrate(const VibrationPattern&);
 46 void cancelVibration();
 47
 48 // FIXME : Add suspendVibration() and resumeVibration() to the page visibility feature, when the document.hidden attribute is changed.
 49 void suspendVibration();
 50 void resumeVibration();
 51 void timerStartFired(Timer<Vibration>*);
 52 void timerStopFired(Timer<Vibration>*);
 53
 54 static const AtomicString& supplementName();
 55 static Vibration* from(Page* page) { return static_cast<Vibration*>(PageSupplement::from(page, supplementName())); }
 56 static bool isActive(Page*);
 57
 58private:
 59 VibrationClient* m_vibrationClient;
 60 Timer<Vibration> m_timerStart;
 61 Timer<Vibration> m_timerStop;
 62 bool m_isVibrating;
 63 VibrationPattern m_pattern;
 64};
 65
 66} // namespace WebCore
 67
 68#endif // ENABLE(VIBRATION)
 69
 70#endif // Vibration_h
 71

Source/WebCore/Modules/vibration/VibrationClient.h

 1/*
 2 * Copyright (C) 2012 Samsung Electronics
 3 *
 4 * This library is free software; you can redistribute it and/or
 5 * modify it under the terms of the GNU Library General Public
 6 * License as published by the Free Software Foundation; either
 7 * version 2 of the License, or (at your option) any later version.
 8 *
 9 * This library is distributed in the hope that it will be useful,
 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
 12 * Library General Public License for more details.
 13 *
 14 * You should have received a copy of the GNU Library General Public License
 15 * along with this library; see the file COPYING.LIB. If not, write to
 16 * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
 17 * Boston, MA 02110-1301, USA.
 18 */
 19
 20#ifndef VibrationClient_h
 21#define VibrationClient_h
 22
 23namespace WebCore {
 24
 25class Page;
 26
 27class VibrationClient {
 28public:
 29 virtual ~VibrationClient() { }
 30
 31 virtual void vibrate(const unsigned long& time) = 0;
 32 virtual void cancelVibration() = 0;
 33
 34 virtual void vibrationDestroyed() = 0;
 35};
 36
 37void provideVibrationTo(Page*, VibrationClient*);
 38
 39} // namespace WebCore
 40
 41#endif // VibrationClient_h
 42

Tools/ChangeLog

 12012-02-17 Kihong Kwon <kihong.kwon@samsung.com>
 2
 3 Add a new API for the Vibration API(W3C).
 4 https://bugs.webkit.org/show_bug.cgi?id=72010
 5
 6 Reviewed by NOBODY (OOPS!).
 7
 8 * Scripts/build-webkit: Add ENABLE_VIBRATION feature.
 9
1102012-02-17 Dirk Pranke <dpranke@chromium.org>
211
312 The new run-webkit-tests needs to dump out pixel hash failures even if the pixel test passes.

Tools/Scripts/build-webkit

@@my (
128128 $tiledBackingStoreSupport,
129129 $touchEventsSupport,
130130 $touchIconLoadingSupport,
 131 $vibrationSupport,
131132 $videoSupport,
132133 $videoTrackSupport,
133134 $webAudioSupport,

@@my @features = (
329330 { option => "touch-icon-loading", desc => "Toggle Touch Icon Loading Support",
330331 define => "ENABLE_TOUCH_ICON_LOADING", default => 0, value => \$touchIconLoadingSupport },
331332
 333 { option => "vibration", desc => "Toggle Video support",
 334 define => "ENABLE_VIBRATION", default => 0, value => \$vibrationSupport },
 335
332336 { option => "video", desc => "Toggle Video support",
333337 define => "ENABLE_VIDEO", default => (isAppleWebKit() || isGtk() || isBlackBerry()), value => \$videoSupport },
334338