blob: 257646324914a3c34df03214b3cd87700a556a26 [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());
// Wait for visibility change to verify visibilityState and having focus.
function handleVisibilityChange() {
assertEqual("visible", document.visibilityState);
assertFalse(document.hasFocus());
// Ensure that the document URL still has the launch=preload parameter after becoming visible.
assertTrue(document.URL.includes('?foo=bar&launch=preload') || document.URL.includes('?launch=preload'));
document.removeEventListener("visibilitychange", handleVisibilityChange);
onEndTest();
}
document.addEventListener("visibilitychange", handleVisibilityChange);
console.log('document.URL == ' + document.URL);
// Ensure that the document URL has the launch=preload parameter when preloading.
assertTrue(document.URL.includes('?foo=bar&launch=preload') || document.URL.includes('?launch=preload'));
setupFinished();
</script>
</body>