Skip to content

[rb] support serving test pages over HTTPS for certificate and cookie tests - #18152

Merged
titusfortner merged 3 commits into
SeleniumHQ:trunkfrom
titusfortner:ruby-https-spec-server
Oct 12, 2026
Merged

titusfortner merged 3 commits into
SeleniumHQ:trunkfrom
titusfortner:ruby-https-spec-server

Conversation

@titusfortner

@titusfortner titusfortner commented Oct 10, 2026 •

Copy link
Copy Markdown
Member

🔗 Related Issues

Ruby implementation of #18148

💥 What does this PR do?

  • Adds https support for Ruby test server
  • Ensure tests requiring https are run

🔧 Implementation Notes

  • The Ruby spec server now serves common/src/web over HTTPS as well as HTTP, using the checked-in self-signed certificate; url_for(name, secure: true) returns the HTTPS URL.
  • Two existing cookie specs are no longer skipped and use https (secure: true and same_site: 'None')
  • Add a BiDi spec to test accept_insecure_certs
  • The HTTPS examples reset the driver with accept_insecure_certs: true rather than setting it for every spec
  • Safari skips certificate tests since it has no way to accept the certificate.
  • The spec server now runs both listeners as in-process threads on every platform, as it always did on Windows, and lets WEBrick bind port 0, so nothing picks ports up front and the forked lifecycle is gone.
  • Dropped the thin/mongrel handler probing from 2010: neither gem is in the gemspec or lockfile, and the SSL options are WEBrick-specific, so a locally installed thin would have silently disabled the HTTPS listener.

🤖 AI assistance

  • AI assisted (complete below)
    • Tool(s): Claude Code (Fable 5.1)
    • What was generated: HTTPS listener, spec changes, and this description
    • I reviewed all AI output and can explain the change

