Vibration can be canceled even if page visibility status is hidden
authorkihong.kwon@samsung.com <kihong.kwon@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Jun 2013 08:07:40 +0000 (08:07 +0000)
committerkihong.kwon@samsung.com <kihong.kwon@samsung.com@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Wed, 19 Jun 2013 08:07:40 +0000 (08:07 +0000)
https://bugs.webkit.org/show_bug.cgi?id=117333

Reviewed by Gyuyoung Kim.

Source/WebCore:

vibration can be canceled in the onvisibilitychange listener even if page visibility is changed to hidden status.
Therefore cancelVibration needs to work when page visibility is hidden.

Tests: vibration/cancelVibration-after-pagevisibility-changed-to-hidden.html

* Modules/vibration/NavigatorVibration.cpp:
(WebCore::NavigatorVibration::vibrate):
* Modules/vibration/Vibration.h:
(WebCore::Vibration::isVibrating):
* testing/Internals.cpp:
(WebCore::Internals::isVibrating):
* testing/Internals.h:
* testing/Internals.idl:

LayoutTests:

Add a test case for cancel vibration after page visibility is changed to hidden status.
In addition, move navigator-vibration.html to vibration directory.

* platform/gtk/TestExpectations:
* platform/mac/TestExpectations:
* platform/qt/TestExpectations:
* platform/win/TestExpectations:
* vibration/cancelVibration-after-pagevisibility-changed-to-hidden-expected.txt: Added.
* vibration/cancelVibration-after-pagevisibility-changed-to-hidden.html: Added.
* vibration/navigator-vibration-expected.txt: Renamed from LayoutTests/fast/dom/navigator-vibration-expected.txt.
* vibration/navigator-vibration.html: Renamed from LayoutTests/fast/dom/navigator-vibration.html.

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@151727 268f45cc-cd09-0410-ab3c-d52691b4dbfc

15 files changed:
LayoutTests/ChangeLog
LayoutTests/platform/gtk/TestExpectations
LayoutTests/platform/mac/TestExpectations
LayoutTests/platform/qt/TestExpectations
LayoutTests/platform/win/TestExpectations
LayoutTests/vibration/cancelVibration-after-pagevisibility-changed-to-hidden-expected.txt [new file with mode: 0644]
LayoutTests/vibration/cancelVibration-after-pagevisibility-changed-to-hidden.html [new file with mode: 0644]
LayoutTests/vibration/navigator-vibration-expected.txt [moved from LayoutTests/fast/dom/navigator-vibration-expected.txt with 100% similarity]
LayoutTests/vibration/navigator-vibration.html [moved from LayoutTests/fast/dom/navigator-vibration.html with 77% similarity]
Source/WebCore/ChangeLog
Source/WebCore/Modules/vibration/NavigatorVibration.cpp
Source/WebCore/Modules/vibration/Vibration.h
Source/WebCore/testing/Internals.cpp
Source/WebCore/testing/Internals.h
Source/WebCore/testing/Internals.idl

index e73d451..7be04b1 100644 (file)
@@ -1,3 +1,22 @@
+2013-06-19  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        Vibration can be canceled even if page visibility status is hidden
+        https://bugs.webkit.org/show_bug.cgi?id=117333
+
+        Reviewed by Gyuyoung Kim.
+
+        Add a test case for cancel vibration after page visibility is changed to hidden status.
+        In addition, move navigator-vibration.html to vibration directory.
+
+        * platform/gtk/TestExpectations:
+        * platform/mac/TestExpectations:
+        * platform/qt/TestExpectations:
+        * platform/win/TestExpectations:
+        * vibration/cancelVibration-after-pagevisibility-changed-to-hidden-expected.txt: Added.
+        * vibration/cancelVibration-after-pagevisibility-changed-to-hidden.html: Added.
+        * vibration/navigator-vibration-expected.txt: Renamed from LayoutTests/fast/dom/navigator-vibration-expected.txt.
+        * vibration/navigator-vibration.html: Renamed from LayoutTests/fast/dom/navigator-vibration.html.
+
 2013-06-18  Gyuyoung Kim  <gyuyoung.kim@samsung.com>
 
         Unreviewed, EFL gardening. Added new baselines for some of editing/delete
