summaryrefslogtreecommitdiffstats
path: root/chrome/test/data/automation/client_redirects.html
blob: b3a221a6d3c13f15b972808cfadb1e15e0a4dc58 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
<!-- Used for testing that the automation code handles client redirects
---- correctly. Tests can call |runTestCase| to run various redirect
---- cases, such as javascript redirects and form submissions.
!-->
<html>
  <script>
    var g_shouldSubmit = true;

    function runTestCase(case_number) {
      if (case_number == 1) {
        document.querySelector("form").submit();
      } else if (case_number == 2) {
        g_shouldSubmit = false;
        // Submitting with javascript does not call the onsubmit handler,
        // so fire a synthetic event instead.
        var event = document.createEvent('MouseEvents');
        event.initMouseEvent('click', true, true, window,
                             0, 0, 0, 0, 0, false, false,
                             false, false, 0, null);
        document.querySelector("#submitButton").dispatchEvent(event);
      } else if (case_number == 3) {
        window.location.href = "client_redirects.html";
      } else if (case_number == 4) {
        window.location.href = "nosuchpageexistshopefully";
      }
    }
  </script>
  <body>
    <form name="form" method="get" onsubmit="return g_shouldSubmit">
      <input name="text" type="text" value="1" />
      <input id="submitButton" type="submit" value="Submit" />
    </form>
  </body>
</html>