10BC0 webdriver: Evaluate script commands via the `WebView` API in servoshell by longvatrong111 · Pull Request #37663 · servo/servo · GitHub
[go: up one dir, main page]

Skip to content

Conversation

longvatrong111
Copy link
Contributor
@longvatrong111 longvatrong111 commented Jun 24, 2025

Let WebDriverCommandMsg::ScriptCommand goes through embedder first.
Give embedder the ability to release webdriver from waiting for a response of ExecuteScript.

Tests: https://github.com/longvatrong111/servo/actions/runs/16071375821
No regression compared to CI run on main branch.

Fixes: #37370

cc: @xiaochengh

@longvatrong111 longvatrong111 requested a review from atbrakhi as a code owner June 24, 2025 05:33
@longvatrong111 longvatrong111 force-pushed the webdriver-script-command branch from 819e22e to a179956 Compare June 24, 2025 05:36
@wusyong
Copy link
Member
wusyong commented Jun 24, 2025

What's the motivation here. Is there any related issue?

@longvatrong111
Copy link
Contributor Author

What's the motivation here. Is there any related issue?

This PR is a follow up of #36714 (comment)

@wusyong wusyong added this pull request to the merge queue Jun 24, 2025
@yezhizhen
Copy link
Member
yezhizhen commented Jun 24, 2025

I am a bit worried about forward_webdriver_command. Commands that used to directly go to Constellation, now goes to embedder which does nothing but forwards it to Constellation. For example, verify_browsing_context_is_open.

I notice that the test execution speed goes down significantly after #36714. There seems to be an extra round of waiting after each subtest. Previously, it almost has no delay. (For example, many tests which used to took 4 seconds now took 30+ seconds. Probably because verify_browsing_context_is_open now goes through extra forwarding?)
cc @mrobinson @jdm @xiaochengh

@wusyong wusyong removed this pull request from the merge queue due to a manual request Jun 24, 2025
@longvatrong111
Copy link
Contributor Author
longvatrong111 commented Jun 24, 2025

I am a bit worried about forward_webdriver_command. Commands that used to directly go to Constellation, now goes to embedder which does nothing but forwards it to Constellation.

I notice that the test execution speed goes down significantly after #36714. There seems to be an extra round of waiting after each subtest. Previously, it almost has no delay. (For example, close_window test which used to took 4 seconds now took 20 seconds. And this is a crucial part for every other test.) cc @mrobinson @jdm @xiaochengh

We need to move all commands to servoshell then evaluate again.
The reason for ScriptCommand was discussed here #36714 (comment).
The extra time is caused by timeout because of no response, which is an issue we can fix later after moving all command. 1 extra forwarding can't take 25s.

@yezhizhen
Copy link
Member
yezhizhen commented Jun 24, 2025

We need to move all commands to servoshell then evaluate again. The reason for ScriptCommand was discussed here #36714 (comment).

I knew that. But I never think it is good idea to move commands that just does forwarding.

The extra time is caused by timeout because of no response, which is an issue we can fix later after moving all command. 1 extra forwarding can't take 25s.

No it is not TIMEOUT. Please run the test and check for yourself. Maybe checkout before #36714. Please read "There seems to be an extra round of waiting after each subtest."

@longvatrong111
Copy link
Contributor Author
longvatrong111 commented Jun 24, 2025

I knew that. But I never think it is good idea to move commands that just does forwarding.

It serves the purpose of synchronization. If script event has shorter route, it may be done out of order with others. In that case, we need to add a wait as well.

No it is not TIMEOUT. Please run the test and check for yourself. Maybe rollback before #36714. Please read "There seems to be an extra round of waiting after each subtest."

Maybe you want to run with #37555 or #37665
It doesn't take 30s. All webdriver context commands work together, it's too soon to evaluate if we only move a part of them.

I run the CI quite frequently, and with #37555, the time is similar as before.
https://github.com/longvatrong111/servo/actions/runs/15830757765

@yezhizhen
Copy link
Member
yezhizhen commented Jun 24, 2025

I definitely agree that navigation command should be moved.

It is just that, previously it immediately switches to the next subtest.. My eyes even cannot catch the speed. Right now there is a 1 second gap between each, leading to greatly increased total time. I'll investigate more once recovered.

It serves the purpose of synchronization. If script event has shorter route, it may be done out of order with others. In that case, we need to add a wait as well.

That makes sense. Thanks for clarification❤️ @longvatrong111

@longvatrong111
Copy link
Contributor Author

I definitely agree that navigation command should be moved.

It is just that, previously it immediately switches to the next subtest.. My eyes even cannot catch the speed. Right now there is a 1 second gap between each, leading to greatly increased total time. I'll investigate more once recovered.

It serves the purpose of synchronization. If script event has shorter route, it may be done out of order with others. In that case, we need to add a wait as well.

