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

Impossible to use window.open during page load. #4940

Closed
1 task done
max3163 opened this issue Sep 27, 2024 · 7 comments
Closed
1 task done

Impossible to use window.open during page load. #4940

max3163 opened this issue Sep 27, 2024 · 7 comments
Labels
upstream These issues require fixing in the Chromium Embedded Framework(CEF) or Chromium.

Comments

@max3163
Copy link

max3163 commented Sep 27, 2024

Is there an existing issue for this?

  • I have searched both open/closed issues, no issue already exists.

CefSharp Version

126.2.180 or later

Operating System

Windows 10

Architecture

x64

.Net Version

4.8

Implementation

WinForms

Reproduction Steps

Start load this page :

<!DOCTYPE html>
<html lang="en">
  <head>
  </head>
  <body>
    <script>
      let count = 0;
      function openWindowRec() {
        console.log("Try window.open : " + count );
        if (!window.open('', 'ID321')) {
          setTimeout(() => {
            count++;
            openWindowRec();
          }, 500)
        }
      }
      console.log("First call openWindowRec" );
      openWindowRec();
    </script>
  </body>
</html>

Expected behavior

A new window is create directly when the first window.open call is made.

Actual behavior

window.open return null during 4-5 second, no window is created and it work after.

Regression?

It work with ALLOY Runtime

Known Workarounds

None since 128

Does this problem also occur in the CEF Sample Application

No

Other information

The problem is present on the Minimal CEF Sharp Application but it work with the minimal CEF Client.

The problem is so on the C# implementation side.

@max3163
Copy link
Author

max3163 commented Sep 27, 2024

I'm just trying the 128 release, and the problem is still here ...

image

1-2sec before you can call the method....

When I use the ALLOW (version 127), it work on the first call as expected :

image

@campersau
Copy link
Contributor

campersau commented Sep 27, 2024

I had to disable popup blocking all together to make it work:

cefSettings.CefCommandLineArgs.Add("disable-popup-blocking");

@amaitland amaitland changed the title [Chrome Runtime with CEFSHARP] Impossible to use window.open during page load. Impossible to use window.open during page load. Sep 27, 2024
@amaitland amaitland added the upstream These issues require fixing in the Chromium Embedded Framework(CEF) or Chromium. label Sep 27, 2024
@amaitland
Copy link
Member

The problem is present on the Minimal CEF Sharp Application but it work with the minimal CEF Client.

I've updated the cefclient links to reflect upstream changes, testing with --use-alloy-style is now required for comparison.

The problem is so on the C# implementation side.

It's very unlikely this is a CefSharp specific problem. More likely it's the alloy styled browsers (which CefSharp uses by default, the last cefclient uses chrome styled) don't handled the popup blocking gracefully.

CefSharp can probably disable popup blocking by default, though that may not be wise as a long term general solution.

Please retest with --use-alloy-style (in addition to the other command line args required for testing)

@max3163
Copy link
Author

max3163 commented Sep 28, 2024

I'm a little confused, for me in 128 version, the alloy style is no more available ?

@mitchcapper
Copy link
Contributor

Alloy was split into runtime component and a 'style' component. The style component still exists on top of chrome to make it work much like the old alloy mode with the new runtime. While 128 killed off the old runtime the style still exists.

@max3163
Copy link
Author

max3163 commented Sep 30, 2024

Ok , thanks for explanation !

So I tested the cefclient.exe with the '--use-alloy-style' and the problem occur too , worse it crash when the popup appear !

In any case, with the "disable-popup-blocking" option, on my CefSharp project it work like a charm !

Thank for the help :)

@magreenblatt
Copy link

You can also allow specific origins to create popups using (C++) code like the following in CefRequestContextHandler::OnRequestContextInitialized:

context->SetContentSetting(origin_url, origin_url,
                           CEF_CONTENT_SETTING_TYPE_POPUPS,
                           CEF_CONTENT_SETTING_VALUE_ALLOW);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
upstream These issues require fixing in the Chromium Embedded Framework(CEF) or Chromium.
Projects
None yet
Development

No branches or pull requests

5 participants