Tests: Add vendor-specific testdriver click() function

This uses `Internals.click()` which doesn't do as much as the
equivalent WebDriver method, but should be enough to satify most tests
that use it.
This commit is contained in:
Tim Ledbetter 2024-12-10 16:41:37 +00:00 committed by Tim Flynn
commit 1bd10a5443
Notes: github-actions[bot] 2024-12-11 08:49:24 +00:00
3 changed files with 35 additions and 0 deletions

View file

@ -0,0 +1,6 @@
Harness status: OK
Found 1 tests
1 Pass
Pass TestDriver click method

View file

@ -0,0 +1,19 @@
<!DOCTYPE html>
<meta charset="utf-8">
<title>TestDriver click method</title>
<script src="../../resources/testharness.js"></script>
<script src="../../resources/testharnessreport.js"></script>
<script src="../../resources/testdriver.js"></script>
<script src="../../resources/testdriver-vendor.js"></script>
<button type="button" id="button">Button</button>
<script>
async_test(t => {
let button = document.getElementById("button");
test_driver
.click(button)
.then(() => t.done())
.catch(t.unreached_func("click failed"));
});
</script>

View file

@ -1,3 +1,13 @@
window.test_driver_internal.click = function(element) {
const boundingRect = element.getBoundingClientRect();
const centerPoint = {
x: boundingRect.left + boundingRect.width / 2,
y: boundingRect.top + boundingRect.height / 2
};
window.internals.click(centerPoint.x, centerPoint.y);
return Promise.resolve();
};
window.test_driver_internal.get_computed_label = async function(element) {
return await window.internals.getComputedLabel(element);
};