Bug 1104732 - followup: fix test flakiness due to arbitrariness of when load happens on a CLOSED TREE

--HG--
extra : amend_source : 4206841ae9f01acf59b15b6140f786c909051c0b
This commit is contained in:
Gijs Kruitbosch 2015-05-29 14:36:36 +01:00
Родитель ea9a0a76af
Коммит be86295761
2 изменённых файлов: 13 добавлений и 4 удалений

Просмотреть файл

@ -4,11 +4,11 @@ function handleRequest(request, response)
{
response.processAsync();
response.setHeader("Content-Type", "application/javascript", false);
response.write("state = 'mid-async';\n");
response.write("asyncState = 'mid-async';\n");
timer = Components.classes["@mozilla.org/timer;1"].createInstance(Components.interfaces.nsITimer);
timer.initWithCallback(function() {
response.write("state = 'async loaded';\n");
response.write("asyncState = 'loaded';\n");
response.finish();
}, 5 * 1000 /* milliseconds */, timer.TYPE_ONE_SHOT);
}

Просмотреть файл

@ -16,21 +16,30 @@ https://bugzilla.mozilla.org/show_bug.cgi?id=1104732
// Test starting
// defer
// DOMContentLoaded
// async loaded
// load
// In the meantime, the async script load should happen before load.
// Ideally, we would want to assert that it happens after DOMContentLoaded,
// because it shouldn't be holding up DOMContentLoaded, but there is
// no *guarantee* that this is the case, so we cannot assert it.
var state = "Test starting";
var asyncState = "not loaded";
SimpleTest.waitForExplicitFinish();
is(document.readyState, "loading", "Document should have been loading.");
document.addEventListener("DOMContentLoaded", function () {
is(document.readyState, "interactive", "readyState should be interactive during DOMContentLoaded.");
is(state, "defer", "Bad state upon DOMContentLoaded");
state = "DOMContentLoaded";
// This doesn't work (see above), but we can't "todo" this assertion either, because
// it will sometimes be the case...
// isnot(asyncState, "loaded", "Async script should not have delayed domcontentloaded");
});
window.addEventListener("load", function () {
is(document.readyState, "complete", "readyState should be complete during load.");
is(state, "async loaded", "Bad state upon load")
is(state, "DOMContentLoaded", "Bad state upon load")
state = "load";
is(asyncState, "loaded", "Async script should be loaded upon document load event");
SimpleTest.finish();
});
</script>