| 1 |
<!DOCTYPE html> |
| 2 |
<html> |
| 3 |
<head> |
| 4 |
<style> |
| 5 |
body { |
| 6 |
margin: 0; |
| 7 |
padding: 0; |
| 8 |
} |
| 9 |
|
| 10 |
#output { |
| 11 |
margin: 30px; |
| 12 |
white-space: pre; |
| 13 |
font-family: monospace; |
| 14 |
} |
| 15 |
|
| 16 |
.error { |
| 17 |
display: block; |
| 18 |
width: calc(100% - 20px); |
| 19 |
background-color: #bb0000; |
| 20 |
padding: 10px; |
| 21 |
border-radius: 5px; |
| 22 |
margin: 10px 0; |
| 23 |
color: white; |
| 24 |
} |
| 25 |
</style> |
| 26 |
</head> |
| 27 |
<body> |
| 28 |
<div id="output"></div> |
| 29 |
|
| 30 |
<script type="text/javascript"> |
| 31 |
let failed = false |
| 32 |
const output = document.querySelector('#output') |
| 33 |
const originalLog = console.log |
| 34 |
const originalError = console.error |
| 35 |
|
| 36 |
console.log = function (message, ...args) { |
| 37 |
if (typeof message !== 'string') { |
| 38 |
originalLog(message, ...args) |
| 39 |
return |
| 40 |
} |
| 41 |
|
| 42 |
if (message.includes('not ok')) { |
| 43 |
failed = true |
| 44 |
document.body.style.backgroundColor = '#ff9d9d' |
| 45 |
} else if (message.includes('# readable-stream-finished') && !failed) { |
| 46 |
document.body.style.backgroundColor = '#9dff9d' |
| 47 |
} |
| 48 |
|
| 49 |
const span = document.createElement('span') |
| 50 |
span.textContent = message + '\n' |
| 51 |
output.appendChild(span) |
| 52 |
window.scrollTo(0, document.body.scrollHeight) |
| 53 |
originalLog(message, ...args) |
| 54 |
} |
| 55 |
|
| 56 |
console.error = function (message, ...args) { |
| 57 |
if (typeof message !== 'string') { |
| 58 |
originalError(message, ...args) |
| 59 |
return |
| 60 |
} |
| 61 |
|
| 62 |
const span = document.createElement('span') |
| 63 |
span.classList.add('error') |
| 64 |
span.textContent = message + '\n' |
| 65 |
output.appendChild(span) |
| 66 |
|
| 67 |
originalError(message, ...args) |
| 68 |
} |
| 69 |
</script> |
| 70 |
<script type="text/javascript" src="./suite.browser.js"></script> |
| 71 |
</body> |
| 72 |
</html> |