From 1bd10a5443982d5cad1da1183b988f4a18c2da81 Mon Sep 17 00:00:00 2001 From: Tim Ledbetter Date: Tue, 10 Dec 2024 16:41:37 +0000 Subject: [PATCH] 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. --- .../infrastructure/testdriver/click.txt | 6 ++++++ .../infrastructure/testdriver/click.html | 19 +++++++++++++++++++ .../wpt-import/resources/testdriver-vendor.js | 10 ++++++++++ 3 files changed, 35 insertions(+) create mode 100644 Tests/LibWeb/Text/expected/wpt-import/infrastructure/testdriver/click.txt create mode 100644 Tests/LibWeb/Text/input/wpt-import/infrastructure/testdriver/click.html diff --git a/Tests/LibWeb/Text/expected/wpt-import/infrastructure/testdriver/click.txt b/Tests/LibWeb/Text/expected/wpt-import/infrastructure/testdriver/click.txt new file mode 100644 index 00000000000..81464bc95c3 --- /dev/null +++ b/Tests/LibWeb/Text/expected/wpt-import/infrastructure/testdriver/click.txt @@ -0,0 +1,6 @@ +Harness status: OK + +Found 1 tests + +1 Pass +Pass TestDriver click method \ No newline at end of file diff --git a/Tests/LibWeb/Text/input/wpt-import/infrastructure/testdriver/click.html b/Tests/LibWeb/Text/input/wpt-import/infrastructure/testdriver/click.html new file mode 100644 index 00000000000..0d144b3d33e --- /dev/null +++ b/Tests/LibWeb/Text/input/wpt-import/infrastructure/testdriver/click.html @@ -0,0 +1,19 @@ + + +TestDriver click method + + + + + + + + diff --git a/Tests/LibWeb/Text/input/wpt-import/resources/testdriver-vendor.js b/Tests/LibWeb/Text/input/wpt-import/resources/testdriver-vendor.js index 2496b5f1830..a9beda369b1 100644 --- a/Tests/LibWeb/Text/input/wpt-import/resources/testdriver-vendor.js +++ b/Tests/LibWeb/Text/input/wpt-import/resources/testdriver-vendor.js @@ -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); };