<!DOCTYPE html>
<head>
<title>Accessibility: slow document load</title>
<script src="../../../resources/testharness.js"></script>
<script src="../../../resources/testharnessreport.js"></script>
</head>
<body>
<p>This is a test.</p>
<script>
async_test((t) => {
let startTime = new Date();
let gotMarkDirtyBeforeOneSecond = false;
accessibilityController.addNotificationListener(
t.step_func((target, notification) => {
elapsedTime = new Date() - startTime;
if (notification == "MarkDirty" && elapsedTime < 1000) {
// See comment below if you're confused by this
gotMarkDirtyBeforeOneSecond = true;
}
if (notification == "LoadComplete") {
accessibilityController.removeNotificationListener();
assert_greater_than_equal(elapsedTime, 1000);
assert_true(gotMarkDirtyBeforeOneSecond);
t.done();
}
}));
window.setTimeout(function() {
assert_unreached("Did not receive all accessibility notifications:\n* Received MarkDirty=" + gotMarkDirtyBeforeOneSecond + "\n* Received LoadComplete: false");
t.done();
}, 2000);
}, "This tests that accessibility events will be fired after the first layout, rather than only after the document loads.");
setTimeout(function() {
// Cause a lifecycle update
document.querySelector('p').style.display = 'none';
}, 0);
</script>
<!-- This is a cgi script that waits 1.5 second before loading.
In practice, it seems to sometimes load after less time, so
that's why we use 1000 ms as the threshold in the tests, above.
-->
<script src="slow-loading-script.cgi"></script>
</body>
</html>