- add sources.
[platform/framework/web/crosswalk.git] / src / chrome / test / data / apptest / dom_mutations.html
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 using DomMutation
4      observers.
5
6      This example webapp simulates an asyncronous login flow. -->
7 <html>
8
9   <head>
10     <title>AppTest Example</title>
11     <script type="text/javascript">
12       var globalTimeout;
13
14       function write(str) {
15         document.getElementById("console").innerHTML += "> " + str + "<br \>";
16       }
17
18       /* Calls a function after a specified number of miliseconds. */
19       function delayedCallback(f, ms) {
20         globalTimeout = setTimeout(f, ms);
21       }
22
23       function init() {
24         write("Initializing...");
25         delayedCallback(createLoginLink, 2000);
26       }
27
28       function createLoginLink() {
29         write("<a id='login' href='' onclick='return login();'>Log In</a>");
30       }
31
32       function login() {
33         write("Logging in...");
34         delayedCallback(loginSuccess, 2000);
35         return false;
36       }
37
38       function loginSuccess() {
39         write("Login succeeded!");
40         document.getElementById("fail").innerHTML = "";
41       }
42
43       function fail() {
44         clearTimeout(globalTimeout);
45         write("App failed!");
46         return false;
47       }
48     </script>
49   </head>
50
51   <body onload="init()">
52     <div id="fail">
53       [ <a href='' onclick='return fail();'>Fail Test</a> ]
54       <br /><br />
55     </div>
56
57     <div id="console">
58     </div>
59
60   </body>
61
62 </html>