就绪状态如何工作?
我使用 RFT (Rational Function Tester) 检查 BrowserTestObject
的属性 .readyState
。
有时,在测试脚本的下一步之前,我需要确保页面已“准备好”并且所有对象均已加载。
.readyState == 4
是否意味着浏览器中的所有对象均已加载并准备就绪?后台的任何 ajax 调用是否仍然“工作”,或者必须在浏览器返回 .readyState=4
之前完成?弹性应用程序怎么样?
这种行为是否真的独立于浏览器?我在使用 IE 8(和 Firefox 3.6.x)
I check the property .readyState
of BrowserTestObject
using RFT (Rational Functional Tester).
Sometimes before the next step in my test script I need to be sure that the page is 'ready' and all objects are loaded.
Does the .readyState == 4
mean that all objects within the browser are loaded and ready? Could any ajax call in background be still "working" or it must finish before the browser returns .readyState=4
? What about a flex application?
Is that behavior browser independent or not really? I am after IE 8 (and firefox 3.6.x)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
如果浏览器实现正确的话,快速回答是“是”。
请参阅此处: http:// www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#current-document-readiness
quick answer is YES if browser implementation is correct.
See here: http://www.whatwg.org/specs/web-apps/current-work/multipage/dom.html#current-document-readiness
我会说不。如果我理解此处的讨论,则使用的readyState仅指测试javascript,没有别的。要等待文档本身加载,您需要挂钩
document.readyState
并等待它变为“complete”
。在这种情况下,一旦 HTML 解析完成,document.readyState
将一劳永逸地"complete"
,并且不会受到任何 XMLHttpRequest 的影响。 Flash 插件可能已启动,也可能无法启动;肯定会有大量的 JavaScript 运行;例如,jquery 中的$(function() {})
构造通常意味着 JavaScript 代码只有在浏览器达到“完成”状态后才能开始执行。为了测试是否有任何异步请求正在进行,我建议以某种方式挂接所有 XMLHttpRequest 的 readyState 事件并使其更新全局变量。
I would say no. If I understood discussion here, readyState used thus only refers to the test javascript, nothing else. To wait that the document itself is loaded, you need to hook to
document.readyState
and wait for it to become"complete"
. In that case, once the HTML parsing is complete, thedocument.readyState
would be"complete"
once and for all, and will not be affected by any XMLHttpRequest whatsoever. Flash plugins could or could not have started; most certainly there would be lots of javascript running; for example$(function() {})
construct in jquery often means that javascript code could start executing only after the browser hits the "complete" state.To test if any asynchronous requests are going on, I suggest hooking the readyState event of all XMLHttpRequests somehow and make it update a global variable.