Commit ad6362a1 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Simulate user inputs in activation-thru-contextmenu-event.html

Use testdriver Action API to simulate mouse actions in
html/user-activation/activation-thru-contextmenu-event.html.

Bug: 1145677
Change-Id: I8c287cd45d87e809cfa4b5967df38ed0b58d0d37
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2520453Reviewed-by: default avatarMustaq Ahmed <mustaq@chromium.org>
Commit-Queue: Lan Wei <lanwei@chromium.org>
Cr-Commit-Position: refs/heads/master@{#825963}
parent 26cd1e86
......@@ -8,6 +8,9 @@
<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>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-actions.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<style>
#target {
width: 250px;
......@@ -28,12 +31,16 @@
function run() {
let success = false;
let test_contextmenu = async_test("'contextmenu' can call vibrate.");
let actions_promise;
var target = document.getElementById("target");
var button = document.getElementById("done");
on_event(document.getElementById("done"), "click", () => {
test_contextmenu.step(() => {
assert_true(activation_event_fired, "activation event has fired");
});
test_contextmenu.done();
// Make sure the test finishes after all the input actions are completed.
actions_promise.then(() => test_contextmenu.done());
});
on_event(document.getElementById("target"), "contextmenu", (e) => {
......@@ -43,6 +50,17 @@
activation_event_fired = true;
});
});
// Inject mouse inputs.
var actions = new test_driver.Actions();
actions_promise = actions
.pointerMove(0, 0, {origin: target})
.pointerDown({button: actions.ButtonType.RIGHT})
.pointerUp({button: actions.ButtonType.RIGHT})
.pointerMove(0, 0, {origin: button})
.pointerDown()
.pointerUp()
.send();
}
</script>
</head>
......
importAutomationScript('/pointerevents/pointerevent_common_input.js');
function inject_input() {
return mouseClickInTarget('#target', undefined, /* right button */ 2).then(function() {
return mouseClickInTarget('#done');
});
}
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment