testharness.js bless() method not working for cross-origin iframes
rdar://165737231 https://bugs.webkit.org/show_bug.cgi?id=303448 Reviewed by Wenson Hsieh. test_driver.click() computes an element's click point in the element's own frame-local coordinates, but WebKitTestRunner's synthetic click is hit-tested from the top window. For a button in an offset or cross-origin iframe the two spaces differ, so bless()'s click missed its target and the test timed out. Resolve the click point into top-window (root-view) coordinates before dispatching: add Internals.boundingBoxInRootViewCoordinates(element) and, in testdriver-vendor.js, shift testdriver.js's frame-local point by the element's frame-to-root-view offset. For a top-level element the offset is zero, so top-level clicks are unchanged; only subframe clicks move. This replaces the earlier interim shim that granted activation directly via internals. Because test_driver.click() now lands in subframes, several replace-before-load tests that relied on a click into a subframe navigating the frame now pass, and their stale FAIL baselines are updated to PASS. On the iOS WPT bot the same subframe clicks make three user-activation tests pass (their stale iPad expectations are removed), and the Digital Credentials default-permissions-policy test now runs to completion producing its DC-on output on iOS (which enables the feature), so an iOS baseline is added for it. Two follow-ups are tracked and their affected cases contained rather than fixed here: one bless-nested subtest expects the spec-correct result but currently fails because WebKit over-activates a same-origin frame nested below a clicked cross-origin frame (webkit.org/b/318749); its committed baseline records that failure. Under site isolation the coordinate resolution cannot cross a RemoteFrame (cross-process) boundary, so the cross-origin bless tests are skipped on mac-site-isolation (webkit.org/b/318763). The same-process mapping also does not yet account for CSS transforms on an ancestor iframe (webkit.org/b/318752). * Source/WebCore/testing/Internals.idl: * Source/WebCore/testing/Internals.h: * Source/WebCore/testing/Internals.cpp: (WebCore::Internals::boundingBoxInRootViewCoordinates): Return an element's border-box in root-view (top window) coordinates, for the test-driver click path. * LayoutTests/resources/testdriver-vendor.js: (window.test_driver_internal.click): For an element in a subframe, shift testdriver's frame-local click point to root-view coordinates via internals.boundingBoxInRootViewCoordinates(); top-level elements need no shift. Remove the interim internals-withUserGesture bless shim. * LayoutTests/http/wpt/user-activation/bless.html: Added. * LayoutTests/http/wpt/user-activation/bless-expected.txt: Added. * LayoutTests/http/wpt/user-activation/bless-nested.sub.html: Added. * LayoutTests/http/wpt/user-activation/bless-nested.sub-expected.txt: Added. * LayoutTests/http/wpt/user-activation/bless-edge-cases.sub.html: Added. * LayoutTests/http/wpt/user-activation/bless-edge-cases.sub-expected.txt: Added. * LayoutTests/http/wpt/user-activation/resources/bless-relay.sub.html: Added. * LayoutTests/http/wpt/user-activation/resources/click-target.html: Added. * LayoutTests/http/wpt/user-activation/resources/iframe.html: Added. * LayoutTests/http/wpt/user-activation/click-offset-subframe-scrolled.html: Added. * LayoutTests/http/wpt/user-activation/click-offset-subframe-scrolled-expected.txt: Added. Regression test: test_driver.click lands on a target inside an offset subframe while the top document is scrolled, exercising the frame-to-root-view coordinate shift. Fails without the shift and passes with it, on both macOS and iOS. * LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-user-click-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-user-click-during-pageshow-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-assign-user-click-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-click-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/location-setter-user-mouseup-expected.txt: Rebaseline to PASS: the subframe click now lands, so the expected navigation occurs. * LayoutTests/platform/mac-site-isolation/TestExpectations: Skip the bless tests under site isolation pending the cross-process coordinate path (webkit.org/b/318763). * LayoutTests/imported/w3c/web-platform-tests/digital-credentials/create.disabled-by-permissions-policy.https.sub-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/digital-credentials/default-permissions-policy.https.sub-expected.txt: * LayoutTests/imported/w3c/web-platform-tests/digital-credentials/get.disabled-by-permissions-policy.https.sub-expected.txt: Reset baselines now that these tests run to completion instead of timing out. * LayoutTests/platform/ios/imported/w3c/web-platform-tests/digital-credentials/default-permissions-policy.https.sub-expected.txt: Added. iOS enables Digital Credentials, so get() is available there; add an iOS baseline with the DC-on output (get() passes) instead of falling back to the DC-off generic baseline. * LayoutTests/platform/glib/TestExpectations: Skip the screen-orientation subframe tests that now run to completion but fail on features not supported there. * LayoutTests/platform/mac-wk2/TestExpectations: Skip the screen-orientation and storage-access-beyond-cookies subframe tests that now run to completion but fail on features not supported there, and mark the digital-credentials default-permissions-policy test [ Debug ] [ Failure ]: DigitalCredentials is enabled in debug Cocoa builds but not release, so it diverges from the DC-off baseline only on debug. * LayoutTests/platform/ipad/TestExpectations: Remove the stale [ Failure ] expectations for the user-activation consumption-sameorigin, propagation-sameorigin, and propagation-crossorigin tests, which now pass because test_driver.click() lands in the subframe. Canonical link: https://commits.webkit.org/317287@main
M
Marcos Caceres committed
ad6fed49234ba17515e45f0c8d283f52cd464a15
Parent: 3e5698d