summaryrefslogtreecommitdiffstats
path: root/testing/web-platform/tests/tools/wave/www/submitresult.html
blob: 07e9f35235016ba41bd599d5eed0388278d27ee1 (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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <title>Web Platform Tests</title>
    <style>
      #console {
        font-family: monospace;
      }
    </style>
    <script src="lib/wave-service.js"></script>
  </head>
  <body>
    <div id="console"></div>
    <script>
      var screenConsole = document.getElementById("console");
      var log = function() {
        var text = "";
        for (var i = 0; i < arguments.length; i++) {
          text += arguments[i] + " ";
        }
        text = text.replace(/ /gm, "&nbsp;");
        text = text.replace(/\n/gm, "<br/>");
        screenConsole.innerHTML += "<br/>" + text;
      };

      window.onerror = function(error) {
        log(error);
      };

      var HOSTNAME = location.hostname;
      var PORT = location.port;
      var PROTOCOL = location.protocol.replace(/:/, "");
      var QUERY = (location.search.replace(/\?/, ""));
      var match = QUERY.match(/token=([^&]+)/);
      var TOKEN = match ? match[1] : null;
      QUERY += /[\?&]path=/.test(location.search) ? "" : "&resume=1";
      match = QUERY.match(/data=([^&]+)/);

      var parsedQuery = {};

      var parts = QUERY.split("&");
      for (var i = 0; i < parts.length; i++) {
        var part = parts[i];
        var key = part.split("=")[0];
        var value = part.split("=")[1];
        parsedQuery[key] = value;
      }

      var resultData;
      var rawResult = parsedQuery.result;
      if (rawResult) {
        resultData = JSON.parse(decodeURIComponent(rawResult));
      }

      WaveService.createResult(TOKEN, resultData, function() {
        WaveService.readNextTest(TOKEN, function(url) {
          location.href = url;
        });
      });
    </script>
  </body>
</html>