[Qtwebengine] How to tell when DOM resources finishes downloading?

Kevin Truong knt261 at gmail.com
Tue Nov 24 19:14:46 CET 2015


Sure Kai -- here's my use case: I have a page that loads ajax data into the
document. The ajax gets loaded into the DOM much later than when the
DomContentLoaded and the Load event is triggered (the red and blue vertical
lines in the picture under "Network Panel Overview"
https://developer.chrome.com/devtools/docs/network). If I understood
correctly, it means the ajax is loaded much later than when loadFinished()
is signaled as well. The amount of time we have to wait before the ajax is
loaded into the document is variable -- it can take 50ms, or it can take up
to 10 seconds. I would like to know exactly when the ajax is loaded into
the DOM (or if that's not possible, exactly when the render finish
downloading the ajax) before serializing/downloading the HTML of the page
and doing tests on the HTML. This is because the HTML changes after the
ajax is loaded into the DOM, and the tests need to be run on the updated
HTML, not the initial HTML.

I'd like this to be generalized as well (not just ajax, but any other DOM
resource), because I have test pages where the exact same thing happens,
but with iframes instead of ajax, or with certain very specific plug-ins
(like the facebook posts that load below an article page). These resources
load independently of DomContentLoaded and the Load event. However, I can
identify them either via the URL or the content type -- I just need to
figure out how I can tell the render to serialize only right after these
resources are loaded.


On Sun, Nov 22, 2015 at 11:59 PM, Koehne Kai <Kai.Koehne at theqtcompany.com>
wrote:

>
>
> > -----Original Message-----
> > From: QtWebEngine [mailto:qtwebengine-bounces at qt-project.org] On Behalf
> > Of Kevin Truong
> > Sent: Friday, November 20, 2015 6:53 AM
> > To: qtwebengine at qt-project.org
> > Subject: [Qtwebengine] How to tell when DOM resources finishes
> downloading?
> >
> > I have a website that loads resources such as images, iframes, ajax,
> scripts, etc.
> >
> > Running qt web engine on this website, I found a way for the render to
> time the
> > exact moment these requests were initiated by subclassing
> > QWebEngineUrlRequestInterceptor, and passing that class to
> m_page.profile()-
> > >setRequestInterceptor().
> >
> > However, I would also like to time when these DOM resources finish
> > downloading as well. This was possible in qt webkit, so I was hoping
> there's a
> > way to do it for qt webengine.
>
> If you could explain your use case it might be easier to give you advice.
>
> I understood you already looked into QWebEngineView::loadFinished(),
> but you couldn't use it for some reason?
>
> > One example I thought was the solution is the signal
> > QWebEngineProfile::downloadRequested(QWebEngineDownloadItem
> > *download). This signal allows me to access the QWebEngineDownloadItem
> > object, which signals when the download has finished, which is basically
> what I
> > am looking for. However, this signal doesn't ever seem to be executed. I
> think it
> > is only run when e.g. a user clicks on a download link, rather than
> being run for
> > every DOM resource being loaded.
>
> downloadRequested() is only emitted basically for things that the user
> wants
> to explicitly save on disk (something that will show up in a browser's
> download
> manager). So I don’t think you can use that to profile the DOM progress.
>
> Regards
>
> Kai
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/qtwebengine/attachments/20151124/50288472/attachment.html>


More information about the QtWebEngine mailing list