💡 Additional Considerations

  • Merge after [bazel] Use MRI on RBE (rebased #17622) #18123 (RBE on MRI): under JRuby, jruby-openssl buffers past the TLS handshake and WEBrick's readiness poll never sees the first request, so these specs stall on a JRuby RBE.
  • Additional Ruby cookie tests remain guarded; we would need to add a host with subdomains or a non-secure-context origin, which this server does not provide.

🔄 Types of changes

  • Cleanup (test infrastructure)

@selenium-ci selenium-ci added C-rb Ruby Bindings B-build Includes scripting, bazel and CI integrations B-devtools Includes everything BiDi or Chrome DevTools related labels Oct 10, 2026
@qodo-code-review

Copy link
Copy Markdown
Contributor

PR Summary by Qodo

Serve Ruby spec pages over HTTPS and enable secure-cookie tests

✨ Enhancement 🧪 Tests ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Serve Ruby spec pages over HTTP and HTTPS using the shared self-signed certificate.
• Run secure-cookie specs against local HTTPS and add BiDi certificate-acceptance coverage.
• Include certificates in Ruby integration test data and skip unsupported Safari certificate tests.
Diagram

graph TD
  Specs["Cookie and BiDi specs"] --> Helpers["URL helpers"] --> Env["Test environment"] --> Server(["WEBrick listeners"]) --> Pages["Shared web pages"]
  Certs["Shared certificate"] --> Server
  Specs --> Browser["Browser driver"] --> Server
Loading
High-Level Assessment

Keep the dual local listeners: existing specs retain HTTP, while HTTPS-dependent specs gain a controlled origin without relying on external sites. An HTTPS-only server would disrupt HTTP coverage, and external HTTPS sites would make tests less reliable.

Files changed (7) +74 / -51

Enhancement (3) +25 / -26
helpers.rbExpose secure URLs through spec helpers +2/-2

Expose secure URLs through spec helpers

• Adds an optional secure keyword to the URL helper and forwards it to the test environment, preserving HTTP as the default.

rb/spec/integration/selenium/webdriver/spec_support/helpers.rb

rack_server.rbServe spec pages on HTTP and HTTPS listeners +18/-21

Serve spec pages on HTTP and HTTPS listeners

• Starts separate WEBrick listeners for the same test app, configuring HTTPS with the shared localhost certificate and key. Waits for both ports, returns protocol-specific URLs, and removes legacy handler probing in favor of WEBrick.

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb

test_environment.rbConfigure the secure spec-server port and certificate path +5/-3

Configure the secure spec-server port and certificate path

• Chooses both server ports before startup and passes the shared certificate directory to RackServer. Propagates the optional secure URL selection to callers.

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb

Tests (2) +35 / -22
browser_spec.rbTest BiDi acceptance of the local certificate +14/-0

Test BiDi acceptance of the local certificate

• Adds a user-context spec that enables insecure certificates, navigates to a local HTTPS page, and verifies the resulting URL. The spec closes its browsing context and removes the user context afterward.

rb/spec/integration/selenium/webdriver/bidi/protocol/browser_spec.rb

manager_spec.rbRun secure-cookie specs against local HTTPS +21/-22

Run secure-cookie specs against local HTTPS

• Replaces skipped external-site secure and SameSite=None cookie cases with local HTTPS tests that reset the driver to accept the self-signed certificate. Skips those cases on Safari and clarifies why the HTTP rejection case remains guarded.

rb/spec/integration/selenium/webdriver/manager_spec.rb

Other (2) +14 / -3
BUILD.bazelExpose localhost certificates to Ruby specs +4/-1

Expose localhost certificates to Ruby specs

• Extends the certificate filegroup's visibility to Ruby spec subpackages so Bazel integration targets can include the certificate and key.

common/certificates/BUILD.bazel

tests.bzlInclude certificates in Ruby integration test data +10/-2

Include certificates in Ruby integration test data

• Adds the shared certificate filegroup to local and remote Ruby integration targets for both classic WebDriver and BiDi, making the HTTPS listener's files available under Bazel.

rb/spec/tests.bzl

@qodo-code-review

qodo-code-review Bot commented Oct 10, 2026 •

Copy link
Copy Markdown
Contributor

Code Review by Qodo

🐞 Bugs (0) 📘 Rule violations (0) 📜 Skill insights (0)

Grey Divider


Action required

1. Test pages intermittently fail to load ✓ Resolved
Description
serve calls Rack::Handler::WEBrick.run concurrently for HTTP and HTTPS, while the installed Rack
handler stores the server in one shared instance variable and rereads it when mounting and starting
it. If one thread replaces that variable while the other is starting, both calls can start the same
server, leaving one port unserved and causing spec-server startup to time out.
Code

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[78]

+          Rack::Handler::WEBrick.run @app, **options, **ssl
Evidence
Both the forked and threaded startup paths call serve concurrently for the two ports. The locked
Rack version is 2.2.24; its WEBrick handler assigns @server and then accesses @server again for
mount and start, allowing one call to operate on the other call's server.

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[54-56]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[76-78]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[93-97]
rb/Gemfile.lock[67-67]
🌐 The Rack 2.2 handler's run method assigns a shared @server, then uses that variable for mounting and starting the server.

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Concurrent calls to Rack's WEBrick handler share its server instance variable, so one listener can remain unserved.

## Fix Focus Areas
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[76-78]
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[54-56]
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[95-95]

## Recommended Fix
Construct, mount, and start each WEBrick server using a thread-local server reference rather than calling the shared Rack handler's `run` method concurrently. Preserve separate references for shutdown.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


2. Secure server survives test shutdown ✓ Resolved
Description
RackServer#run starts the HTTPS listener in an untracked thread, while start_threaded records
only the outer thread and stop kills only that recorded thread. On Windows, JRuby, and
TruffleRuby, GlobalTestEnv#quit therefore leaves the HTTPS listener active after stopping the test
server, including when the environment is reused in the same process; the changed lifecycle has no
test to catch this.
Code

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[R53-54]

+          Thread.new { Rack::Handler::WEBrick.run @app, **server_options(@secure_port), **ssl_options }
+          Rack::Handler::WEBrick.run @app, **server_options(@port)
Evidence
The changed run method creates an HTTPS thread without retaining it, while start_threaded saves
only the outer thread and stop kills only that saved thread. GlobalTestEnv#quit calls stop, so
its shutdown path does not reach the HTTPS listener; the changed behavior also lacks the applicable
test coverage called for by the checklist.

AGENTS.md: Use Small Tests That Exercise Real API Contracts
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[39-54]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[61-66]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[89-96]
rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[213-219]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[40-54]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[89-95]
rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[213-218]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
On threaded platforms, stopping the test server stops the recorded outer thread but leaves the separately started HTTPS listener running. The changed shutdown lifecycle also needs test coverage.

## Fix Focus Areas
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[51-66]
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[89-95]

## Recommended Fix
Retain references to both listener threads or server instances. Update `stop` to shut down both listeners and join their threads. Add a focused test that starts both listeners, stops the server, and verifies that neither listener remains active.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended

3. Idle secure clients consume server threads ✓ Resolved
Description
BufferedTlsRequest#run makes wait_readable return true for every TLS socket, so WEBrick
proceeds to parse even when no HTTP request is available. A client that completes the TLS handshake
but sends no request then blocks inside request parsing instead of reaching WEBrick's request
timeout, leaving the secure listener's thread and socket occupied.
Code

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[R37-38]

+              io.define_singleton_method(:wait_readable) { |_timeout| true }
+              sock.define_singleton_method(:to_io) { io }
Evidence
The workaround applies to every accepted OpenSSL TLS socket, while WEBrick's HTTPServer#run uses
sock.to_io.wait_readable before parsing the request. Returning true unconditionally skips that
timeout/readiness check; the secure server is started with these sockets through the HTTPS WEBrick
listener.

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[31-40]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[69-73]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The JRuby workaround overrides the delegated socket's `wait_readable` to always return `true`, bypassing WEBrick's readiness timeout. After a TLS handshake, an idle client can therefore block indefinitely in HTTP request parsing and consume a WEBrick request thread.

### Fix Focus Areas
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[31-44]

### Recommended Fix
Replace the unconditional readiness result with a bounded readiness implementation that still accommodates JRuby's buffered TLS data without bypassing idle-request timeouts. If the underlying socket cannot expose buffered data reliably, enforce `RequestTimeout` around the subsequent request parse so idle TLS clients cannot retain server threads indefinitely.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


4. A failed secure startup leaves an orphan ✓ Resolved
Description
run starts HTTPS in a separate thread, allowing the HTTP server to keep running when certificate
loading or the HTTPS bind fails. In forked mode the parent eventually times out waiting for the
secure port, but app_server has not stored the server instance, so its normal cleanup cannot reach
the still-running child.
Code

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[R53-54]

+          Thread.new { Rack::Handler::WEBrick.run @app, **server_options(@secure_port), **ssl_options }
+          Rack::Handler::WEBrick.run @app, **server_options(@port)
Evidence
HTTPS setup and binding happen in the new thread, while HTTP remains in run. The parent requires
connectivity to both ports; the environment assigns @app_server only after start succeeds, and
quit cleans up only an assigned server.

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[43-54]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[78-94]
rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[104-111]
rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[213-218]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An HTTPS startup failure can leave the forked HTTP server running after `start` times out.
## Fix Focus Areas
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[40-54]
- rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[104-111]
## Recommended Fix
Propagate HTTPS-thread startup failures to the process supervising startup and ensure a failed `start` stops and reaps any listener or child it created.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


5. Secure pages can reach the plain server ✓ Resolved
Description
app_server calls random_port twice, but each call closes its socket before either listener
binds, so both calls can return the same port. If HTTP wins the bind, startup can report both ports
connected even though the HTTPS listener failed, and secure test URLs then reach a plain HTTP
server.
Code

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[R106-108]

+            app_server = RackServer.new(root.join('common/src/web').to_s, random_port,
+                                        secure_port: random_port,
+                                        certificates: root.join('common/certificates').to_s)
Evidence
random_port closes its bound socket before returning, the new call selects a second port without
checking it against the first, and startup polls both supplied numbers using only TCP connectivity.

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[106-108]
rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[425-436]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[43-54]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The two independently selected ports can be identical because `random_port` closes each socket before the listeners bind.
## Fix Focus Areas
- rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[104-108]
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[40-54]
## Recommended Fix
Ensure the HTTP and HTTPS listeners receive distinct ports, with port ownership maintained until each listener binds; do not treat two connections to one port as proof that both listeners started.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Context sources
Review mode: Auto: ⚖️ Balanced: Downgraded extended -> standard: change is below the extended eligibility bar (hunks 13/18, lines 165/200; both must reach the floor). Router rationale: HTTPS server lifecycle changes span multiple independent, defect-prone paths.

Grey Divider

Tip of the day
💡 Did you know, you can commit Qodo's fix in one click with committable suggestions (GitHub & GitLab)

More tips ↗ | Customize Qodo ↗ | Qodo docs ↗

Grey Divider

Previous reviews

Review updated until commit f7cfd9d

Results up to commit 4fb429f ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Action required
1. Secure server survives test shutdown ✓ Resolved
Description
RackServer#run starts the HTTPS listener in an untracked thread, while start_threaded records
only the outer thread and stop kills only that recorded thread. On Windows, JRuby, and
TruffleRuby, GlobalTestEnv#quit therefore leaves the HTTPS listener active after stopping the test
server, including when the environment is reused in the same process; the changed lifecycle has no
test to catch this.
Code

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[R53-54]

+          Thread.new { Rack::Handler::WEBrick.run @app, **server_options(@secure_port), **ssl_options }
+          Rack::Handler::WEBrick.run @app, **server_options(@port)
Evidence
The changed run method creates an HTTPS thread without retaining it, while start_threaded saves
only the outer thread and stop kills only that saved thread. GlobalTestEnv#quit calls stop, so
its shutdown path does not reach the HTTPS listener; the changed behavior also lacks the applicable
test coverage called for by the checklist.

AGENTS.md: Use Small Tests That Exercise Real API Contracts
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[39-54]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[61-66]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[89-96]
rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[213-219]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[40-54]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[89-95]
rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[213-218]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
On threaded platforms, stopping the test server stops the recorded outer thread but leaves the separately started HTTPS listener running. The changed shutdown lifecycle also needs test coverage.

## Fix Focus Areas
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[51-66]
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[89-95]

## Recommended Fix
Retain references to both listener threads or server instances. Update `stop` to shut down both listeners and join their threads. Add a focused test that starts both listeners, stops the server, and verifies that neither listener remains active.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools



Remediation recommended
2. A failed secure startup leaves an orphan ✓ Resolved
Description
run starts HTTPS in a separate thread, allowing the HTTP server to keep running when certificate
loading or the HTTPS bind fails. In forked mode the parent eventually times out waiting for the
secure port, but app_server has not stored the server instance, so its normal cleanup cannot reach
the still-running child.
Code

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[R53-54]

+          Thread.new { Rack::Handler::WEBrick.run @app, **server_options(@secure_port), **ssl_options }
+          Rack::Handler::WEBrick.run @app, **server_options(@port)
Evidence
HTTPS setup and binding happen in the new thread, while HTTP remains in run. The parent requires
connectivity to both ports; the environment assigns @app_server only after start succeeds, and
quit cleans up only an assigned server.

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[43-54]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[78-94]
rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[104-111]
rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[213-218]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
An HTTPS startup failure can leave the forked HTTP server running after `start` times out.
## Fix Focus Areas
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[40-54]
- rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[104-111]
## Recommended Fix
Propagate HTTPS-thread startup failures to the process supervising startup and ensure a failed `start` stops and reaps any listener or child it created.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


3. Secure pages can reach the plain server ✓ Resolved
Description
app_server calls random_port twice, but each call closes its socket before either listener
binds, so both calls can return the same port. If HTTP wins the bind, startup can report both ports
connected even though the HTTPS listener failed, and secure test URLs then reach a plain HTTP
server.
Code

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[R106-108]

+            app_server = RackServer.new(root.join('common/src/web').to_s, random_port,
+                                        secure_port: random_port,
+                                        certificates: root.join('common/certificates').to_s)
Evidence
random_port closes its bound socket before returning, the new call selects a second port without
checking it against the first, and startup polls both supplied numbers using only TCP connectivity.

rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[106-108]
rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[425-436]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[43-54]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
The two independently selected ports can be identical because `random_port` closes each socket before the listeners bind.
## Fix Focus Areas
- rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb[104-108]
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[40-54]
## Recommended Fix
Ensure the HTTP and HTTPS listeners receive distinct ports, with port ownership maintained until each listener binds; do not treat two connections to one port as proof that both listeners started.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit bf490f8 ⚖️ Balanced


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Action required
1. Test pages intermittently fail to load ✓ Resolved
Description
serve calls Rack::Handler::WEBrick.run concurrently for HTTP and HTTPS, while the installed Rack
handler stores the server in one shared instance variable and rereads it when mounting and starting
it. If one thread replaces that variable while the other is starting, both calls can start the same
server, leaving one port unserved and causing spec-server startup to time out.
Code

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[78]

+          Rack::Handler::WEBrick.run @app, **options, **ssl
Evidence
Both the forked and threaded startup paths call serve concurrently for the two ports. The locked
Rack version is 2.2.24; its WEBrick handler assigns @server and then accesses @server again for
mount and start, allowing one call to operate on the other call's server.

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[54-56]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[76-78]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[93-97]
rb/Gemfile.lock[67-67]
🌐 The Rack 2.2 handler's run method assigns a shared @server, then uses that variable for mounting and starting the server.

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

## Issue description
Concurrent calls to Rack's WEBrick handler share its server instance variable, so one listener can remain unserved.

## Fix Focus Areas
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[76-78]
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[54-56]
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[95-95]

## Recommended Fix
Construct, mount, and start each WEBrick server using a thread-local server reference rather than calling the shared Rack handler's `run` method concurrently. Preserve separate references for shutdown.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Results up to commit cc1743a 🚀 Fast


🐞 Bugs (0) 📘 Rule violations (0) 📎 Requirement gaps (0) 🎨 UX issues (0) 🔗 Cross-repo conflicts (0) 📜 Skill insights (0)


Remediation recommended
1. Idle secure clients consume server threads ✓ Resolved
Description
BufferedTlsRequest#run makes wait_readable return true for every TLS socket, so WEBrick
proceeds to parse even when no HTTP request is available. A client that completes the TLS handshake
but sends no request then blocks inside request parsing instead of reaching WEBrick's request
timeout, leaving the secure listener's thread and socket occupied.
Code

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[R37-38]

+              io.define_singleton_method(:wait_readable) { |_timeout| true }
+              sock.define_singleton_method(:to_io) { io }
Evidence
The workaround applies to every accepted OpenSSL TLS socket, while WEBrick's HTTPServer#run uses
sock.to_io.wait_readable before parsing the request. Returning true unconditionally skips that
timeout/readiness check; the secure server is started with these sockets through the HTTPS WEBrick
listener.

rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[31-40]
rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[69-73]

Agent prompt
The issue below was found during a code review. Follow the provided context and guidance below and implement a solution

### Issue description
The JRuby workaround overrides the delegated socket's `wait_readable` to always return `true`, bypassing WEBrick's readiness timeout. After a TLS handshake, an idle client can therefore block indefinitely in HTTP request parsing and consume a WEBrick request thread.

### Fix Focus Areas
- rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb[31-44]

### Recommended Fix
Replace the unconditional readiness result with a bounded readiness implementation that still accommodates JRuby's buffered TLS data without bypassing idle-request timeouts. If the underlying socket cannot expose buffered data reliably, enforce `RequestTimeout` around the subsequent request parse so idle TLS clients cannot retain server threads indefinitely.

ⓘ Copy this prompt and use it to remediate the issue with your preferred AI generation tools


Grey Divider

Qodo Logo

Comment thread rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb Outdated
Comment thread rb/spec/integration/selenium/webdriver/spec_support/test_environment.rb Outdated
Comment thread rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb Outdated
Comment thread rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb Outdated
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit bf490f8

Comment thread rb/spec/integration/selenium/webdriver/spec_support/rack_server.rb Outdated
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit cc1743a

@titusfortner titusfortner changed the title [rb] serve the spec pages over HTTPS with the shared self-signed certificate and run the secure cookie specs [rb] support serving test pages over HTTPS for certificate and cookie tests Oct 10, 2026
@titusfortner

Copy link
Copy Markdown
Member Author

There's not an easy fix for the JRuby issues, so I'm going to try to merge #18123 first

@titusfortner
titusfortner force-pushed the ruby-https-spec-server branch from cc1743a to 9a2899f Compare October 12, 2026 15:00
@qodo-code-review

Copy link
Copy Markdown
Contributor

Code review by qodo was updated up to the latest commit 9a2899f

@qodo-code-review

qodo-code-review Bot commented Oct 12, 2026 •

Copy link
Copy Markdown
Contributor

No code changes since the last review — review skipped

Qodo Logo

@titusfortner
titusfortner merged commit 508ab41 into SeleniumHQ:trunk Oct 12, 2026
45 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

B-build Includes scripting, bazel and CI integrations B-devtools Includes everything BiDi or Chrome DevTools related C-rb Ruby Bindings

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants

Sponsor
SponsoredKunjungi sekarang
Promo