Commit 42f777c7 authored by Lan Wei's avatar Lan Wei Committed by Commit Bot

Use promise in wpt pointer event tests to finish the tests

Instead of adding a variable to check if the test is finished, we can
create a promise object and finish the test at its last callback.

Bug: 606367
Change-Id: Iabf281a1fffca85630683e79436a8b442057b824
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/1618002
Commit-Queue: Lan Wei <lanwei@chromium.org>
Reviewed-by: default avatarNavid Zolghadr <nzolghadr@chromium.org>
Cr-Commit-Position: refs/heads/master@{#663936}
parent fe061200
......@@ -92,7 +92,7 @@
function run() {
var target0 = document.getElementById("target0");
var btnComplete = document.getElementById("btnComplete");
var clickIsReceived = false;
var actions_promise;
// Check if touch-action attribute works properly for embedded divs
// Scrollable-Parent, Child: `auto`, Grand-Child: `none`
......@@ -103,7 +103,11 @@
assert_equals(target0.scrollLeft, 0, "scroll x offset should be 0 in the end of the test");
assert_equals(target0.scrollTop, 0, "scroll y offset should be 0 in the end of the test");
});
clickIsReceived = true;
// Make sure the test finishes after all the input actions are completed.
actions_promise.then( () => {
test_touchaction.done();
});
updateDescriptionComplete();
});
......@@ -112,15 +116,11 @@
});
// Inject touch inputs.
touchScrollInTarget(scrollTarget, 'down').then(function() {
return touchScrollInTarget(scrollTarget, 'right');
}).then(function() {
return clickInTarget("touch", btnComplete);
actions_promise = touchScrollInTarget(scrollTarget, 'down');
actions_promise.then(function() {
touchScrollInTarget(scrollTarget, 'right');
}).then(function() {
test_touchaction.step(function () {
assert_true(clickIsReceived, "click should be received before the test finishes");
}, "click should be received before the test finishes");
test_touchaction.done();
clickInTarget("touch", btnComplete);
});
}
</script>
......
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