Bug 1637197 [wpt PR 23526] - [uievents] Simplify dblclick test to make it fail fast, a=testonly

Automatic update from web-platform-tests
[uievents] Simplify dblclick test to make it fail fast (#23526)

Previously, if the actions_promise was rejected, which happens when
running manually, the test would simply time out.

This also renames the test to match sibling tests and make room for a
dblclick_event_touch.html to be added.
--

wpt-commits: d30f14a9935dc8c7627d668ae3111f0a75587184
wpt-pr: 23526
This commit is contained in:
Philip Jägenstedt 2020-05-26 11:25:37 +00:00 committed by moz-wptsync-bot
parent 6ca7f593a0
commit 89cb52b8ec
2 changed files with 44 additions and 55 deletions

View File

@ -0,0 +1,44 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>dblclick event for the mouse pointer type</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<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
{
background-color: green;
width: 200px;
height: 200px;
}
</style>
</head>
<body>
<p>Double-click on the green box with the left mouse button.</p>
<div id="target"></div>
<script>
promise_test(async (t) => {
const target = document.getElementById("target");
const event_watcher = new EventWatcher(t, target, ["click", "dblclick"]);
const actions_promise = new test_driver.Actions()
.pointerMove(0, 0, {origin: target})
.pointerDown()
.pointerUp()
.pointerDown()
.pointerUp()
.send();
// Make sure the test finishes after all the input actions are completed.
t.add_cleanup(() => actions_promise);
const event = await event_watcher.wait_for(["click", "click", "dblclick"]);
assert_equals(event.type, "dblclick");
assert_equals(event.target, target);
assert_equals(event.detail, 2);
});
</script>
</body>
</html>

View File

@ -1,55 +0,0 @@
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Double Click</title>
<link rel="author" title="Google" href="http://www.google.com/" />
<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 type="text/css">
.textarea
{
background: red;
width: 100px;
height: 100px;
color: white;
text-align: center;
font-family: monospace;
}
</style>
<script type="text/javascript">
// Send two continuous clicks.
function run() {
var testDoubleClick = async_test('Tests that the double click event is correctly generated by sending pointerDown, pointerUp, pointerDown and pointerUp for the mouse type.');
var elem = document.getElementById("click_area");
var actions_promise;
elem.addEventListener('dblclick', function(e) {
testDoubleClick.step(function () {
assert_equals(e.target.id, "click_area");
assert_equals(e.detail, 2);
});
// Make sure the test finishes after all the input actions are completed.
actions_promise.then( () => {
testDoubleClick.done();
});
});
actions_promise = new test_driver.Actions()
.pointerMove(0, 0, {origin: elem})
.pointerDown()
.pointerUp()
.pointerDown()
.pointerUp()
.send();
}
</script>
</head>
<body onload="run()">
<h1>Double Click</h1>
<p>Double-click on the text area and check if the "dblclick" event is received.</p>
<div id="click_area" class="textarea"></div>
</body>
</html>