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
HandleAfterCreated(CefBrowser:061da4b8)
HandleLoadStart(CefBrowser:0x061da510, CefFrame:0x00000000)
http://www.google.co.uk/search?q=cefsharp
HandleLoadStart(CefBrowser:0x061dac80, CefFrame:0x061da510) FrameName="" MainFrame? True
http://www.google.co.uk/blank.html
http://www.google.co.uk/images/nav_logo29.png
HandleLoadStart(CefBrowser:0x061daf30, CefFrame:0x061dac80) FrameName="wgjf" MainFrame? False
HandleLoadEnd(CefBrowser:0x061db250, CefFrame:0x061db1f8) FrameName="wgjf" MainFrame? False
http://www.google.co.uk/extern_js/f/CgJlbhICdWsrMEU4ACwrMFo4ACwrMA44ACwrMBc4ACwrMCc4ACwrMDw4ACwrMFE4ACwrMFk4ACwrMAo4AEAdmgICcHMsKzAWOAAsKzAZOAAsKzAlOM-IASwrMCo4CywrMCs4ESwrMDU4ACwrMEA4ACwrMEE4ACwrME04ACwrME44ACwrMFM4ACwrMFQ4ACwrMF84ACwrMGM4ACwrMGk4ACwrMB04AJoCAnBzLCswXDgALCswGDgALCswJjgALIACKpACJw/cDLPAIGguKY.js
HandleLoadEnd(CefBrowser:0x061db2a8, CefFrame:0x061db250) FrameName="" MainFrame? True
HandleLoadEnd(CefBrowser:0x061db250, CefFrame:0x00000000)
http://www.google.co.uk/extern_chrome/6354f67d2c0f0c5e.js
HandleLoadStart(CefBrowser:0x061db2a8, CefFrame:0x00000000)
http://www.google.co.uk/compressiontest/gzip.html
HandleLoadStart(CefBrowser:0x061db3b0, CefFrame:0x061db358) FrameName="<!--framePath //<!--frame1-->-->" MainFrame? False
HandleLoadEnd(CefBrowser:0x061db3b0, CefFrame:0x061db358) FrameName="<!--framePath //<!--frame1-->-->" MainFrame? False
HandleLoadEnd(CefBrowser:0x061db358, CefFrame:0x00000000)
http://www.google.co.uk/csi?v=3&s=web&action=&e=27744,27867,27886,28062,28065&ei=Ju0ATYOiAs24hAfqrYjuBw&expi=27744,27867,27886,28062,28065&imc=3&imn=3&imp=0&rt=xjsls.147,prt.149,xjses.234,xjsee.339,xjs.345,ol.358,iml.149
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,
Tom.