That makes sense. Thanks for clarification❤️ @longvatrong111

Let's move this one last. I will also check tests with all pieces of moving commands. Thank you.

@longvatrong111 longvatrong111 force-pushed the webdriver-script-command branch from a179956 to 5ea68e0 Compare June 25, 2025 06:29
@xiaochengh
Copy link
Contributor

This one looks pretty straightforward, but please request another review from me when it's ready to merge. Thanks!

@longvatrong111
Copy link
Contributor Author

We have more reason to move ScriptCommand to servoshell: #35734 (comment)

github-merge-queue bot pushed a commit that referenced this pull request Jul 1, 2025
…ndowSize` (#37712)

1. Remove the unnecessary new thread which use GetWindowRect command and
blocks for 500ms. Previously this is necessary because constellation
forward "resize" to embedder, and WebDriver wait for a constant
sufficient time to `GetWindowRect` in the new thread. This caused long
delay because there are many subtests and SetWindowRect is called
between each.
2. Remove `resize_timeout`
3. Return current dimension instead of 0 from embedder when it fails to
resize.
4. Do resizing as long as one of width/height is `Some`, according to
spec.

Testing: All Conformance test with new passing cases.
Fixes: #37663 (comment)

---------

Signed-off-by: Euclid Ye <yezhizhenjiakang@gmail.com>
@jdm jdm closed this in #37712 Jul 1, 2025
@yezhizhen yezhizhen reopened this Jul 1, 2025
@longvatrong111 longvatrong111 force-pushed the webdriver-script-command branch 5 times, most recently from fdb1500 to 87a1668 Compare July 4, 2025 08:56
@longvatrong111 longvatrong111 marked this pull request as ready for review July 4, 2025 08:57
@longvatrong111
Copy link
Contributor Author

Update expected test result based on: https://github.com/longvatrong111/servo/actions/runs/16120879305

@yezhizhen
Copy link
Member
yezhizhen commented Jul 8, 2025

Update expected test result based on: https://github.com/longvatrong111/servo/actions/runs/16120879305

This is confusing. Why these test expectations were newly added yesterday in 9afe027, but reverted again today?

@longvatrong111
Copy link
Contributor Author
longvatrong111 commented Jul 8, 2025

Update expected test result based on: https://github.com/longvatrong111/servo/actions/runs/16120879305

This is confusing. Why these test expectations were newly added yesterday in 9afe027, but reverted again today?

I see.
Test result in 9afe027 was updated according to local test. After that I ran the CI:
https://github.com/longvatrong111/servo/actions/runs/16089865593

So /webdriver/tests/classic/perform_actions/key_events.py and some sub-tests in perform_actions were wrongly updated in 9afe027.

Test result in this PR is updated according to https://github.com/longvatrong111/servo/actions/runs/16120879305
This PR actually fixes element_send_key, switch_to_window. For perform_actions it only fixes the wrong test result update from 9afe027

@longvatrong111
Copy link
Contributor Author

Current test result, some unexpected results remain because of intermittent result or CI give different result with local.
https://github.com/longvatrong111/servo/actions/runs/16133927807

@longvatrong111 longvatrong111 force-pushed the webdriver-script-command branch 2 times, most recently from e0023dc to 0f5224a Compare July 8, 2025 08:22
@longvatrong111 longvatrong111 added the T-linux-wpt Do a try run of the WPT label Jul 8, 2025
@github-actions github-actions bot removed the T-linux-wpt Do a try run of the WPT label Jul 8, 2025
Copy link
github-actions bot commented Jul 8, 2025

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

Copy link
github-actions bot commented Jul 8, 2025

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

Flaky unexpected result (17)
  • OK /content-security-policy/frame-ancestors/frame-ancestors-path-ignored.window.html (#36468)
    • PASS [expected FAIL] subtest: A 'frame-ancestors' CSP directive with a URL that includes a path should be ignored.
  • OK /css/css-cascade/layer-font-face-override.html (#35935)
    • PASS [expected FAIL] subtest: @font-face override update with appended sheet 1
    • PASS [expected FAIL] subtest: @font-face override update with appended sheet 2
  • OK [expected ERROR] /fetch/fetch-later/quota/same-origin-iframe/multiple-iframes.tentative.https.window.html (#35176)
  • OK /fetch/metadata/generated/css-font-face.https.sub.tentative.html (#32732)
    • PASS [expected FAIL] subtest: sec-fetch-dest
  • OK /fetch/metadata/generated/css-font-face.sub.tentative.html (#34624)
    • PASS [expected FAIL] subtest: sec-fetch-storage-access - Not sent to non-trustworthy cross-site destination
  • ERROR /fetch/metadata/generated/serviceworker.https.sub.html (#36247)
    • PASS [expected FAIL] subtest: sec-fetch-site - Same origin, no options - registration
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-cross-origin.sub.window.html (#29056)
    • PASS [expected FAIL] subtest: Cross-origin navigation started from unload handler must be ignored
  • OK /html/browsers/browsing-the-web/navigating-across-documents/replace-before-load/a-click.html (#28697)
    • PASS [expected FAIL] subtest: aElement.click() before the load event must NOT replace
  • TIMEOUT /html/browsers/history/the-history-interface/001.html (#12580)
    • FAIL [expected PASS] subtest: traversing history must also traverse hash changes

      assert_equals: (this could cause other failures later on) expected "" but got "test"
      

  • TIMEOUT [expected OK] /html/infrastructure/urls/base-url/document-base-url-window-initiator-is-not-opener.https.window.html (#30970)
  • TIMEOUT [expected CRASH] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-1.html (#22647)
  • OK /html/semantics/scripting-1/the-script-element/module/dynamic-import/blob-url.any.worker.html (#33909)
    • FAIL [expected PASS] subtest: Revoking a blob URL immediately after calling import will not fail

      promise_test: Unhandled rejection with value: object "TypeError: Dynamic import failed"
      

  • OK /html/webappapis/user-prompts/print-during-unload.html (#35944)
    • FAIL [expected PASS] subtest: print() during unload

      assert_array_equals: expected property 1 to be "destination" but got "error: window.print is not a function" (expected array ["start", "destination"] got ["start", "error: window.print is not a function"])
      

  • OK /preload/prefetch-document.html (#37210)
    • FAIL [expected PASS] subtest: different-site document prefetch with 'as=document' should not be consumed

      assert_equals: expected 2 but got 1
      

  • TIMEOUT [expected OK] /service-workers/service-worker/detached-context.https.html
    • TIMEOUT [expected FAIL] subtest: accessing navigator.serviceWorker on a detached iframe

      Test timed out
      

  • OK [expected TIMEOUT] /webmessaging/with-ports/017.html (#24486)
    • PASS [expected TIMEOUT] subtest: origin of the script that invoked the method, about:blank
  • ERROR [expected OK] /workers/baseurl/alpha/import-in-moduleworker.html (#21315)
Stable unexpected results that are known to be intermittent (24)
  • FAIL [expected PASS] /_mozilla/css/stacked_layers.html (#15988)
  • FAIL [expected PASS] /_mozilla/mozilla/sslfail.html (#10760)
  • TIMEOUT [expected OK] /_mozilla/mozilla/window_resize_event.html (#36741)
    • TIMEOUT [expected PASS] subtest: Popup onresize event fires after resizeTo

      Test timed out
      

  • OK /css/css-cascade/layer-cssom-order-reverse.html (#36094)
    • PASS [expected FAIL] subtest: Delete layer invalidates @font-face
  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-weight: '430' should prefer '450 460' over '500'

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

    • FAIL [expected PASS] subtest: Matching font-stretch: '90%' should prefer '90% 100%' over '50% 80%'

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

  • FAIL [expected PASS] /css/css-grid/grid-items/grid-auto-margin-and-replaced-item-001.html (#37162)
  • TIMEOUT [expected OK] /fetch/api/redirect/redirect-keepalive.https.any.html (#32153)
    • TIMEOUT [expected PASS] subtest: [keepalive][iframe][load] mixed content redirect; setting up

      Test timed out
      

  • ERROR [expected TIMEOUT] /fetch/fetch-later/quota/same-origin-iframe/max-payload.tentative.https.window.html (#35210)
  • OK /html/browsers/browsing-the-web/navigating-across-documents/005.html (#27062)
    • PASS [expected FAIL] subtest: Link with onclick navigation and href navigation
  • OK /html/browsers/browsing-the-web/navigating-across-documents/008.html (#24456)
    • PASS [expected FAIL] subtest: Link with onclick form submit to javascript url and href navigation
  • OK /html/browsers/browsing-the-web/navigating-across-documents/empty-iframe-load-event.html (#29066)
    • FAIL [expected PASS] subtest: Check execution order from nested timeout

      assert_equals: Expected nested setTimeout to run second expected true but got false
      

    • FAIL [expected PASS] subtest: Check execution order on load handler

      assert_equals: Expected onload to run first expected false but got true
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/initial-empty-document/load-pageshow-events-iframe-contentWindow.html (#28681)
    • PASS [expected FAIL] subtest: load &amp; pageshow events do not fire on contentWindow of &lt;iframe&gt; element created with src='about:blank'
  • OK /html/browsers/history/the-history-interface/traverse_the_history_5.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 5 but got 3 (expected array [6, 5] got [6, 3])
      

  • FAIL [expected PASS] /html/canvas/element/manual/drawing-text-to-the-canvas/canvas.2d.disconnected-font-size-math.html (#30063)
  • TIMEOUT /html/interaction/focus/the-autofocus-attribute/supported-elements.html (#24145)
    • TIMEOUT [expected FAIL] subtest: Element with tabindex should support autofocus

      Test timed out
      

  • OK /html/semantics/embedded-content/the-iframe-element/iframe-loading-lazy-nav-location-assign.html (#32863)
    • PASS [expected FAIL] subtest: Navigating iframe loading='lazy' before it is loaded: location.assign
  • CRASH [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-2.html (#22667)
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_escaping-3.html (#24057)
  • CRASH [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-2.html (#22154)
  • OK [expected TIMEOUT] /html/semantics/embedded-content/the-iframe-element/iframe_sandbox_popups_nonescaping-3.html (#24066)
  • OK /preload/preload-error.sub.html (#37177)
    • FAIL [expected PASS] subtest: success (style): main

      assert_greater_than: http://web-platform.test:8000/preload/resources/dummy.css?label=style should be loaded expected a number greater than 0 but got 0
      

    • PASS [expected FAIL] subtest: 404 (xhr): main
    • FAIL [expected PASS] subtest: Decode-error (style): main

      assert_greater_than: http://web-platform.test:8000/preload/resources/dummy.xml?pipe=header%28Content-Type%2Ctext%2Fcss%29&amp;label=style should be loaded expected a number greater than 0 but got 0
      

    • PASS [expected FAIL] subtest: MIME-error (script): main
  • CRASH [expected TIMEOUT] /trusted-types/trusted-types-navigation.html?06-10 (#37920)
  • TIMEOUT [expected OK] /webmessaging/with-ports/018.html (#24485)
    • TIMEOUT [expected PASS] subtest: origin of the script that invoked the method, javascript:

      Test timed out
      

  • OK [expected ERROR] /workers/constructors/Worker/Worker-constructor.html (#22991)

Copy link
github-actions bot commented Jul 8, 2025

✨ Try run (#16151610342) succeeded.

@longvatrong111
Copy link
Contributor Author

Hi @mrobinson, I think this one is ready to be merged.

@longvatrong111 longvatrong111 force-pushed the webdriver-script-command branch from 0f5224a to 1e78893 Compare July 9, 2025 05:56
@longvatrong111 longvatrong111 requested a review from gterzian as a code owner July 9, 2025 05:56
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
Signed-off-by: batu_hoang <longvatrong111@gmail.com>
@longvatrong111 longvatrong111 force-pushed the webdriver-script-command branch from 1e78893 to 3ec4f85 Compare July 9, 2025 05:57
@mrobinson mrobinson changed the title Move webdriver script command to servoshell webdriver: Evaluate script commands via the WebView API in servoshell Jul 9, 2025
@mrobinson mrobinson force-pushed the webdriver-script-command branch from e7a259d to 03c16e4 Compare July 9, 2025 13:23
Comment on lines 421 to 427
// From <https://w3c.github.io/webdriver/#dfn-execute-a-function-body>:
// > The rules to execute a function body are as follows. The algorithm returns
// > an ECMAScript completion record.
// >
// > If at any point during the algorithm a user prompt appears, immediately return
// > Completion { Type: normal, Value: null, Target: empty }, but continue to run the
// > other steps of this algorithm in parallel.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// From <https://w3c.github.io/webdriver/#dfn-execute-a-function-body>:
// > The rules to execute a function body are as follows. The algorithm returns
// > an ECMAScript completion record.
// >
// > If at any point during the algorithm a user prompt appears, immediately return
// > Completion { Type: normal, Value: null, Target: empty }, but continue to run the
// > other steps of this algorithm in parallel.
/// From <https://w3c.github.io/webdriver/#dfn-execute-a-function-body>:
/// > The rules to execute a function body are as follows. The algorithm returns
/// > an ECMAScript completion record.
// >
/// > If at any point during the algorithm a user prompt appears, immediately return
/// > Completion { Type: normal, Value: null, Target: empty }, but continue to run the
/// > other steps of this algorithm in parallel.

- Avoid cloning the entire WebDriver message. Just clone the sender.
- Adjust the documentation to be rustdoc.

Signed-off-by: Martin Robinson <mrobinson@igalia.com>
@mrobinson mrobinson force-pushed the webdriver-script-command branch from 03c16e4 to b2891e2 Compare July 9, 2025 13:23
@mrobinson mrobinson enabled auto-merge July 9, 2025 13:24
@mrobinson mrobinson added this pull request to the merge queue Jul 9, 2025
Merged via the queue into servo:main with commit 4499fde Jul 9, 2025
21 checks passed
@longvatrong111 longvatrong111 deleted the webdriver-script-command branch July 9, 2025 15:56
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.

[webdriver] Moving webdriver to servoshell
5 participants
0