Roll leveldb 3f7758:803d69 (v1.17 -> v1.18)
[chromium-blink-merge.git] / chrome / test / data / apptest / basic.html
blob606cc95635b224cf4ca0cf78117e254b8699aa12
1 <!DOCTYPE html>
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. -->
7 <html>
9 <head>
10 <title>AppTest Example</title>
11 <script type="text/javascript">
12 var globalTimeout;
14 function write(str) {
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);
30 function init() {
31 write("Initializing...");
32 delayedCallback(createLoginLink, 2000);
33 raiseEvent("init");
36 function createLoginLink() {
37 write("<a id='login' href='' onclick='return login();'>Log In</a>");
38 raiseEvent("login ready");
41 function login() {
42 write("Logging in...");
43 delayedCallback(loginSuccess, 2000);
44 raiseEvent("login start");
45 return false;
48 function loginSuccess() {
49 write("Login succeeded!");
50 raiseEvent("login done");
51 raiseEvent("test success");
54 function fail() {
55 clearTimeout(globalTimeout);
56 write("App failed!");
57 raiseEvent("error");
58 return false;
60 </script>
61 </head>
63 <body onload="init()">
64 <div id="s-1">
65 [ <a id='fail' href='' onclick='return fail();'>Fail Test</a> ]
66 <br /><br />
67 </div>
69 <div id="console">
70 </div>
72 </body>
74 </html>