-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Remove navigator.vibrate without user gesture.
Calls to navigator.vibrate will immediately return 'false' if user hasn't tapped on the frame or any embedded frame yet. The implementation is behind an experimental flag. The Intent to Deprecate thread: https://groups.google.com/a/chromium.org/forum/#!topic/blink-dev/QGcpjisxtik BUG=704650 Review-Url: https://codereview.chromium.org/2778693004 Cr-Commit-Position: refs/heads/master@{#465618} (cherry picked from commit c5b5911) Review-Url: https://codereview.chromium.org/2825403002 . Cr-Commit-Position: refs/branch-heads/3071@{#54} Cr-Branched-From: a106f0a-refs/heads/master@{#464641}
- Loading branch information
gogerald
committed
Apr 19, 2017
1 parent
338ccfc
commit 54365e6
Showing
40 changed files
with
410 additions
and
80 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
27 changes: 21 additions & 6 deletions
27
...ebKit/LayoutTests/http/tests/feature-policy/resources/feature-policy-vibrate-enabled.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,11 +1,26 @@ | ||
<!DOCTYPE html> | ||
<head> | ||
<title>Feature-Policy Vibrate Enabled</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
</head> | ||
<title>Feature-Policy Vibrate Enabled</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/js-test-resources/user-gesture-utils.js"></script> | ||
<script> | ||
test(function() { | ||
assert_true(navigator.vibrate(200)); | ||
|
||
function startTest(event) { | ||
// Simulates a user click for vibrate to be allowed. | ||
var element = document.getElementById("test"); | ||
simulateUserClick(element.offsetLeft + event.data.x + 2, element.offsetTop + event.data.y + 2); | ||
} | ||
|
||
function testVibrate() { | ||
test(function () { | ||
assert_true(navigator.vibrate(200)); | ||
}, 'Any iframe may call navigator.vibrate when enabled.'); | ||
} | ||
|
||
window.addEventListener("message", startTest, false); | ||
</script> | ||
<body> | ||
<button id="test" onclick="testVibrate();">Click to vibrate</button> | ||
</body> | ||
</html> |
1 change: 1 addition & 0 deletions
1
third_party/WebKit/LayoutTests/http/tests/feature-policy/vibrate-disabled-expected.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
...Kit/LayoutTests/http/tests/security/resources/same-origin-iframe-for-vibrate-allowed.html
This file was deleted.
Oops, something went wrong.
15 changes: 0 additions & 15 deletions
15
...d_party/WebKit/LayoutTests/http/tests/security/vibrate_in_same_origin_iframe_allowed.html
This file was deleted.
Oops, something went wrong.
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
54 changes: 54 additions & 0 deletions
54
...security/vibration/resources/vibrate-in-same-origin-iframe-with-user-gesture-allowed.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
<html> | ||
<head> | ||
<title>Testing vibrate 3 times in an iframe</title> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/js-test-resources/user-gesture-utils.js"></script> | ||
<script> | ||
function loaded() | ||
{ | ||
document.getElementsByTagName('h4')[0].innerHTML = document.domain; | ||
} | ||
|
||
function startTest(event) | ||
{ | ||
// A manual click should enable vibrate. | ||
if (window.eventSender) { | ||
test(function() { | ||
assert_true( | ||
navigator.vibrate(200), | ||
"1. Vibrate w/o user gesture is deprecated and will be blocked in M60."); | ||
}); | ||
var element = document.getElementById("b"); | ||
simulateUserClick(element.offsetLeft + event.data.x + 2, element.offsetTop + event.data.y + 2); | ||
} | ||
} | ||
|
||
function performTestAfterClick() | ||
{ | ||
test(function () { | ||
assert_true( | ||
navigator.vibrate(200), | ||
"3. Vibrate after user gesture succeeded."); | ||
}); | ||
} | ||
|
||
function performTestWithClick() | ||
{ | ||
test(function () { | ||
assert_true( | ||
navigator.vibrate(200), | ||
"2. Vibrate triggered by user gesture succeeded."); | ||
}); | ||
window.requestAnimationFrame(performTestAfterClick); | ||
} | ||
|
||
window.addEventListener("message", startTest, false); | ||
</script> | ||
</head> | ||
<body onload="loaded();"> | ||
<h4>DOMAIN</h4> | ||
<button id="b" onclick="performTestWithClick();">Perform Test</button> | ||
</body> | ||
</html> | ||
|
27 changes: 27 additions & 0 deletions
27
...ayoutTests/http/tests/security/vibration/resources/vibrate-with-user-gesture-allowed.html
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<script src="/js-test-resources/user-gesture-utils.js"></script> | ||
<script> | ||
|
||
function startTest(event) { | ||
// Simulates a user click for vibrate to be allowed. | ||
var element = document.getElementById("test"); | ||
simulateUserClick(element.offsetLeft + event.data.x + 2, element.offsetTop + event.data.y + 2); | ||
} | ||
|
||
function testVibrate() { | ||
test(function () { | ||
assert_true(navigator.vibrate(200)); | ||
}, "An iframe may call navigator.vibrate with user gesture."); | ||
} | ||
|
||
window.addEventListener("message", startTest, false); | ||
</script> | ||
</head> | ||
<body> | ||
<button id="test" onclick="testVibrate();">Click to vibrate</button> | ||
</body> | ||
</html> |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.