Skip to content

webdriver: Move navigation status tracking from script to constellation + Wait for navigation complete - #49817

Merged
jdm merged 3 commits into
servo:mainfrom
yezhizhen:fix-int-partial
Nov 16, 2026
Merged

jdm merged 3 commits into
servo:mainfrom
yezhizhen:fix-int-partial

Conversation

@yezhizhen

@yezhizhen yezhizhen commented Nov 11, 2026 •

Copy link
Copy Markdown
Member

This is done in two commits:

  • Report navigation and load statuses from the Constellation instead of script thread. This ends up with simpler model overall.
  • Implement step 6.4 for the WebDriver processing model to wait for navigation complete before each command.

Testing: Several tests stop CRASH.
Part of #42802

@yezhizhen
yezhizhen requested a review from gterzian as a code owner November 11, 2026 09:16
@servo-highfive servo-highfive added the S-awaiting-review There is new code that needs to be reviewed. label Nov 11, 2026
@yezhizhen yezhizhen changed the title webdriver: Wait for navigation to complete before running commands webdriver: Move navigation status tracking from script to constellation + Wait for navigation complete Nov 11, 2026
@yezhizhen
yezhizhen requested a review from jdm November 11, 2026 09:19
@yezhizhen yezhizhen added the T-linux-wpt Do a try run of the WPT label Nov 11, 2026
@github-actions github-actions Bot removed the T-linux-wpt Do a try run of the WPT label Nov 11, 2026
@github-actions

Copy link
Copy Markdown

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

@github-actions

Copy link
Copy Markdown

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

