Closed Bug 1977168 Opened 2 months ago Closed 2 months ago

Can't navigate to https URLs with http proxy passed to createUserContext

Categories

(Remote Protocol :: WebDriver BiDi, defect, P2)

defect
Points:
2

Tracking

(firefox142 fixed)

RESOLVED FIXED
142 Branch
Tracking Status
firefox142 --- fixed

People

(Reporter: hbenl, Assigned: Sasha)

References

(Blocks 1 open bug)

Details

(Whiteboard: [webdriver:m17][webdriver:relnote])

Attachments

(1 file)

STR:

  • start a local http proxy on port 8080 (e.g. npx proxy --port 8080)
  • replace /path/to/firefox/nightly in the following script and run it:
import WebDriver from "webdriver";

(async () => {
  const browser = await WebDriver.newSession({
    capabilities: {
      webSocketUrl: true,
      browserName: 'firefox',
      'moz:firefoxOptions': {
        binary: '/path/to/firefox/nightly',
      },
    }
  });
  const { userContext } = await browser.browserCreateUserContext({
    proxy: {
      proxyType: "manual",
      httpProxy: "localhost:8080",
      sslProxy: "localhost:8080",
    }
  });
  const { context } = await browser.browsingContextCreate({ type: 'tab', userContext });
  await browser.browsingContextNavigate({ context, url: 'https://bugzilla.mozilla.org' });
  await new Promise(resolve => setTimeout(resolve, 1000));
  await browser.deleteSession();
})();

Expected:
The browser loads the bugzilla page

Actual:
The browser shows a message "Secure Connection Failed" with error code SSL_ERROR_RX_RECORD_TOO_LONG.

Loading http:// URLs works and so does loading https:// URLs without a proxy.
Furthermore, it also works for https:// URLs when the proxy is set globally like this:

[...]
  const browser = await WebDriver.newSession({
    capabilities: {
      webSocketUrl: true,
      browserName: 'firefox',
      'moz:firefoxOptions': {
        binary: '/path/to/firefox/nightly',
      },
      proxy: {
        proxyType: "manual",
        httpProxy: "localhost:8080",
        sslProxy: "localhost:8080",
      }
    }
  });
  const { userContext } = await browser.browserCreateUserContext({});
[...]
Summary: Can't navigate to https URLs with proxy passed to createUserContext → Can't navigate to https URLs with http proxy passed to createUserContext

Holger, would you mind running with the preference remote.log.level set to Trace and pasting the log output? Maybe it already gives a bit more information what might be wrong.

Blocks: 1870839
Flags: needinfo?(hbenl)

This is all I get:

