blob: 79e20cd1d997091c0e018effe479ed9966a42565 [file] [log] [blame]
<!DOCTYPE html>
<!-- This is an example app used by chrome/functional/apptest.py to demonstrate
use of the Automation Event Queue for testing webapps.
This example webapp uses explicitly raised events in a simulated
asyncronous login flow. -->
<html>
<head>
<title>AppTest Example</title>
<script type="text/javascript">
var globalTimeout;
function write(str) {
document.getElementById("console").innerHTML += "> " + str + "<br \>";
}
/* Calls a function after a specified number of miliseconds. */
function delayedCallback(f, ms) {
globalTimeout = setTimeout(f, ms);
}
/* Adds an event with the given name to the AutomationEventQueue. */
function raiseEvent(str) {
if (window.domAutomationController) {
window.domAutomationController.send(str);
}
}
function init() {
write("Initializing...");
delayedCallback(createLoginLink, 2000);
raiseEvent("init");
}
function createLoginLink() {
write("<a id='login' href='' onclick='return login();'>Log In</a>");
raiseEvent("login ready");
}
function login() {
write("Logging in...");
delayedCallback(loginSuccess, 2000);
raiseEvent("login start");
return false;
}
function loginSuccess() {
write("Login succeeded!");
raiseEvent("login done");
raiseEvent("test success");
}
function fail() {
clearTimeout(globalTimeout);
write("App failed!");
raiseEvent("error");
return false;
}
</script>
</head>
<body onload="init()">
<div id="s-1">
[ <a id='fail' href='' onclick='return fail();'>Fail Test</a> ]
<br /><br />
</div>
<div id="console">
</div>
</body>
</html>