From fbaf0bb26397aa498eb9156f06d5a6fe34dd7dd8 Mon Sep 17 00:00:00 2001 From: Daniel Baumann Date: Fri, 19 Apr 2024 03:14:29 +0200 Subject: Merging upstream version 125.0.1. Signed-off-by: Daniel Baumann --- .../tests/fenced-frame/resources/utils.js | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) (limited to 'testing/web-platform/tests/fenced-frame/resources') diff --git a/testing/web-platform/tests/fenced-frame/resources/utils.js b/testing/web-platform/tests/fenced-frame/resources/utils.js index cbea173f17..d6cca91437 100644 --- a/testing/web-platform/tests/fenced-frame/resources/utils.js +++ b/testing/web-platform/tests/fenced-frame/resources/utils.js @@ -250,6 +250,11 @@ function buildRemoteContextForObject(object, uuid, html) { } }; + // If `object` is null (e.g. a window created with noopener), set it to a + // dummy value so that the Proxy constructor won't fail. + if (object == null) { + object = {}; + } const proxy = new Proxy(object, handler); return proxy; } @@ -646,3 +651,19 @@ function setupCSP(csp, second_csp=null) { document.head.appendChild(second_meta); } } + +// Clicking in WPT tends to be flaky (https://crbug.com/1066891), so you may +// need to click multiple times to have an effect. This function clicks at +// coordinates `{x, y}` relative to `click_origin`, by default 3 times. Should +// not be used for tests where multiple clicks have distinct impact on the state +// of the page, but rather to bruteforce through flakes that rely on only one +// click. +async function multiClick(x, y, click_origin, times = 3) { + for (let i = 0; i < times; i++) { + let actions = new test_driver.Actions(); + await actions.pointerMove(x, y, {origin: click_origin}) + .pointerDown() + .pointerUp() + .send(); + } +} -- cgit v1.2.3