summaryrefslogtreecommitdiffstats
path: root/testing/mochitest/redirect.html
blob: d2b009534374fafe6a4972d92fc4e7c393ecfb7d (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
35
36
37
38
39
40
41
42
<html>
<head>
  <title>redirecting...</title>

  <script type="text/javascript">
    function redirect(aURL)
    {
      // We create a listener for this event in browser-test.js which will
      // get picked up when specifying --flavor=chrome or --flavor=a11y
      var event = new CustomEvent("contentEvent", {
        bubbles: true,
        detail: {
          "data": aURL + location.search,
          "type": "loadURI"
        }
      });
      document.dispatchEvent(event);
    }

    function redirectToHarness()
    {
      redirect("chrome://mochikit/content/harness.xul");
    }

    function onLoad() {
      // Wait for MozAfterPaint, since the listener in browser-test.js is not
      // added until then.
      window.addEventListener("MozAfterPaint", function testOnMozAfterPaint() {
        window.removeEventListener("MozAfterPaint", testOnMozAfterPaint);
        setTimeout(redirectToHarness, 0);
        // In case the listener was not ready, try again after a few seconds.
        setTimeout(redirectToHarness, 5000);
      });

    }
  </script>
</head>

<body onload="onLoad();">
redirecting...
</body>
</html>