chromiumembedded / cef

Chromium Embedded Framework (CEF). A simple framework for embedding Chromium-based browsers in other applications.
https://bitbucket.org/chromiumembedded/cef/
Other
3.09k stars 450 forks source link

OnBeforeResourceLoad() not called for some fetch/XHRs #3593

Open RadoMmm opened 8 months ago

RadoMmm commented 8 months ago

Describe the bug For certain site(s) the request handling is not working, because neither CefRequestContextHandler::GetResourceRequestHandler() nor OnBeforeResourceLoad() is called for some requests invoked by service worker.

To Reproduce Steps to reproduce the behavior:

  1. implement the request handler in cefclient in the class ClientRequestContextHandler (root_window_manager.cc), for example
CefRefPtr<CefResourceRequestHandler> GetResourceRequestHandler(
      CefRefPtr<CefBrowser> browser,
      CefRefPtr<CefFrame> frame,
      CefRefPtr<CefRequest> request,
      bool is_navigation,
      bool is_download,
      const CefString& request_initiator,
      bool& disable_default_handling) override {

      std::string url = request->GetURL();
      if (url.find("fbs.com/api", 0) != std::string::npos)
      {
          LOG(INFO) << "**X: " << request->GetIdentifier() << " " << url;
      }

      return this;
  }
  1. navigate or start with --url=https://fbs.com/cabinet/recovery
  2. (optional) send form with any e-mail
  3. no requests to fbs.com/api are caught

Expected behavior Requests like https://fbs.com/api/v1/maintenance should be handled.

Screenshots If applicable, add screenshots to help explain your problem.

Versions (please complete the following information):

Additional context I've tried to find the problem, I've got here: forum post

tishion commented 5 months ago

same problem for sw.js file. Found some old reports on this issue. please refer to: https://magpcss.org/ceforum/viewtopic.php?f=6&t=19041

We cannot intercept the request to sw.js file even we have implemented CefRequestContext. Maybe this is a regression bug?