2 <!-- This is an example app used by chrome/functional/apptest.py to demonstrate
3 use of the Automation Event Queue for testing webapps.
5 This example webapp uses explicitly raised events in a simulated
6 asyncronous login flow. -->
10 <title>AppTest Example
</title>
11 <script type=
"text/javascript">
15 document
.getElementById("console").innerHTML
+= "> " + str
+ "<br \>";
18 /* Calls a function after a specified number of miliseconds. */
19 function delayedCallback(f
, ms
) {
20 globalTimeout
= setTimeout(f
, ms
);
23 /* Adds an event with the given name to the AutomationEventQueue. */
24 function raiseEvent(str
) {
25 if (window
.domAutomationController
) {
26 window
.domAutomationController
.sendWithId(4444, str
);
31 write("Initializing...");
32 delayedCallback(createLoginLink
, 2000);
36 function createLoginLink() {
37 write("<a id='login' href='' onclick='return login();'>Log In</a>");
38 raiseEvent("login ready");
42 write("Logging in...");
43 delayedCallback(loginSuccess
, 2000);
44 raiseEvent("login start");
48 function loginSuccess() {
49 write("Login succeeded!");
50 raiseEvent("login done");
51 raiseEvent("test success");
55 clearTimeout(globalTimeout
);
63 <body onload=
"init()">
65 [
<a id='fail' href='' onclick='return fail();'
>Fail Test
</a> ]