Skip to content
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

winforms: setting remote-allow-origins does not show remote origins on set port with Chrome bootstrap #3740

Closed
m-kovac opened this issue Jul 15, 2024 · 10 comments
Labels
bug Bug report needs user feedback Additional feedback required

Comments

@m-kovac
Copy link

m-kovac commented Jul 15, 2024

Describe the bug

With CefSharp v126.2.70, CEF v126.0.6478.115 the remote-allow-origins parameter with set localhost:port stopped to have effect. This is connected to switch from Alloy bootstrap to Chrome bootstrap.

To Reproduce

  1. Clone https://github.com/cefsharp/CefSharp.MinimalExample
  2. Open solution CefSharp.MinimalExample.net472
  3. Update CefSharp for CefSharp.MinimalExample.WinForms.net472 to v126.2.70
  4. In CefSharp.MinimalExample.WinForms.net472 project Program.cs set following settings to CefSettings
settings.RemoteDebuggingPort = 1236; 
settings.CefCommandLineArgs.Add("remote-allow-origins", $"http://localhost:{settings.RemoteDebuggingPort}");
  1. Start the project
  2. Open new browser window and go to localhost:1236
  3. Observe empty window
  4. Stop the project
  5. Add setting settings.ChromeRuntime = false; to CefSettings to change back to Alloy bootstrap
  6. Start the project
  7. Go to localhost:1236
  8. Observe window with the link to "Google"

Expected behavior
The remote-allow-origins should work with Chrome bootstrap.

Screenshots

Missing link
image

Expected behavior
image

Versions (please complete the following information):

  • OS: Windows 11
  • CEF Version: v126.0.6478.115
  • CefSharp Version: v126.2.70
@m-kovac m-kovac added the bug Bug report label Jul 15, 2024
@m-kovac m-kovac changed the title windows, winforms: setting remote-allow-origins does not show remote origins on set port with Chrome bootstrap winforms: setting remote-allow-origins does not show remote origins on set port with Chrome bootstrap Jul 15, 2024
@magreenblatt
Copy link
Collaborator

The remote-allow-origins flag is implemented in Chromium. I suggest that you test the behavior in Google Chrome.

@magreenblatt magreenblatt added the needs user feedback Additional feedback required label Jul 15, 2024
@m-kovac
Copy link
Author

m-kovac commented Jul 16, 2024

Sorry, I don't understand. What should I test in Google Chrome?

@magreenblatt
Copy link
Collaborator

What should I test in Google Chrome?

You should test how the --remote-allow-origins flag behaves in Google Chrome. From the code:

// Enables web socket connections from the specified origins only. '*' allows
// any origin.

@magreenblatt
Copy link
Collaborator

Go to localhost:1236
Observe window with the link to "Google"

You should use chrome://inspect/ for connecting to remote debugging.

@magreenblatt
Copy link
Collaborator

Your "Missing link" and "Expected behavior" screenshots are also both showing Chrome style windows.

@magreenblatt
Copy link
Collaborator

Closing this issue as WontFix given that CEF has no special handling for the --remote-allow-origins flag, and there are better/preferred ways to access remote debugging if that is the intention.

@SiMoStro
Copy link

SiMoStro commented Aug 2, 2024

To be honest, we are facing the exact same problem starting from v126 and I don't get the "WontFix" reason; we were able to successfully use the "--remote-allow-origins" switch:

cefsharp/CefSharp#4894

this seems a regression to me, either in CEF or in CefSharp :-/

@jozefizso
Copy link

Opening the URL for the remote debugging port on previous CEF releases will load the JSON with list of active browser instances:

image

This no longer happens for the v126:

image

Requesting the JSON manually for v126 does work:

 curl http://localhost:1236/json/list?t=1722606942069
[ {
   "description": "",
   "devtoolsFrontendUrl": "/devtools/inspector.html?ws=localhost:1236/devtools/page/A4A02D4EEDF8E9EDB16F4C71237DB7FD",
   "id": "A4A02D4EEDF8E9EDB16F4C71237DB7FD",
   "title": "Slido",
   "type": "page",
   "url": "https://app.example.org/",
   "webSocketDebuggerUrl": "ws://localhost:1236/devtools/page/A4A02D4EEDF8E9EDB16F4C71237DB7FD"
} ]

