-
Notifications
You must be signed in to change notification settings - Fork 6.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Treat long-press gesture as a user activation.
Also add a web-platform-test for this change, which is already supported by Firefox. Intent to ship: https://groups.google.com/a/chromium.org/d/msg/blink-dev/-2AyrUFwXvY/Q_wCUmKSAgAJ Spec change PR: whatwg/html#3659 Bug: 836401 Change-Id: Ia710190857211684ce5ce7d4ff835b874f658b29 Reviewed-on: https://chromium-review.googlesource.com/1039265 Reviewed-by: Dave Tapuska <dtapuska@chromium.org> Commit-Queue: Mustaq Ahmed <mustaq@chromium.org> Cr-Commit-Position: refs/heads/master@{#555450}
- Loading branch information
1 parent
d8a31d4
commit 8a2c87f
Showing
3 changed files
with
68 additions
and
0 deletions.
There are no files selected for viewing
58 changes: 58 additions & 0 deletions
58
...youtTests/external/wpt/html/user-activation/activation-thru-contextmenu-event-manual.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,58 @@ | ||
<!DOCTYPE html> | ||
<html> | ||
<head> | ||
<title>User activation with 'contextmenu' event</title> | ||
<meta content="text/html; charset=UTF-8" http-equiv="Content-Type"/> | ||
<link rel="author" title="Google" href="http://www.google.com "/> | ||
<link rel="help" href="https://html.spec.whatwg.org/#triggered-by-user-activation"> | ||
<script src="/resources/testharness.js"></script> | ||
<script src="/resources/testharnessreport.js"></script> | ||
<style> | ||
#target { | ||
width: 250px; | ||
height: 150px; | ||
float: left; | ||
background-color: green; | ||
} | ||
|
||
#done { | ||
float: left; | ||
padding: 20px; | ||
margin: 10px; | ||
} | ||
</style> | ||
<script type="text/javascript"> | ||
let activation_event_fired = false; | ||
|
||
function run() { | ||
let success = false; | ||
let test_contextmenu = async_test("'contextmenu' can call vibrate."); | ||
|
||
on_event(document.getElementById("done"), "click", () => { | ||
test_contextmenu.step(() => { | ||
assert_true(activation_event_fired, "activation event has fired"); | ||
}); | ||
test_contextmenu.done(); | ||
}); | ||
|
||
on_event(document.getElementById("target"), "contextmenu", (e) => { | ||
test_contextmenu.step(() => { | ||
e.preventDefault(); | ||
assert_true(navigator.vibrate(200), "navigator.vibrate is successful"); | ||
activation_event_fired = true; | ||
}); | ||
}); | ||
} | ||
</script> | ||
</head> | ||
<body onload="run()"> | ||
<h1>User activation with 'contextmenu' event</h1> | ||
<h4>Tests that a 'contextmenu' event is treated like a user activation.</h4> | ||
<ol> | ||
<li>Right-click or long-press on green.</li> | ||
<li>Click or tap on Done.</li> | ||
</ol> | ||
<div id="target"></div> | ||
<input type="button" id="done" value="Done" /> | ||
</body> | ||
</html> |
7 changes: 7 additions & 0 deletions
7
...pt_automation/html/user-activation/activation-thru-contextmenu-event-manual-automation.js
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,7 @@ | ||
importAutomationScript('/pointerevents/pointerevent_common_input.js'); | ||
|
||
function inject_input() { | ||
return mouseClickInTarget('#target', undefined, 'right').then(function() { | ||
return mouseClickInTarget('#done'); | ||
}); | ||
} |
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