|
23 | 23 | } |
24 | 24 | </style> |
25 | 25 | <script> |
26 | | - var COMMAND_PREFIX = 'COMMAND:'; |
27 | 26 | var counter = 0; |
28 | | - function check() { |
29 | | - fetch('/check') |
30 | | - .then((rsp) => rsp.text()) |
31 | | - .then((responseText) => { |
32 | | - if (responseText.startsWith(COMMAND_PREFIX)) { |
33 | | - var url = responseText.substr(COMMAND_PREFIX.length); |
34 | | - iframe.src = url; |
35 | | - document.getElementById('count').textContent = counter++; |
36 | | - } |
37 | | - // Polling for the next test to start: we just keep asking if we |
38 | | - // should load a new page, since the iframe doesn't currently have |
39 | | - // a way to tell us it completed (even if it did, we'd need to poll |
40 | | - // the server to know when the next test page is ready to load). |
41 | | - // (A timeout value of 100msecs has been seen to stall test |
42 | | - // browser.test_audio_worklet_worker on Chrome) |
43 | | - setTimeout(check, 200); |
44 | | - }) |
45 | | - .catch(() => { |
46 | | - document.body.innerHTML = 'Tests complete. View log in console.'; |
47 | | - // Attempt to close the main window. This works on chrome |
48 | | - // but fails on firefox with: `Scripts may not close windows that |
49 | | - // were not opened by script.` |
50 | | - window.close(); |
51 | | - }); |
| 27 | + async function check() { |
| 28 | + try { |
| 29 | + const rsp = await fetch('/check'); |
| 30 | + const responseText = await rsp.text(); |
| 31 | + |
| 32 | + const COMMAND_PREFIX = 'COMMAND:'; |
| 33 | + if (responseText.startsWith(COMMAND_PREFIX)) { |
| 34 | + var url = responseText.substr(COMMAND_PREFIX.length); |
| 35 | + iframe.src = url; |
| 36 | + document.getElementById('count').textContent = counter++; |
| 37 | + } |
| 38 | + // Polling for the next test to start: we just keep asking if we |
| 39 | + // should load a new page, since the iframe doesn't currently have |
| 40 | + // a way to tell us it completed (even if it did, we'd need to poll |
| 41 | + // the server to know when the next test page is ready to load). |
| 42 | + // (A timeout value of 100msecs has been seen to stall test |
| 43 | + // browser.test_audio_worklet_worker on Chrome) |
| 44 | + setTimeout(check, 200); |
| 45 | + } catch { |
| 46 | + document.body.innerHTML = 'Tests complete. View log in console.'; |
| 47 | + // Attempt to close the main window. This works on chrome |
| 48 | + // but fails on firefox with: `Scripts may not close windows that |
| 49 | + // were not opened by script.` |
| 50 | + window.close(); |
| 51 | + } |
52 | 52 | } |
53 | 53 | document.addEventListener('DOMContentLoaded', check); |
54 | 54 | </script> |
|
0 commit comments