Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(194)

Unified Diff: third_party/WebKit/LayoutTests/http/tests/security/vibration/vibrate-on-top-page-before-during-after-user-gesture.html

Issue 2778693004: Remove navigator.vibrate without user gesture. (Closed)
Patch Set: refactor SimulateUserClick Created 3 years, 8 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/LayoutTests/http/tests/security/vibration/vibrate-on-top-page-before-during-after-user-gesture.html
diff --git a/third_party/WebKit/LayoutTests/http/tests/security/vibration/vibrate-on-top-page-before-during-after-user-gesture.html b/third_party/WebKit/LayoutTests/http/tests/security/vibration/vibrate-on-top-page-before-during-after-user-gesture.html
new file mode 100644
index 0000000000000000000000000000000000000000..90846a6b88a3724d0ca9725014386fc0bce7805b
--- /dev/null
+++ b/third_party/WebKit/LayoutTests/http/tests/security/vibration/vibrate-on-top-page-before-during-after-user-gesture.html
@@ -0,0 +1,50 @@
+<html>
+<head>
+ <script src="/resources/testharness.js"></script>
mustaq 2017/04/13 19:05:04 Can you please add a <title> to describe the test
binlu 2017/04/13 19:55:27 Done.
+ <script src="/resources/testharnessreport.js"></script>
+ <script src="/js-test-resources/user-gesture-utils.js"></script>
+ <script>
+ var test = async_test(
mustaq 2017/04/13 19:05:04 Ditto about async_test.
binlu 2017/04/13 19:55:27 Done.
+ "Testing vibrate 3 times on the top page: " +
+ " 1. blocked before user gesture;" +
+ " 2. succeed during the click event;" +
+ " 3. succeed after user click.");
+ function startTest()
+ {
+ test.step(function() {
+ assert_false(
+ navigator.vibrate(200),
+ "1. Blocked vibrate before user gesture.");
+ });
+
+ // A manual click should enable vibrate.
+ var element = document.getElementById("test");
+ simulateUserClick(element.offsetLeft + 2, element.offsetTop + 2);
+ performTestWithClick();
+ }
+
+ function performTestWithClick()
+ {
+ test.step(function () {
+ assert_true(
+ navigator.vibrate(200),
+ "2. Vibrate triggered by user gesture succeeded.");
+ });
+ window.requestAnimationFrame(performTestAfterClick);
+ }
+
+ function performTestAfterClick()
+ {
+ test.step(function () {
+ assert_true(
+ navigator.vibrate(200),
+ "3. Vibrate after user gesture succeeded.");
+ });
+ test.done();
+ }
+ </script>
+</head>
+<body onload="startTest();">
+ <button id="test">Click to vibrate</button>
+</body>
+</html>

Powered by Google App Engine
This is Rietveld 408576698