index 1955695..89b909b 100644 (file)
@@ -273,7 +273,7 @@ webkit.org/b/71849 webgl [ Skip ]
 Bug(GTK) compositing/visible-rect [ Skip ]
 
 # Vibration API support not yet.
-webkit.org/b/99029 fast/dom/navigator-vibration.html [ Failure ]
+webkit.org/b/99029 vibration [ Failure ]
 
 # DumpRenderTree code to enable Java is currently a no-op
 webkit.org/b/99031 java [ Skip ]
index 91e6abc..e2c79a7 100644 (file)
@@ -521,7 +521,7 @@ media/W3C/video/canPlayType/canPlayType_two_implies_one_6.html
 webkit.org/b/78290 fast/dom/MutationObserver/end-of-task-delivery.html [ Failure ]
 
 # Needs PageClients::vibrationClient() implementation.
-webkit.org/b/72010 fast/dom/navigator-vibration.html
+webkit.org/b/72010 vibration
 
 # Touch adjustment not enabled
 webkit.org/b/78801 touchadjustment
index 8257bad..e07474a 100644 (file)
@@ -436,7 +436,7 @@ fast/canvas/webgl
 fast/parser/pre-html5-parser-quirks.html
 
 #Vibration API is not implemented.
-fast/dom/navigator-vibration.html
+vibration
 
 #Battery Status API is not implemented.
 batterystatus
index 626dc3a..489c2b6 100644 (file)
@@ -1782,7 +1782,7 @@ fast/inline/continuation-outlines-with-layers-2.html
 fast/repaint/transform-absolute-in-positioned-container.html
 
 #Vibration API is not implemented.
-fast/dom/navigator-vibration.html
+vibration
 
 # https://bugs.webkit.org/show_bug.cgi?id=82628
 svg/hittest/svg-ellipse-non-scale-stroke.xhtml
diff --git a/LayoutTests/vibration/cancelVibration-after-pagevisibility-changed-to-hidden-expected.txt b/LayoutTests/vibration/cancelVibration-after-pagevisibility-changed-to-hidden-expected.txt
new file mode 100644 (file)
index 0000000..3e95445
--- /dev/null
@@ -0,0 +1,12 @@
+Tests the cancelVibration after changing the value of pageVisibility to hidden.
+
+On success, you will see a series of "PASS" messages, followed by "TEST COMPLETE".
+
+
+PASS internals.isVibrating() is false
+PASS internals.isVibrating() is true
+PASS internals.isVibrating() is false
+PASS successfullyParsed is true
+
+TEST COMPLETE
+
diff --git a/LayoutTests/vibration/cancelVibration-after-pagevisibility-changed-to-hidden.html b/LayoutTests/vibration/cancelVibration-after-pagevisibility-changed-to-hidden.html
new file mode 100644 (file)
index 0000000..5dff382
--- /dev/null
@@ -0,0 +1,29 @@
+<html>
+<head>
+<script src="../fast/js/resources/js-test-pre.js"></script>
+</head>
+<body>
+<script>
+description('Tests the cancelVibration after changing the value of pageVisibility to hidden.');
+
+document.addEventListener('visibilitychange', function(e) {
+    if (document.visibilityState == 'hidden')
+        navigator.vibrate(0);
+        shouldBeFalse('internals.isVibrating()');
+        finishJSTest();
+    });
+
+shouldBeFalse('internals.isVibrating()');
+navigator.vibrate(10000);
+if (window.testRunner) {
+    setTimeout(function() {
+        shouldBeTrue('internals.isVibrating()');
+        testRunner.setPageVisibility('hidden');
+        }, 0);
+} else
+    debug('This test can not be run without the TestRunner');
+window.jsTestIsAsync = true;
+</script>
+<script src="../fast/js/resources/js-test-post.js"></script>
+</body>
+</html>
@@ -1,6 +1,6 @@
 <html>
 <head>
