OLD | NEW |
(Empty) | |
| 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. |
| 4 |
| 5 This example webapp uses explicitly raised events in a simulated |
| 6 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 /* Adds an event with the given name to the AutomationEventQueue. */ |
| 24 function raiseEvent(str) { |
| 25 if (window.domAutomationController) { |
| 26 window.domAutomationController.setAutomationId(424242) |
| 27 window.domAutomationController.send(str); |
| 28 } |
| 29 } |
| 30 |
| 31 function init() { |
| 32 write("Initializing..."); |
| 33 delayedCallback(createLoginLink, 2000); |
| 34 raiseEvent("init"); |
| 35 } |
| 36 |
| 37 function createLoginLink() { |
| 38 write("<a id='login' href='' onclick='return login();'>Log In</a>"); |
| 39 raiseEvent("login ready"); |
| 40 } |
| 41 |
| 42 function login() { |
| 43 write("Logging in..."); |
| 44 delayedCallback(loginSuccess, 2000); |
| 45 raiseEvent("login start"); |
| 46 return false; |
| 47 } |
| 48 |
| 49 function loginSuccess() { |
| 50 write("Login succeeded!"); |
| 51 raiseEvent("login done"); |
| 52 } |
| 53 |
| 54 function fail() { |
| 55 clearTimeout(globalTimeout); |
| 56 write("App failed!"); |
| 57 raiseEvent("error"); |
| 58 return false; |
| 59 } |
| 60 </script> |
| 61 </head> |
| 62 |
| 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> |
| 68 |
| 69 <div id="console"> |
| 70 </div> |
| 71 |
| 72 </body> |
| 73 |
| 74 </html> |
OLD | NEW |