2025-07-14T11:31:32.474Z INFO webdriver: Initiate new session using the WebDriver protocol
2025-07-14T11:31:32.560Z INFO geckodriver: Starting Geckodriver at /var/folders/9w/67gtm1kn2wl_nskhbxlj0h640000gn/T/geckodriver with params: --port=54532 --allow-hosts=localhost --host=0.0.0.0 --websocket-port=0
2025-07-14T11:31:32.564Z INFO geckodriver: 1752492692562        geckodriver     INFO    Listening on 0.0.0.0:54532
2025-07-14T11:31:32.565Z INFO @wdio/utils: Started GeckoDriver in 37ms on port 54532
2025-07-14T11:31:32.570Z INFO webdriver: [POST] http://localhost:54532/session
2025-07-14T11:31:32.577Z INFO geckodriver: 1752492692577        mozrunner::runner       INFO    Running command: MOZ_CRASHREPORTER="1" MOZ_CRASHREPORTER_NO_REPORT="1" MOZ_CRASHREPORTER_SHUTDOWN="1" "/Users/hbenl/Documents ... s" "localhost" "-foreground" "-no-remote" "-profile" "/var/folders/9w/67gtm1kn2wl_nskhbxlj0h640000gn/T/rust_mozprofileOTzcEG"
2025-07-14T11:31:32.846Z INFO geckodriver: 1752492692846        Marionette      INFO    Marionette enabled
2025-07-14T11:31:32.976Z INFO geckodriver: 1752492692976        Marionette      INFO    Listening on port 54535
2025-07-14T11:31:32.980Z WARN geckodriver: WebDriver BiDi listening on ws://127.0.0.1:54536
2025-07-14T11:31:32.992Z INFO geckodriver: Read port: 54535
2025-07-14T11:31:33.325Z WARN geckodriver: UNSUPPORTED (log once): POSSIBLE ISSUE: unit 1 GLD_TEXTURE_INDEX_2D is unloadable and bound to sampler type (Float) - using zero texture because texture unloadable
2025-07-14T11:31:33.600Z INFO webdriver: Register BiDi handler for session with id 2d48545c-5b55-4479-816f-5cd6d34f2011
2025-07-14T11:31:33.601Z INFO webdriver: Connecting to webSocketUrl ws://127.0.0.1:54536/session/2d48545c-5b55-4479-816f-5cd6d34f2011
2025-07-14T11:31:33.604Z INFO geckodriver: 1752492693604        RemoteAgent     INFO    Perform WebSocket upgrade for incoming connection from 127.0.0.1:54539
2025-07-14T11:31:33.605Z INFO webdriver: Connected to Bidi protocol at ws://127.0.0.1:54536/session/2d48545c-5b55-4479-816f-5cd6d34f2011
2025-07-14T11:31:33.605Z INFO webdriver: Connected to WebDriver Bidi interface at ws://127.0.0.1:54536/session/2d48545c-5b55-4479-816f-5cd6d34f2011
2025-07-14T11:31:33.605Z INFO webdriver: BIDI COMMAND browser.createUserContext {"proxy":{"proxyType":"manual","httpProxy":"localhost:8080","sslProxy":"localhost:8080"}}
2025-07-14T11:31:33.610Z INFO webdriver: BIDI RESULT {"type":"success","id":1,"result":{"userContext":"a11b6f43-b04d-48c3-aef4-0330872d4ea2"}}
2025-07-14T11:31:33.610Z INFO webdriver: BIDI COMMAND browsingContext.create {"type":"tab","userContext":"a11b6f43-b04d-48c3-aef4-0330872d4ea2"}
2025-07-14T11:31:33.643Z INFO geckodriver: console.error: (new NotFoundError("Could not find fa0fc42c-d91d-fca7-34eb-806ff46062dc in cache or dump", "resource://services-settings/Attachments.sys.mjs", 48))
2025-07-14T11:31:33.643Z INFO geckodriver: console.warn: "Unable to find the attachment for" "fa0fc42c-d91d-fca7-34eb-806ff46062dc"
2025-07-14T11:31:33.695Z INFO webdriver: BIDI RESULT {"type":"success","id":2,"result":{"context":"216215e7-1e96-4113-bd7d-ec482aaf94b7"}}
2025-07-14T11:31:33.695Z INFO webdriver: BIDI COMMAND browsingContext.navigate {"context":"216215e7-1e96-4113-bd7d-ec482aaf94b7","url":"https://bugzilla.mozilla.org"}
2025-07-14T11:31:33.778Z INFO geckodriver: 1752492693778        Marionette      WARN    Ignoring event 'pageshow' because document has an invalid readyState of 'uninitialized'.
2025-07-14T11:31:33.782Z INFO webdriver: BIDI RESULT {"type":"error","id":3,"error":"unknown error","message":"Error: NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SECURITY, SSL_ERROR_RX_RECORD_TOO_LONG)","stacktrace":"onLocationChange@chrome://remote/content/shared/Navigate.sys.mjs:449:26\n"}
node:internal/process/promises:391
    triggerUncaughtException(err, true /* fromPromise */);
    ^

Error: WebDriver Bidi command "browsingContext.navigate" failed with error: unknown error - Error: NS_ERROR_GENERATE_FAILURE(NS_ERROR_MODULE_SECURITY, SSL_ERROR_RX_RECORD_TOO_LONG)
    at BidiHandler.send (file:///Users/hbenl/Documents/bidi-client/node_modules/webdriver/build/node.js:357:23)
    at BidiHandler.browsingContextNavigate (file:///Users/hbenl/Documents/bidi-client/node_modules/webdriver/build/node.js:668:31)
    at Browser.value (file:///Users/hbenl/Documents/bidi-client/node_modules/webdriver/build/node.js:1262:26)
    at <anonymous> (/Users/hbenl/Documents/bidi-client/src/index.ts:25:17)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

Driver Stack:
    at onLocationChange@chrome://remote/content/shared/Navigate.sys.mjs:449:26

Setting remote.log.level doesn't seem to have an effect for some reason (but I've verified that setting prefs does work in general).

Flags: needinfo?(hbenl)
Assignee: nobody → aborovova
Status: NEW → ASSIGNED
Duplicate of this bug: 1977175
Whiteboard: [webdriver:m17]
Points: --- → 2
Priority: -- → P2
Pushed by aborovova@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/1149efad6e47 https://hg.mozilla.org/integration/autoland/rev/bceefcdc8b18 [bidi] Proxy all kind of traffic when a proxy is set with "browser.createUserContext". r=webdriver-reviewers,whimboo
Status: ASSIGNED → RESOLVED
Closed: 2 months ago
Resolution: --- → FIXED
Target Milestone: --- → 142 Branch
Whiteboard: [webdriver:m17] → [webdriver:m17][webdriver:relnote]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: