Auto merge of #16087 - jdm:testimprovement, r=metajack

Don't create a new XHR until the previous one is complete.

This test often times out when run under rr, because the event loop gets flooded with timer events that initiate XHRs before the previous XHR has completed. Additionally, we're running the event handler up to three times per XHR, which is just silly.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/servo/servo/16087)
<!-- Reviewable:end -->
This commit is contained in:
bors-servo 2017-03-23 12:46:14 -07:00 committed by GitHub
commit af9a1588d1
2 changed files with 5 additions and 4 deletions

View file

@ -176338,7 +176338,7 @@
"reftest" "reftest"
], ],
"html/semantics/embedded-content/the-iframe-element/iframe_harness.js": [ "html/semantics/embedded-content/the-iframe-element/iframe_harness.js": [
"c5db7a8f3c32f79a4e24d176cb95563a999240e5", "2f22f494c69854a79af94ccf90215ece7bb4a130",
"support" "support"
], ],
"html/semantics/embedded-content/the-iframe-element/iframe_javascript_url_01.htm": [ "html/semantics/embedded-content/the-iframe-element/iframe_javascript_url_01.htm": [

View file

@ -1,15 +1,16 @@
function get_test_results(id) { function get_test_results(id) {
async_test(function(test) { async_test(function(test) {
var timer = window.setInterval(test.step_func(loop), 100); test.step_timeout(loop, 100);
function loop() { function loop() {
var xhr = new XMLHttpRequest(); var xhr = new XMLHttpRequest();
xhr.open('GET', 'stash.py?id=' + id); xhr.open('GET', 'stash.py?id=' + id);
xhr.onreadystatechange = test.step_func(function() { xhr.onload = test.step_func(function() {
assert_equals(xhr.status, 200); assert_equals(xhr.status, 200);
if (xhr.responseText) { if (xhr.responseText) {
assert_equals(xhr.responseText, "OK"); assert_equals(xhr.responseText, "OK");
test.done(); test.done();
window.clearTimeout(timer); } else {
test.step_timeout(loop, 100);
} }
}); });
xhr.send(); xhr.send();