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

Unified Diff: third_party/WebKit/LayoutTests/vibration/resources/vibrate-from-iframe.html

Issue 2778693004: Remove navigator.vibrate without user gesture. (Closed)
Patch Set: reformat again! 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/vibration/resources/vibrate-from-iframe.html
diff --git a/third_party/WebKit/LayoutTests/vibration/resources/vibrate-from-iframe.html b/third_party/WebKit/LayoutTests/vibration/resources/vibrate-from-iframe.html
index 4bcf5f5895993c96940a697cc217f09086e45317..b1ab46760c5e6e84341ad93b86c68b23b419a8ae 100644
--- a/third_party/WebKit/LayoutTests/vibration/resources/vibrate-from-iframe.html
+++ b/third_party/WebKit/LayoutTests/vibration/resources/vibrate-from-iframe.html
@@ -1,7 +1,38 @@
<!DOCTYPE html>
+<script src="../../resources/testharness.js"></script>
+<script src="../../resources/testharnessreport.js"></script>
+<script src="../../resources/user-gesture-utils.js"></script>
<script>
'use strict';
-navigator.vibrate(1234);
+/*function startTest(event) {
mustaq 2017/04/13 14:28:34 Used code.
binlu 2017/04/13 15:11:11 Done.
+ // Simulates a user click for vibrate to be allowed.
+ // See: https://www.chromestatus.com/feature/5644273861001216.
+ //simulateUserClick("test", event);
+*/
+function startTest() {
+ if (window.eventSender) {
+ // Get iframe's Left Position
+ var iframes = window.parent.document.getElementsByTagName('iframe');
+ // The last iframe.
+ var iframe = iframes[iframes.length-1];
+ var element = document.getElementById("test");
+ eventSender.mouseMoveTo(element.offsetLeft + iframe.offsetLeft + 2, element.offsetTop + iframe.offsetTop + 2);
+ eventSender.mouseDown();
+ eventSender.mouseUp();
+ }
+}
+function testVibrate() {
+ test(function () {
+ assert_true(navigator.vibrate(200));
+ }, "An iframe may call navigator.vibrate with user gesture.");
+}
+
+// window.addEventListener("message", startTest, false);
</script>
+<body onload="startTest();">
+<button id="test" onclick="testVibrate();">Click to vibrate</button>
+</body>
+</html>
+

Powered by Google App Engine
This is Rietveld 408576698