ui_test_utils::NavigateToURL behavior.

25 views
Skip to first unread message

karan...@chromium.org

unread,
Oct 6, 2017, 4:52:43 PM10/6/17
to Chromium-dev
I was trying to write some browser tests and was using ui_test_utils::NavigateToURL(browser, url) in the process. The documentation for this says that it blocks until the navigation finishes. What does this correspond to as far as the page lifecycle (DOMContentLoaded, onload events etc. ) is concerned? 

My use case: I was trying to call some JS functions using content::ExecuteScriptAndExtractBool but was getting "Uncaught ReferenceError" for the functions if I placed the inline JS in the <body> tag. Placing the inline JS in the <head> section seems to resolve the issue. 

karan...@chromium.org

unread,
Oct 6, 2017, 4:59:06 PM10/6/17
to Chromium-dev
Also, there seems to have been prior discussion on this, but I can't seem to find a conclusive answer.

Charles Harrison

unread,
Oct 6, 2017, 5:08:19 PM10/6/17
to karan...@chromium.org, Chromium-dev
It looks like NavigateToURL(browser, url)  uses BROWSER_TEST_WAIT_FOR_NAVIGATION which indicates that it only waits for the navigation to finish (e.g. the response is complete and we've read the headers).

This would align it with the documentation. Note that navigation finished just means we've *started* processing the HTML and is a state before DCL or the load event.

If you want to wait for the load to finish, it looks like TestFrameNavigationObserver does something like that.

--
--
Chromium Developers mailing list: chromi...@chromium.org
View archives, change email options, or unsubscribe:
http://groups.google.com/a/chromium.org/group/chromium-dev
---
You received this message because you are subscribed to the Google Groups "Chromium-dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to chromium-dev+unsubscribe@chromium.org.
To view this discussion on the web visit https://groups.google.com/a/chromium.org/d/msgid/chromium-dev/7681f6f2-4beb-4d14-8e23-349ee29c28c0%40chromium.org.

karan...@chromium.org

unread,
Oct 6, 2017, 7:34:07 PM10/6/17
to Chromium-dev, karan...@chromium.org
Seems even NavigateToURL uses a TestNavigationObserver which waits for DidStopLoading to fire on the associated web contents. I tried using TestFrameNavigationObserver (which also waits on DidStopLoading) but it didn't seem to help.

Charles Harrison

unread,
Oct 6, 2017, 7:48:12 PM10/6/17
to karan...@chromium.org, Chromium-dev
Hm seems like I was wrong :)

In any case, it seems like a bug if DidStopLoading is called before DCL and we've processed all scripts in the body. Can you post a repro?

karan...@chromium.org

unread,
Oct 6, 2017, 9:02:18 PM10/6/17
to Chromium-dev, karan...@chromium.org
Nevermind, it was my mistake. Turns out self-closing iframes (<iframe src="" />) are not a thing. This caused the content (inline JS) after the iframe tag to be considered part of the iframe. Thanks for your help!
Reply all
Reply to author
Forward
0 new messages