As you know I'm trying to provide a Chromium/CEF based browser control for .Net similar to MSHTML, GeckoFx or Webkit.NET it's going well so far but there are currently two problems that I'm now facing.
I cannot find a good way of notifying users that a page is fully loaded and I cannot find a reliable way to expose frames or determine which frames events are occurring on. This is very important for users that want to programmatically exercise a web site.
Regarding notification that a page is fully loaded, it'd like to be able to inform users at the point that they might safely run scripts against the page or inspect its contents. There doesn't appear to be a way to query a browser or frame for its current state and the HandleLoadStart, HandleLoadEnd methods do not seem to fire at the appropriate times, for instance the HandleLoadEnd event fires several times for the CefBrowser.
Below is some debug output from loading http://www.google.co.uk/search?q=cefsharp
- Code: Select all
HandleLoadStart(CefBrowser:0x061dac80, CefFrame:0x061da510) FrameName="" MainFrame? True
HandleLoadStart(CefBrowser:0x061daf30, CefFrame:0x061dac80) FrameName="wgjf" MainFrame? False
HandleLoadEnd(CefBrowser:0x061db250, CefFrame:0x061db1f8) FrameName="wgjf" MainFrame? False
HandleLoadEnd(CefBrowser:0x061db2a8, CefFrame:0x061db250) FrameName="" MainFrame? True
HandleLoadStart(CefBrowser:0x061db3b0, CefFrame:0x061db358) FrameName="<!--framePath //<!--frame1-->-->" MainFrame? False
HandleLoadEnd(CefBrowser:0x061db3b0, CefFrame:0x061db358) FrameName="<!--framePath //<!--frame1-->-->" MainFrame? False
As you can see waiting for a HandleLoadEnd with a null frame is not enough as this occurs twice. I therefore tried to implement a countdown/countup latch to sum the number of starts minus ends and signal when the count returns to zero, this doesn't seem to be reliable though due to race conditions.
What I'd really like to do is to be able to track the state of each frame, this brings me to the next problem, there is no way to compare CefBrowsers of CefFrames for equality and the pointers passing in by the framework change continually as seen above. This is also the reason that I can't wrap and expose the frame related portions of the API, I can't tell which frame is being referred to.
What is the difference between the calls with a null frame argument and the mainframe?
Is there something that can be exposed that would act as a more natural navigation-complete/page-ready event? Is there a way of comparing frames/browsers for equality that I've missed?
Thanks in advance and apologies for the rambling nature of this post,