0

I'm trying to get the Page.windowOpen event to fire when using CefSharp

Here is the sample code

let browser = new ChromiumWebBrowser("https://www.google.com")
//removed code that waits for browser to load        
let client = browser.GetDevToolsClient()
client.Page.WindowOpen.Add(fun x -> Console.WriteLine(x.Url))
browser.ShowDevTools() //window.open('https://www.wikipedia.org') via console, event does not fire
client.Runtime.EvaluateAsync("window.open('https://www.wikipedia.org')") //event does not fire

The windowOpen docs are scant on detail, and I'm assuming this event should fire from the context of the page that is executing the window.open() js function

The window does physically open, but no event fires.

Where is the problem ?

  • My implementation
  • CefSharp
  • Cef
OrdinaryOrange
  • 2,420
  • 1
  • 16
  • 25
  • You need to first call https://chromedevtools.github.io/devtools-protocol/tot/Page/#method-enable – amaitland Nov 12 '21 at 03:23
  • Brilliant, works perfectly. Shame the docs don't clearly state this requirement, I would never have found that without significant pain. Change you comment to an answer and I'll attribute the answer. – OrdinaryOrange Nov 13 '21 at 01:07

1 Answers1

0

I noticed you did not call Page.enable. It is not well documented, but in order to have the Page Domain events fired (except for lifecycle ones as of now), you have to enable the domain.

Kle0s
  • 113
  • 1
  • 8