Skip to content

script: Add support for polygons in HtmlAreaElement::hit_test #37064

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 24, 2025

Conversation

arihant2math
Copy link
Contributor

@arihant2math arihant2math commented May 21, 2025

Uses raycasting to determine whether point is in polygon

Testing: Added unittest
Fixes: None to my knowledge

@arihant2math arihant2math requested a review from gterzian as a code owner May 21, 2025 07:14
@sebsebmc sebsebmc added the T-linux-wpt Do a try run of the WPT label May 21, 2025
@github-actions github-actions bot removed the T-linux-wpt Do a try run of the WPT label May 21, 2025
Copy link

🔨 Triggering try run (#15167451005) for Linux (WPT)

Copy link

Test results for linux-wpt from try job (#15167451005):

Flaky unexpected result (24)
  • OK /FileAPI/url/url-with-fetch.any.html (#21517)
    • FAIL [expected PASS] subtest: Revoke blob URL after calling fetch, fetch should succeed

      promise_test: Unhandled rejection with value: object "TypeError: Network error occurred"
      

  • OK /FileAPI/url/url-with-fetch.any.worker.html (#21517)
    • PASS [expected FAIL] subtest: Revoke blob URL after calling fetch, fetch should succeed
  • TIMEOUT [expected OK] /_mozilla/mozilla/window_resizeTo.html (#36741)
    • TIMEOUT [expected PASS] subtest: Popup onresize event fires after resizeTo

      Test timed out
      

  • TIMEOUT [expected OK] /_webgl/conformance/uniforms/out-of-bounds-uniform-array-access.html (#26225)
    • NOTRUN [expected PASS] subtest: Overall test
  • PASS [expected FAIL] /css/compositing/mix-blend-mode/mix-blend-mode-video-sibling.html (#32849)
  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-weight: '500' should prefer '500' over '450 460'

      assert_equals: Unexpected font on test element expected 487 but got 532
      

  • FAIL [expected PASS] /css/css-overflow/line-clamp/line-clamp-with-floats-010.tentative.html (#35018)
  • FAIL [expected PASS] /css/css-sizing/dynamic-available-size-iframe.html (#31559)
  • PASS [expected FAIL] /css/selectors/invalidation/any-link-attribute-removal.html (#35054)
  • OK /custom-elements/form-associated/ElementInternals-setFormValue.html (#29174)
    • PASS [expected FAIL] subtest: Multiple values - name content attribute is ignored
  • OK /html/browsers/browsing-the-web/overlapping-navigations-and-traversals/cross-document-nav-cross-document-nav.html (#29181)
    • PASS [expected FAIL] subtest: cross-document navigation then cross-document navigation
  • ERROR [expected OK] /html/canvas/element/manual/imagebitmap/createImageBitmap-transfer.html (#34119)
  • CRASH [expected OK] /html/dom/elements/the-innertext-and-outertext-properties/getter.html (#37070)
  • TIMEOUT [expected OK] /html/interaction/focus/the-autofocus-attribute/update-the-rendering.html (#24145)
    • TIMEOUT [expected FAIL] subtest: "Flush autofocus candidates" should be happen before a scroll event and animation frame callbacks

      Test timed out
      

  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html (#22667)
    • FAIL [expected TIMEOUT] subtest: Check that popups from a sandboxed iframe escape the sandbox if allow-popups-to-escape-sandbox is used

      assert_equals: It came from a sandboxed iframe expected "null" but got "http://web-platform.test:8000"
      

  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
    • FAIL [expected NOTRUN] subtest: Check that popups from a sandboxed iframe do not escape the sandbox

      assert_equals: It came from a sandboxed iframe expected "null" but got "http://web-platform.test:8000"
      

  • OK /html/semantics/forms/form-submission-0/text-plain.window.html (#28687)
    • PASS [expected FAIL] subtest: text/plain: Basic test (formdata event)
  • OK /html/semantics/forms/form-submission-0/urlencoded2.window.html (#28687)
    • PASS [expected FAIL] subtest: application/x-www-form-urlencoded: Basic test (formdata event)
    • PASS [expected FAIL] subtest: application/x-www-form-urlencoded: \r\n in filename (normal form)
  • OK /html/semantics/forms/historical.html (#28568)
    • PASS [expected FAIL] subtest: <input name=isindex> should not be supported
  • TIMEOUT [expected OK] /resource-timing/nested-context-navigations-iframe.html (#24311)
    • TIMEOUT [expected PASS] subtest: Test that iframe navigations are not observable by the parent, even after history navigations by the parent

      Test timed out
      

    • NOTRUN [expected PASS] subtest: Test that crossorigin iframe navigations are not observable by the parent, even after history navigations by the parent
    • NOTRUN [expected PASS] subtest: Test that cross-site iframe navigations are not observable by the parent, even after history navigations by the parent
    • NOTRUN [expected PASS] subtest: Test that iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that crossorigin iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that cross-site iframe navigations are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that iframe refreshes are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that crossorigin iframe refreshes are not observable by the parent
    • NOTRUN [expected PASS] subtest: Test that cross-site iframe refreshes are not observable by the parent
  • TIMEOUT /resource-timing/test_resource_timing.html (#25720)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (img)
  • TIMEOUT /resource-timing/test_resource_timing.https.html (#25216)
    • PASS [expected FAIL] subtest: PerformanceEntry has correct name, initiatorType, startTime, and duration (img)
  • TIMEOUT [expected OK] /webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.html (#29053)
    • TIMEOUT [expected PASS] subtest: StorageKey: test 3P about:blank window opened from a 3P iframe

      Test timed out
      

  • ERROR [expected OK] /workers/constructors/Worker/Worker-constructor.html (#22991)
Stable unexpected results that are known to be intermittent (16)
  • FAIL [expected PASS] /_mozilla/css/dirty_viewport.html (#13731)
  • OK /_webgl/conformance/textures/misc/texture-upload-size.html (#21770)
    • FAIL [expected PASS] subtest: WebGL test #60

      assert_true: could not create image (SVG) expected true got false
      

  • PASS [expected FAIL] /css/css-overflow/overflow-video.html (#34720)
  • FAIL [expected PASS] /css/css-tables/table-cell-overflow-auto-scrolled.html (#35011)
  • OK /fetch/metadata/generated/css-font-face.https.sub.tentative.html (#32732)
    • PASS [expected FAIL] subtest: sec-fetch-dest
    • PASS [expected FAIL] subtest: sec-fetch-user
    • PASS [expected FAIL] subtest: sec-fetch-storage-access - Cross-site
    • PASS [expected FAIL] subtest: sec-fetch-storage-access - Same site
  • OK [expected ERROR] /fetch/nosniff/importscripts.html (#27144)
    • PASS [expected TIMEOUT] subtest: Test importScripts()
  • OK /html/browsers/browsing-the-web/navigating-across-documents/009.html (#24456)
    • FAIL [expected PASS] subtest: Link with onclick form submit to javascript url with document.write and href navigation

      assert_array_equals: expected property 1 to be "href" but got "click" (expected array ["write", "href"] got ["write", "click"])
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-nosrc.html (#34819)
    • PASS [expected FAIL] subtest: link click
    • FAIL [expected PASS] subtest: form submission

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?1=" but got "about:blank"
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/iframe-src-aboutblank-navigate-immediately.html (#29048)
    • FAIL [expected PASS] subtest: Navigating to a different document with form submission

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?1=" but got "about:blank"
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html (#28697)
    • FAIL [expected PASS] subtest: aElement.click() before the load event must NOT replace

      assert_equals: expected "http://web-platform.test:8000/common/blank.html?thereplacement" but got "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/resources/code-injector.html?pipe=sub(none)&code=%0A%20%20%20%20const%20a%20%3D%20document.createElement(%22a%22)%3B%0A%20%20%20%20a.href%20%3D%20%22%2Fcommon%2Fblank.html%3Fthereplacement%22%3B%0A%20%20%20%20document.currentScript.before(a)%3B%0A%20%20%20%20a.click()%3B%0A%20%20"
      

  • OK /html/browsers/history/the-history-interface/traverse_the_history_3.html (#21383)
    • FAIL [expected PASS] subtest: Multiple history traversals, last would be aborted

      assert_array_equals: Pages opened during history navigation expected property 1 to be 3 but got 2 (expected array [6, 3] got [6, 2])
      

  • PASS [expected FAIL] /html/canvas/element/manual/drawing-text-to-the-canvas/canvas.2d.disconnected-font-size-math.html (#30063)
  • TIMEOUT /html/canvas/element/manual/imagebitmap/createImageBitmap-origin.sub.html (#31931)
    • TIMEOUT [expected FAIL] subtest: redirected to cross-origin HTMLVideoElement: origin unclear bitmaprenderer.transferFromImageBitmap

      Test timed out
      

    • NOTRUN [expected FAIL] subtest: redirected to same-origin HTMLVideoElement: origin unclear getImageData
    • NOTRUN [expected FAIL] subtest: redirected to same-origin HTMLVideoElement: origin unclear 2dContext.drawImage
    • NOTRUN [expected FAIL] subtest: redirected to same-origin HTMLVideoElement: origin unclear bitmaprenderer.transferFromImageBitmap
    • NOTRUN [expected FAIL] subtest: unclean HTMLCanvasElement: origin unclear getImageData
    • NOTRUN [expected FAIL] subtest: unclean HTMLCanvasElement: origin unclear 2dContext.drawImage
    • NOTRUN [expected FAIL] subtest: unclean HTMLCanvasElement: origin unclear bitmaprenderer.transferFromImageBitmap
    • NOTRUN [expected FAIL] subtest: unclean ImageBitmap: origin unclear getImageData
    • NOTRUN [expected FAIL] subtest: unclean ImageBitmap: origin unclear 2dContext.drawImage
    • NOTRUN [expected FAIL] subtest: unclean ImageBitmap: origin unclear bitmaprenderer.transferFromImageBitmap
  • OK [expected TIMEOUT] /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • FAIL [expected NOTRUN] subtest: Host element with delegatesFocus should support autofocus

      assert_equals: expected Element node <div autofocus=""></div> but got Element node <body><div autofocus=""></div></body>
      

    • FAIL [expected NOTRUN] subtest: Host element with delegatesFocus including no focusable descendants should be skipped

      assert_equals: expected Element node <input autofocus=""></input> but got Element node <body><div autofocus=""></div><input autofocus=""></body>
      

    • FAIL [expected NOTRUN] subtest: Area element should support autofocus

      promise_test: Unhandled rejection with value: object "TypeError: w.document.querySelector(...) is null"
      

  • TIMEOUT /html/semantics/embedded-content/the-canvas-element/security.pattern.fillStyle.sub.html (#36989)
    • FAIL [expected TIMEOUT] subtest: redirected to same-origin HTMLVideoElement: Setting fillStyle to an origin-unclean pattern makes the canvas origin-unclean

      promise_test: Unhandled rejection with value: object "TypeError: argument could not be converted to any of: HTMLImageElement, HTMLCanvasElement, OffscreenCanvas, CSSStyleValue"
      

    • PASS [expected NOTRUN] subtest: unclean HTMLCanvasElement: Setting fillStyle to an origin-unclean pattern makes the canvas origin-unclean
    • FAIL [expected NOTRUN] subtest: unclean ImageBitmap: Setting fillStyle to an origin-unclean pattern makes the canvas origin-unclean

      promise_test: Unhandled rejection with value: object "NotSupportedError: The operation is not supported."
      

    • PASS [expected NOTRUN] subtest: cross-origin HTMLImageElement: Setting fillStyle to an origin-unclean offscreen canvas pattern makes the canvas origin-unclean
    • FAIL [expected NOTRUN] subtest: cross-origin SVGImageElement: Setting fillStyle to an origin-unclean offscreen canvas pattern makes the canvas origin-unclean

      promise_test: Unhandled rejection with value: object "[object Event]"
      

    • TIMEOUT [expected NOTRUN] subtest: cross-origin HTMLVideoElement: Setting fillStyle to an origin-unclean offscreen canvas pattern makes the canvas origin-unclean

      Test timed out
      

  • OK /webaudio/the-audio-api/the-audiobuffersourcenode-interface/sub-sample-buffer-stitching.html (#22849)
    • FAIL [expected PASS] subtest: X Stitched sine-wave buffers at sample rate 43800 does not equal [0,0.06264832615852356,0.12505052983760834,0.18696144223213196,0.24813786149024963,0.308339387178421,0.36732959747314453,0.4248766601085663,0.480754554271698,0.5347436666488647,0.5866320133209229,0.6362156271934509,0.6832997798919678,0.7276994585990906,0.7692402601242065,0.8077589869499207...] with an element-wise tolerance of {"absoluteThreshold":0.0038986,"relativeThreshold":0}. Index Actual Expected AbsError RelError Test threshold [14650] 6.2289451923530376e-15 8.6956524848937988e-1 8.6956524848937367e-1 9.9999999999999289e-1 3.8985999999999999e-3 [14651] 3.0547976493835449e-1 8.9879405498504639e-1 5.9331429004669189e-1 6.6012262403823208e-1 3.8985999999999999e-3 Max AbsError of 8.6956524848937367e-1 at index of 14650. Max RelError of 9.9999999999999289e-1 at index of 14650.

      assert_true: expected true got false
      

    • FAIL [expected PASS] subtest: X SNR (42.96525288004429 dB) is not greater than or equal to 65.737. Got 42.96525288004429.

      assert_true: expected true got false
      

Copy link

✨ Try run (#15167451005) succeeded.

@sebsebmc
Copy link
Contributor

sebsebmc commented May 21, 2025

I believe there are some HTMLAreaElement WPT tests but they rely on elementFromPoint that still fail with this change.
There are unit tests to update in tests/unit/script/htmlareaelement.rs

@arihant2math
Copy link
Contributor Author

There is a polygon hit_test unittest but that doesn't seem to have been affected.

@sebsebmc
Copy link
Contributor

Yeah that test has 2 asserts that test for not hitting, and the old code only returned false so of course it passed. It would be good to add some tests that actually test for returning a hit.

@arihant2math
Copy link
Contributor Author

I've added tests that pass.

Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
Signed-off-by: Ashwin Naren <arihant2math@gmail.com>
@mrobinson mrobinson changed the title hit_test for HtmlAreaElement polygons script: Add support for polygons in HtmlAreaElement::hit_test May 24, 2025
@mrobinson mrobinson added this pull request to the merge queue May 24, 2025
Merged via the queue into servo:main with commit 0ed2c48 May 24, 2025
22 checks passed
@arihant2math arihant2math deleted the polygon-area branch May 24, 2025 15:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants