blob: 6063d37e0bd82880e12cbba5b5eff01275c93c48 [file] [log] [blame]
<!DOCTYPE html>
<head>
<title>Cobalt preload state visibility test</title>
<script src='black_box_js_test_utils.js'></script>
</head>
<body>
<h1>
<span>ID element</span>
</h1>
<script>
// In preload mode, visibility should be "hidden" and window/document
// should not have focus.
assertEqual("hidden", document.visibilityState);
assertFalse(document.hasFocus());
var visibilityStateVisible = false;
// Wait for visibility change to verify visibilityState and having focus.
function handleVisibilityChange() {
assertFalse(document.hasFocus());
if (visibilityStateVisible) {
assertEqual("hidden", document.visibilityState);
// Allow the app to become visible and then hidden at most once.
} else {
assertEqual("visible", document.visibilityState);
visibilityStateVisible = true;
onEndTest();
}
}
document.addEventListener("visibilitychange", handleVisibilityChange);
setupFinished();
</script>
</body>