And opening the devtoolsFrontendUrl in the browser will show the Dev Tools for the running CEF instance.

@amaitland
Copy link
Contributor

this seems a regression to me, either in CEF or in CefSharp :-/

This is not a regression in CefSharp.

Testing with cef_binary_127.3.2+gf1af617+chromium-127.0.6533.100_windows64_client and the problem reproduces.

# Works
.\cefclient.exe --use-alloy-style --remote-debugging-port=9955 --remote-allow-origins=http://localhost:9955 --disable-chrome-runtime

# Doesn't work
.\cefclient.exe --use-alloy-style --remote-debugging-port=9955 --remote-allow-origins=http://localhost:9955

Tested with --disable-request-handling-for-testing also which makes no difference.

given that CEF has no special handling for the --remote-allow-origins flag

Without actually debugging my guess would be that it's something fairly simple that's missing or not enabled in the Chrome Bootstrap.

@jozefizso
Copy link

Our CefSharp setttings:

var settings = new CefSettings();
settings.RootCachePath = Path.Combine(appDataFolder, @"browser-cache");
settings.BrowserSubprocessPath = Path.Combine(installPath, Environment.Is64BitProcess ? "x64" : "x86", "CefSharp.BrowserSubprocess.exe");
settings.RemoteDebuggingPort = 1236;
settings.CefCommandLineArgs.Add("remote-allow-origins", $"http://localhost:{settings.RemoteDebuggingPort}");

CefSharpSettings.RuntimeStyle = CefRuntimeStyle.Chrome;

Remote Debugger in M125

curl  -v http://localhost:1236
* Host localhost:1236 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:1236...
*   Trying 127.0.0.1:1236...
* Connected to localhost (127.0.0.1) port 1236
> GET / HTTP/1.1
> Host: localhost:1236
> User-Agent: curl/8.8.0
> Accept: */*
>
* Request completely sent off
< HTTP/1.1 200 OK
< X-Frame-Options:DENY
< Content-Length:1475
< Content-Type:text/html; charset=UTF-8
<
<html>
<head>
<title>CEF remote debugging</title>
<style>
</style>

<script>
function onLoad() {
  var tabs_list_request = new XMLHttpRequest();
  tabs_list_request.open("GET", "/json/list?t=" + new Date().getTime(), true);
  tabs_list_request.onreadystatechange = onReady;
  tabs_list_request.send();
}

function onReady() {
  if(this.readyState == 4 && this.status == 200) {
    if(this.response != null)
      var responseJSON = JSON.parse(this.response);
      for (var i = 0; i < responseJSON.length; ++i)
        appendItem(responseJSON[i]);
  }
}

function appendItem(item_object) {
  var frontend_ref;
  if (item_object.devtoolsFrontendUrl) {
    frontend_ref = document.createElement("a");
    frontend_ref.href = item_object.devtoolsFrontendUrl;
    frontend_ref.title = item_object.title;
  } else {
    frontend_ref = document.createElement("div");
    frontend_ref.title = "The tab already has active debugging session";
  }

  var text = document.createElement("div");
  if (item_object.title)
    text.innerText = item_object.title;
  else
    text.innerText = "(untitled tab)";
  text.style.cssText = "background-image:url(" + item_object.faviconUrl + ")";
  frontend_ref.appendChild(text);

  var item = document.createElement("p");
  item.appendChild(frontend_ref);

  document.getElementById("items").appendChild(item);
}
</script>
</head>
<body onload='onLoad()'>
  <div id='caption'>Inspectable WebContents</div>
  <div id='items'></div>
</body>
</html>
* Connection #0 to host localhost left intact

Remote Debugger in M126 & M127

 curl  -v http://localhost:1236
* Host localhost:1236 was resolved.
* IPv6: ::1
* IPv4: 127.0.0.1
*   Trying [::1]:1236...
*   Trying 127.0.0.1:1236...
* Connected to localhost (127.0.0.1) port 1236
> GET / HTTP/1.1
> Host: localhost:1236
> User-Agent: curl/8.8.0
> Accept: */*
>
< HTTP/1.1 200 OK
< X-Frame-Options:DENY
< Content-Length:0
< Content-Type:text/html; charset=UTF-8
<
* Connection #0 to host localhost left intact

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Bug report needs user feedback Additional feedback required
Projects
None yet
Development

No branches or pull requests

5 participants