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 @@ ...@@ -92,7 +92,7 @@
function run() { function run() {
var target0 = document.getElementById("target0"); var target0 = document.getElementById("target0");
var btnComplete = document.getElementById("btnComplete"); var btnComplete = document.getElementById("btnComplete");
var clickIsReceived = false; var actions_promise;
// Check if touch-action attribute works properly for embedded divs // Check if touch-action attribute works properly for embedded divs
// Scrollable-Parent, Child: `auto`, Grand-Child: `none` // Scrollable-Parent, Child: `auto`, Grand-Child: `none`
...@@ -103,7 +103,11 @@ ...@@ -103,7 +103,11 @@
assert_equals(target0.scrollLeft, 0, "scroll x offset should be 0 in the end of the test"); 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"); 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(); updateDescriptionComplete();
}); });
...@@ -112,15 +116,11 @@ ...@@ -112,15 +116,11 @@
}); });
// Inject touch inputs. // Inject touch inputs.
touchScrollInTarget(scrollTarget, 'down').then(function() { actions_promise = touchScrollInTarget(scrollTarget, 'down');
return touchScrollInTarget(scrollTarget, 'right'); actions_promise.then(function() {
}).then(function() { touchScrollInTarget(scrollTarget, 'right');
return clickInTarget("touch", btnComplete);
}).then(function() { }).then(function() {
test_touchaction.step(function () { clickInTarget("touch", btnComplete);
assert_true(clickIsReceived, "click should be received before the test finishes");
}, "click should be received before the test finishes");
test_touchaction.done();
}); });
} }
</script> </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