Disclosure Statement: This site contains affiliate links, which means that I may receive a commission if you make a purchase using these links. As an eBay Partner, I earn from qualifying purchases.
If you find these projects useful please consider becoming a sponsor with Patreon, GitHub or Liberapay.

There is a fatal bug in the doOnBeforePopup function

dvbss11
Posts: 28
Joined: Sat Oct 26, 2019 6:30 pm

Re: There is a fatal bug in the doOnBeforePopup function

Post by dvbss11 »

So maybe in cef there is some kind of nibul functional that allows you to programmatically create popap without js. Tell me what causes the BeforePopap event where to look at this code where doBeforePopap will be called
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: There is a fatal bug in the doOnBeforePopup function

Post by salvadordf »

As far as I know, that code is not in CEF.

Chromium's code uses those callbacks that CEF4Delphi exposes as events.
coater
Posts: 187
Joined: Sat Sep 29, 2018 1:51 pm

Re: There is a fatal bug in the doOnBeforePopup function

Post by coater »

salvadordf wrote: Tue Aug 06, 2019 7:19 pm I opened this URL using SimpleBrowser2 and MiniBrowser because SimpleBrowser2 blocks all popups but MiniBrowser allows all popups :
https://search.daum.net/search?w=tot&DA=YZR&t__nil_searchbox=btn&sug=&sugo=&q=%EC%A3%BC%EC%98%A5%EC%88%9C

MiniBrowser opened the popup window when I clicked that search result marked in red.
SimpleBrowser2 blocked the popup window when I clicked that search result marked in red.

I also tested https://www.daum.net/ and I clicked several ads with SimpleBrowser2 and MiniBrowser. MiniBrowser opened popup windows when I clicked the ads but SimpleBrowser2 blocked all of them.

I tested all this in Delphi 10.3 and Lazarus 2.0.2

Please, download the latest CEF4Delphi version and replace TChromium.doOnBeforePopup with this code in uCEFChromium.pas :

Code: Select all

function TChromium.doOnBeforePopup(const browser            : ICefBrowser;
                                   const frame              : ICefFrame;
                                   const targetUrl          : ustring;
                                   const targetFrameName    : ustring;
                                         targetDisposition  : TCefWindowOpenDisposition;
                                         userGesture        : Boolean;
                                   const popupFeatures      : TCefPopupFeatures;
                                   var   windowInfo         : TCefWindowInfo;
                                   var   client             : ICefClient;
                                   var   settings           : TCefBrowserSettings;
                                   var   extra_info         : ICefDictionaryValue;
                                   var   noJavascriptAccess : Boolean): Boolean;
begin
  Result := False;

  if Assigned(FOnBeforePopup) then
    FOnBeforePopup(Self, browser, frame, targetUrl, targetFrameName,
                   targetDisposition, userGesture, popupFeatures, windowInfo, client,
                   settings, extra_info, noJavascriptAccess, Result);
                   
  CefDebugLog('Result value : ' + BoolToStr(Result, true));                   
end;
Enable the log in NinjaBrowser setting these properties :

Code: Select all

  GlobalCEFApp.LogFile          := 'debug.log';
  GlobalCEFApp.LogSeverity      := LOGSEVERITY_VERBOSE;
Build CEF4Delphi and NinjaBrowser, navigate to the previous URL, click on the search result marked in red, close the browser and the open the debug.log file.

If you see a text line with "Result value : false" and you set Result to true inside NinjaBrowser then there's an issue passing a "var" parameter from C++ to CEF4Delphi.
noJavascriptAccess means what?
If I set it to true, error will happened.
User avatar
salvadordf
Posts: 4564
Joined: Thu Feb 02, 2017 12:24 pm
Location: Spain
Contact:

Re: There is a fatal bug in the doOnBeforePopup function

Post by salvadordf »

It's explained in the code comments for the TChromiumCore.OnBeforePopup event :
https://github.com/salvadordf/CEF4Delphi/blob/8e5b4e4ef38cf9bbcd11509dbf6a7926f9e35422/source/uCEFChromiumCore.pas#L2682
coater
Posts: 187
Joined: Sat Sep 29, 2018 1:51 pm

Re: There is a fatal bug in the doOnBeforePopup function

Post by coater »

no_javascript_access|
/// value is set to false (0) the new browser will not be scriptable and may
/// not be hosted in the same renderer process as the source browser.

Thank you very much!
Post Reply