1 <!-- Used for testing that the automation code handles client redirects
2 ---- correctly. Tests can call |runTestCase| to run various redirect
3 ---- cases, such as javascript redirects and form submissions.
7 var g_shouldSubmit
= true;
9 function runTestCase(case_number
) {
10 if (case_number
== 1) {
11 document
.querySelector("form").submit();
12 } else if (case_number
== 2) {
13 g_shouldSubmit
= false;
14 // Submitting with javascript does not call the onsubmit handler,
15 // so fire a synthetic event instead.
16 var event
= document
.createEvent('MouseEvents');
17 event
.initMouseEvent('click', true, true, window
,
18 0, 0, 0, 0, 0, false, false,
19 false, false, 0, null);
20 document
.querySelector("#submitButton").dispatchEvent(event
);
21 } else if (case_number
== 3) {
22 window
.location
.href
= "client_redirects.html";
23 } else if (case_number
== 4) {
24 window
.location
.href
= "nosuchpageexistshopefully";
29 <form name=
"form" method=
"get" onsubmit=
"return g_shouldSubmit">
30 <input name=
"text" type=
"text" value=
"1" />
31 <input id=
"submitButton" type=
"submit" value=
"Submit" />