File: browser_harness.html

package info (click to toggle)
emscripten 2.0.12~dfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 108,440 kB
  • sloc: ansic: 510,324; cpp: 384,763; javascript: 84,341; python: 51,362; sh: 50,019; pascal: 4,159; makefile: 3,409; asm: 2,150; lisp: 1,869; ruby: 488; cs: 142
file content (60 lines) | stat: -rw-r--r-- 1,811 bytes parent folder | download | duplicates (2)
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
<!DOCTYPE html>
<html>
<head>
  <meta charset="utf-8" />
  <title>Emscripten Browser Test Harness</title>
  <style>
    html, body {
      margin: 0;
      padding: 0;
      height: 100%;
    }
    body {
      display: flex;
      flex-direction: column;
    }
    .topbar {
      background-color: #79f;
    }
    .full {
      border: none;
      width: 100%;
      flex: 1;
    }
  </style>
  <script>
    var COMMAND_PREFIX = 'COMMAND:';
    var counter = 0;
    function check() {
      var request = new XMLHttpRequest();
      request.open('GET', '/check');
      request.send(null);
      request.addEventListener("load", function() {
        if (request.responseText.startsWith(COMMAND_PREFIX)) {
          var url = request.responseText.substr(COMMAND_PREFIX.length);
          iframe.src = url;
          document.getElementById('count').textContent = counter++;
        }
        // Polling for the next test to start: we just keep asking if we
        // should load a new page, since the iframe doesn't currently have
        // a way to tell us it completed (even if it did, we'd need to poll
        // the server to know when the next test page is ready to load).
        setTimeout(check, 10);
      });
      request.addEventListener("error", function() {
        document.body.innerHTML = 'Tests complete. View log in console.';
        // Attempt to close the main window.  This works on chrome
        // but fails on firefox with: `Scripts may not close windows that
        // were not opened by script.`
        window.close();
      });
    }
    document.addEventListener('DOMContentLoaded', check);
  </script>
</head>
<body>
  <span class="topbar">Running test <span id="count"></span>...</span>
  <iframe class="full" id="iframe" allowfullscreen="true"></iframe>
</body>
</html>