-<script src="../js/resources/js-test-pre.js"></script>
+<script src="../fast/js/resources/js-test-pre.js"></script>
 </head>
 <body>
 <script>
@@ -13,6 +13,6 @@ shouldBe("navigator.vibrate([1000, 300, 500]);", "undefined");
 shouldBe("navigator.vibrate(4294967295);", "undefined");
 shouldThrow("navigator.vibrate();");
 </script>
-<script src="../js/resources/js-test-post.js"></script>
+<script src="../fast/js/resources/js-test-post.js"></script>
 </body>
 </html>
index a5f8143..c3539e2 100644 (file)
@@ -1,3 +1,24 @@
+2013-06-19  Kihong Kwon  <kihong.kwon@samsung.com>
+
+        Vibration can be canceled even if page visibility status is hidden
+        https://bugs.webkit.org/show_bug.cgi?id=117333
+
+        Reviewed by Gyuyoung Kim.
+
+        vibration can be canceled in the onvisibilitychange listener even if page visibility is changed to hidden status.
+        Therefore cancelVibration needs to work when page visibility is hidden.
+
+        Tests: vibration/cancelVibration-after-pagevisibility-changed-to-hidden.html
+
+        * Modules/vibration/NavigatorVibration.cpp:
+        (WebCore::NavigatorVibration::vibrate):
+        * Modules/vibration/Vibration.h:
+        (WebCore::Vibration::isVibrating):
+        * testing/Internals.cpp:
+        (WebCore::Internals::isVibrating):
+        * testing/Internals.h:
+        * testing/Internals.idl:
+
 2013-06-18  Ryosuke Niwa  <rniwa@webkit.org>
 
         Input type range slider is not updated when min or max are changed
index 6614e08..e170470 100644 (file)
@@ -45,7 +45,7 @@ void NavigatorVibration::vibrate(Navigator* navigator, unsigned time, ExceptionC
         return;
 
 #if ENABLE(PAGE_VISIBILITY_API)
-    if (navigator->frame()->page()->visibilityState() == PageVisibilityStateHidden)
+    if (navigator->frame()->page()->visibilityState() == PageVisibilityStateHidden && time)
         return;
 #endif
 
index 9e2bc43..335ec60 100644 (file)
@@ -53,6 +53,8 @@ public:
     static Vibration* from(Page* page) { return static_cast<Vibration*>(Supplement<Page>::from(page, supplementName())); }
     static bool isActive(Page*);
 
+    bool isVibrating() { return m_isVibrating; }
+
 private:
     VibrationClient* m_vibrationClient;
     Timer<Vibration> m_timerStart;
index 454d31c..102af79 100644 (file)
 #include "SpeechSynthesis.h"
 #endif
 
+#if ENABLE(VIBRATION)
+#include "Vibration.h"
+#endif
+
 namespace WebCore {
 
 using namespace HTMLNames;
@@ -2161,4 +2165,14 @@ PassRefPtr<ClientRect> Internals::selectionBounds(ExceptionCode& ec)
     return ClientRect::create(document->frame()->selection()->bounds());
 }
 
+#if ENABLE(VIBRATION)
+bool Internals::isVibrating()
+{
+    Page* page = contextDocument()->page();
+    ASSERT(page);
+
+    return Vibration::from(page)->isVibrating();
+}
+#endif
+
 }
index 2ec93fb..1dd900a 100644 (file)
@@ -321,6 +321,10 @@ public:
 
     PassRefPtr<ClientRect> selectionBounds(ExceptionCode&);
 
+#if ENABLE(VIBRATION)
+    bool isVibrating();
+#endif
+
 private:
     explicit Internals(Document*);
     Document* contextDocument() const;
index 5fcd852..f9d833d 100644 (file)
 
     boolean isSelectPopupVisible(Node node);
 
+#if defined(ENABLE_VIBRATION) && ENABLE_VIBRATION
+    boolean isVibrating();
+#endif
+
     [RaisesException] ClientRect selectionBounds();
 };