就绪状态如何工作?

发布于 2025-01-08 21:46:10 字数 376 浏览 5 评论 0原文

我使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

百合的盛世恋 2025-01-15 21:46:10

如果浏览器实现正确的话,快速回答是“是”。

请参阅此处: 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

萌辣 2025-01-15 21:46:10

我会说不。如果我理解此处的讨论,则使用的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, the document.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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文