Flaky unexpected result (27)
  • CRASH [expected OK] /IndexedDB/idbcursor_continue_objectstore.any.worker.html
  • CRASH [expected OK] /IndexedDB/idbindex-getAll-enforcerange.any.sharedworker.html
  • OK /beacon/beacon-basic.https.window.html (#41723)
    • FAIL [expected PASS] subtest: Payload size restriction should be accumulated: type = string

      assert_false: expected false got true
      

    • FAIL [expected PASS] subtest: Payload size restriction should be accumulated: type = arraybuffer

      assert_false: expected false got true
      

  • FAIL [expected PASS] /css/filter-effects/kernel-unit-length-002.html
  • TIMEOUT [expected PASS] /dom/nodes/moveBefore/moveBefore-range-iframe-crash.html
  • OK /fetch/content-length/api-and-duplicate-headers.any.worker.html (#35197)
    • FAIL [expected PASS] subtest: fetch() and duplicate Content-Length/Content-Type headers

      promise_test: Unhandled rejection with value: object "TypeError: Network error: HTTP failure: client error (SendRequest)"
      

  • ERROR [expected OK] /focus/focus-event-after-switching-iframes.sub.html (#40368)
  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin-fragment.html (#20768)
    • PASS [expected FAIL] subtest: Tests that a fragment navigation in the unload handler will not block the initial navigation
  • OK /html/browsers/browsing-the-web/navigating-across-documents/refresh/same-document-refresh.html (#34597)
    • FAIL [expected PASS] subtest: Same-Document Referrer from Refresh

      assert_equals: original page loads expected "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/refresh/resources/refresh-with-section.sub.html?url=%23section" but got "http://web-platform.test:8000/html/browsers/browsing-the-web/navigating-across-documents/refresh/resources/refresh-with-section.sub.html?url=%23section#section"
      

  • 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/browsers/windows/consume-user-activation/window-open-multi-global.html (#47399)
    • TIMEOUT [expected FAIL] subtest: window.open() and consuming user activation with multiple globals in play

      Test timed out
      

  • OK /html/webappapis/dynamic-markup-insertion/document-write/iframe_005.html (#43671)
    • PASS [expected FAIL] subtest: document.write external script into iframe write back into parent
  • FAIL [expected PASS] /mathml/presentation-markup/operators/mo-form-dynamic-002.html (#49169)
  • PASS [expected FAIL] /mathml/presentation-markup/operators/mo-lspace-rspace-dynamic.html (#49168)
  • PASS [expected FAIL] /mathml/presentation-markup/operators/operator-dictionary-empty-and-three-chars.html (#49173)
  • TIMEOUT [expected OK] /pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html
    • NOTRUN [expected PASS] subtest: touch two-finger pan on 'touch-action: pan-x pan-y'
    • NOTRUN [expected FAIL] subtest: touch two-finger pan on 'touch-action: pinch-zoom'
  • OK /upgrade-insecure-requests/gen/sharedworker-classic-data.meta/upgrade/websocket.https.html
    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for websocket to cross-ws-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for websocket to same-ws-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

  • OK /webdriver/tests/classic/back/user_prompts.py
    • FAIL [expected PASS] subtest: test_default[confirm-False]

      webdriver.error.NoSuchAlertException: no such alert (404): No user prompt is currently active.
      

  • OK /webdriver/tests/classic/delete_all_cookies/delete.py
    • ERROR [expected FAIL] subtest: test_no_browsing_context

      setup error: webdriver.error.NoSuchElementException: no such element (404)
      

  • OK /webdriver/tests/classic/dismiss_alert/dismiss.py (#39098)
    • ERROR [expected PASS] subtest: test_no_top_browsing_context

      setup error: webdriver.error.NoSuchElementException: no such element (404)
      

  • TIMEOUT [expected OK] /webdriver/tests/classic/element_click/center_point.py
  • OK /webdriver/tests/classic/element_click/iframe.py
    • FAIL [expected PASS] subtest: test_click_element_in_frame[same_origin]

      AssertionError: assert '' == 'clicked'
      

  • OK /webdriver/tests/classic/get_named_cookie/get.py
    • ERROR [expected FAIL] subtest: test_no_browsing_context

      setup error: webdriver.error.NoSuchElementException: no such element (404)
      

  • TIMEOUT [expected OK] /webdriver/tests/classic/perform_actions/navigation.py (#38822)
  • OK /webdriver/tests/classic/perform_actions/pointer_touch.py
    • FAIL [expected PASS] subtest: test_touch_pointer_in_shadow_tree[inner-closed]

      webdriver.error.NoSuchElementException: no such element (404)
      

  • OK /webdriver/tests/classic/set_window_rect/set.py
    • ERROR [expected PASS] subtest: test_no_browsing_context

      setup error: webdriver.error.NoSuchElementException: no such element (404)
      

  • OK [expected TIMEOUT] /webstorage/localstorage-about-blank-3P-iframe-opens-3P-window.partitioned.html (#29053)
    • FAIL [expected TIMEOUT] subtest: StorageKey: test 3P about:blank window opened from a 3P iframe

      assert_true: about:blank window opened by 3P iframe does not inherit 3P iframe's StorageKey expected true got false
      

Stable unexpected results that are known to be intermittent (7)
  • CRASH [expected TIMEOUT] /IndexedDB/idbcursor-request-source.any.worker.html (#48700)
  • OK /IndexedDB/idbtransaction-oncomplete.any.worker.html (#42804)
    • FAIL [expected PASS] subtest: IDBTransaction - complete event

      assert_array_equals: lengths differ, expected array ["upgradeneeded", "complete", "success", "opencursor"] length 4, got ["upgradeneeded", "complete", "success"] length 3
      

  • OK /css/CSS2/floats/float-in-block-in-inline-position-001.html (#49534)
    • PASS [expected FAIL] subtest: A line after a bordered block containing a float avoids it at the block's position (nested)
    • PASS [expected FAIL] subtest: A line after a bordered block containing a float avoids it at the block's position (sibling)
    • PASS [expected FAIL] subtest: The float lands in the same place whether the bordered block is nested in an inline box or a sibling of inline content
  • OK /dom/nodes/moveBefore/iframe-document-preserve.window.html (#43152)
    • FAIL [expected PASS] subtest: moveBefore(): cross-origin iframe is preserved: remove new parent

      assert_equals: iframe does not fire a second load event expected 1 but got 0
      

  • OK [expected TIMEOUT] /dom/xpath-evaluation-detached-nodes.html (#49715)
    • FAIL [expected PASS] subtest: Axis traversal on detached attribute does not crash and returns empty node-set

      assert_equals: Expression "ancestor-or-self::*" on detached attribute should return empty node-set expected 0 but got 1
      

  • TIMEOUT [expected OK] /html/browsers/browsing-the-web/navigating-across-documents/cross-origin-top-navigation-with-user-activation-in-parent.window.html (#48205)
    • TIMEOUT [expected FAIL] subtest: Cross-origin top navigation is blocked without user activation, even if the parent has user activation

      Test timed out
      

  • CRASH [expected TIMEOUT] /performance-timeline/not-restored-reasons/abort-block-bfcache.window.html (#42802)

@github-actions

Copy link
Copy Markdown

✨ Try run (#42994551082) succeeded.

/// A [`GenericSender`] to notify navigation events to webdriver.
webdriver_load_status_sender: Option<(GenericSender<WebDriverLoadStatus>, PipelineId)>,
/// Senders to notify WebDriver of navigation events, keyed by webview.
webdriver_load_status_senders: FxHashMap<WebViewId, GenericSender<WebDriverLoadStatusMessage>>,

@yezhizhen yezhizhen Nov 11, 2026 •

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Previously, we register with each command that might navigate, and remove the tracking immediately after the command. But then, a navigation between commands is invisible (e.g., triggered by script).

Now we track per webview, which is always monitored. It is only removed when we delete session or close webview.

Comment on lines -388 to -390
/// A channel to notify webdriver if there is a navigation
#[no_trace]
webdriver_load_status_sender: RefCell<Option<GenericSender<WebDriverLoadStatus>>>,

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Another reason why tracking in script is problematic is that, once we navigate away, server doesn't know status until sender is set inside the new Window.

@jdm jdm left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Makes sense. Thanks!

@servo-highfive servo-highfive removed the S-awaiting-review There is new code that needs to be reviewed. label Nov 16, 2026
@jdm
jdm added this pull request to the merge queue Nov 16, 2026
@servo-highfive servo-highfive added the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 16, 2026
@github-actions

Copy link
Copy Markdown

Test results for linux-wpt from merge queue job (#43948050202):

Flaky unexpected result (22)
  • OK /css/CSS2/floats/floats-in-inline-content-intrinsic-size-001.html (#49728)
    • FAIL [expected PASS] subtest: An empty float next to text (emptyFloatAndText, min-content)

      assert_equals: expected 70 but got 50
      

  • FAIL [expected PASS] /css/css-backgrounds/background-size-042.html
  • OK /css/css-fonts/variations/at-font-face-font-matching.html (#20684)
    • FAIL [expected PASS] subtest: Matching font-weight: '500' should prefer '350 399' over '351 398'

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

  • OK /css/css-position/static-position/inline-containing-block-with-border.html (#49970)
    • FAIL [expected PASS] subtest: writing-mode: horizontal-tb; direction: ltr; inline box 'border-inline-start: 30px solid; padding-inline-start: 7px'; originally inline-level absolutely positioned box

      assert_equals: left expected 111 but got 137
      

  • OK /dom/nodes/moveBefore/iframe-document-preserve.window.html (#43152)
    • FAIL [expected PASS] subtest: moveBefore(): cross-origin iframe is preserved: remove self via innerHTML

      assert_equals: iframe does not fire a second load event expected 1 but got 0
      

  • OK /fetch/content-length/api-and-duplicate-headers.any.worker.html (#35197)
    • FAIL [expected PASS] subtest: fetch() and duplicate Content-Length/Content-Type headers

      promise_test: Unhandled rejection with value: object "TypeError: Network error: HTTP failure: client error (SendRequest)"
      

  • OK /html/browsers/browsing-the-web/navigating-across-documents/navigation-unload-same-origin-fragment.html (#20768)
    • PASS [expected FAIL] subtest: Tests that a fragment navigation in the unload handler will not block the initial navigation
  • TIMEOUT [expected OK] /html/browsers/windows/consume-user-activation/window-open-multi-global.html (#47399)
    • TIMEOUT [expected FAIL] subtest: window.open() and consuming user activation with multiple globals in play

      Test timed out
      

  • CRASH [expected FAIL] /html/semantics/interestfor/interestfor-plain-inline-element.tentative.html
  • TIMEOUT [expected OK] /html/user-activation/consumption-sameorigin.html
    • NOTRUN [expected PASS] subtest: Consumption test
  • TIMEOUT [expected OK] /html/user-activation/navigation-state-reset-sameorigin.html (#45151)
    • TIMEOUT [expected FAIL] subtest: Post-navigation state reset.

      Test timed out
      

  • TIMEOUT [expected OK] /html/user-activation/propagation-sameorigin.html (#49544)
    • NOTRUN [expected PASS] subtest: Propagation test
  • OK /html/webappapis/dynamic-markup-insertion/document-write/iframe_005.html (#43671)
    • PASS [expected FAIL] subtest: document.write external script into iframe write back into parent
  • 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"])
      

  • FAIL [expected PASS] /mathml/presentation-markup/operators/mo-form-dynamic-002.html (#49169)
  • PASS [expected FAIL] /mathml/presentation-markup/operators/operator-dictionary-empty-and-three-chars.html (#49173)
  • OK /mixed-content/tentative/autoupgrades/mixed-content-cors.https.sub.html (#41123)
    • FAIL [expected PASS] subtest: Cross-Origin audio should get upgraded even if CORS is set

      assert_equals: Length of other host audio is correct expected 1 but got Infinity
      

  • TIMEOUT [expected OK] /pointerevents/compat/pointerevent_touch-action_two-finger_interaction.html
    • NOTRUN [expected PASS] subtest: touch two-finger pan on 'touch-action: pan-x pan-y'
    • NOTRUN [expected FAIL] subtest: touch two-finger pan on 'touch-action: pinch-zoom'
  • OK /upgrade-insecure-requests/gen/sharedworker-module-data.meta/upgrade/xhr.https.html
    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for xhr to cross-http-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for xhr to cross-https origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for xhr to same-http-downgrade origin and no-redirect redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

    • FAIL [expected PASS] subtest: Upgrade-Insecure-Requests: Expects allowed for xhr to same-https origin and downgrade redirection from https context.

      assert_equals: The resource request should be 'allowed'. expected "allowed" but got "blocked"
      

  • OK /webdriver/tests/classic/back/user_prompts.py
    • FAIL [expected PASS] subtest: test_accept_and_notify[prompt-]

      AssertionError: assert 'about:blank' == 'https://web-platform.test:8443/webdriver/tests/support/inline.py?doc=%3C%21doctype+html%3E%0A%3Cmeta+charset%3DUTF-8%3E%0A%3Cp+id%3D2%3E&amp;mime=text%2Fhtml&amp;charset=UTF-8'
      

  • OK /webdriver/tests/classic/perform_actions/pointer_mouse.py (#49662)
    • FAIL [expected PASS] subtest: test_down_closes_browsing_context[without up]

      Failed: DID NOT RAISE &lt;class 'webdriver.error.NoSuchWindowException'&gt;
      

  • OK /webxr/xrSession_features_deviceSupport.https.html (#24357)
    • FAIL [expected PASS] subtest: Immersive XRSession requests with no supported device should reject

      assert_unreached: Should have rejected: undefined Reached unreachable code
      

Stable unexpected results that are known to be intermittent (6)
  • OK /css/CSS2/floats/float-in-block-in-inline-position-001.html (#49534)
    • FAIL [expected PASS] subtest: A line after a bordered block containing a float avoids it at the block's position (sibling)

      assert_equals: the line's block-axis position expected 108 but got 106.35000000000002
      

  • TIMEOUT [expected ERROR] /html/browsers/history/the-location-interface/location_replace_session_history.html (#41896)
  • OK /mixed-content/tentative/autoupgrades/video-upgrade.https.sub.html (#41135)
    • FAIL [expected PASS] subtest: Video of other host autoupgraded

      assert_equals: Length. Other host expected 1 but got Infinity
      

  • CRASH [expected TIMEOUT] /performance-timeline/not-restored-reasons/abort-block-bfcache.window.html (#42802)
  • OK /pointerevents/pointerevent_pointercapture_in_frame.html?pen (#45536)
    • PASS [expected FAIL] subtest: Test penpointer capture in same-origin frame: Pointer down at inner frame and set pointer capture.
    • PASS [expected FAIL] subtest: Test penpointer capture in same-origin frame: Pointer down at inner frame and set pointer capture to outer frame should not capture.
  • OK /user-timing/measure_associated_with_navigation_timing.html (#47273)
    • FAIL [expected PASS] subtest: loadTime plus loadEventEnd to a mark "a" should equal to navigationStart to "a".

      assert_equals: loadTime plus loadEventEnd to a mark "a" should equal to navigationStart to "a". expected 12.79 but got 12.790000000000001
      

Merged via the queue into servo:main with commit 270fa95 Nov 16, 2026
35 checks passed
@servo-highfive servo-highfive removed the S-awaiting-merge The PR is in the process of compiling and running tests on the automated CI. label Nov 16, 2026
@skyz1

skyz1 commented Nov 16, 2026

Copy link
Copy Markdown
Member

This job had an unexpected failure in /webdriver/tests/classic/send_alert_text/send.py, that does not seem to be related to my PR. Could it be possible that the test is flaky because of the changes here?

@yezhizhen
yezhizhen deleted the fix-int-partial branch November 17, 2026 02:48
@yezhizhen

yezhizhen commented Nov 17, 2026 •

Copy link
Copy Markdown
Member Author

This job had an unexpected failure in /webdriver/tests/classic/send_alert_text/send.py, that does not seem to be related to my PR. Could it be possible that the test is flaky because of the changes here?

I ran it for an hour on c4e8a9b but cannot replicate :(

skyz1 pushed a commit to skyz1/servo that referenced this pull request Nov 23, 2026
…o#50150)

When a webview exists, the browsing context may still be pending to be
activated/created, as we've seen in servo#49817.

Testing: Tested locally.
Fixes: Part of servo#47582:
`test_link_from_toplevel_context_with_target[_blank] -
webdriver.error.NoSuchWindowException: no such window (404)`, which
opens a new webview from click.

Signed-off-by: Euclid Ye <[email protected]>
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.

4 participants