Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 22 additions & 2 deletions tests/browser_reporting.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ function reportResultToServer(result, sync, port) {
port = port || 8888;
if (reportResultToServer.reported) {
// Only report one result per test, even if the test misbehaves and tries to report more.
reportErrorToServer("excessive reported results, sending " + result + ", test will fail");
reportStderrToServer("excessive reported results, sending " + result + ", test will fail");
}
reportResultToServer.reported = true;
var xhr = new XMLHttpRequest();
Expand All @@ -25,12 +25,18 @@ function maybeReportResultToServer(result, sync, port) {
reportResultToServer(result, sync, port);
}

function reportErrorToServer(message) {
function reportStderrToServer(message) {
var xhr = new XMLHttpRequest();
xhr.open('GET', encodeURI('http://localhost:8888?stderr=' + message));
xhr.send();
}

function reportStdoutToServer(message) {
var xhr = new XMLHttpRequest();
xhr.open('GET', encodeURI('http://localhost:8888?stdout=' + message));
xhr.send();
}

if (typeof window === 'object' && window) {
function report_error(e) {
// MINIMAL_RUNTIME doesn't handle exit or call the below onExit handler
Expand Down Expand Up @@ -62,4 +68,18 @@ if (hasModule) {
Module['onAbort'] = function(reason) {
maybeReportResultToServer('abort:' + reason);
}

var oldPrint = Module['print'];
Module['print'] = function() {
reportStdoutToServer(Array.prototype.slice.call(arguments).join(' '));
if (oldPrint)
oldPrint.apply(null, arguments);
}

var oldPrintErr = Module['printErr'];
Module['printErr'] = function() {
reportStderrToServer(Array.prototype.slice.call(arguments).join(' '));
if (oldPrintErr)
oldPrintErr.apply(null, arguments);
}
}
9 changes: 0 additions & 9 deletions tests/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -1199,16 +1199,7 @@ def do_GET(self):
self.send_header('Expires', '-1')
self.end_headers()
self.wfile.write(b'OK')

elif 'stdout=' in self.path or 'stderr=' in self.path or 'exception=' in self.path:
'''
To get logging to the console from browser tests, add this to
print/printErr/the exception handler in src/shell.html:

var xhr = new XMLHttpRequest();
xhr.open('GET', encodeURI('http://localhost:8888?stdout=' + text));
xhr.send();
'''
print('[client logging:', unquote_plus(self.path), ']')
self.send_response(200)
self.send_header('Content-type', 'text/html')
Expand Down