diff --git a/test/browser/test_html5_fullscreen.html b/test/browser/test_html5_fullscreen.html
index b26a75e0ab5d6..4702bd52db7e0 100644
--- a/test/browser/test_html5_fullscreen.html
+++ b/test/browser/test_html5_fullscreen.html
@@ -77,8 +77,8 @@
print: (function() {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
- return function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ return (...args) => {
+ var text = args.join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/ 1) text = Array.prototype.slice.call(arguments).join(' ');
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.error(text);
- }
+ printErr(..args) {
+ var text = args.join(' ');
+ console.error(text);
},
canvas: (function() {
var canvas = document.getElementById('canvas');
diff --git a/test/browser/test_manual_download_data.html b/test/browser/test_manual_download_data.html
index acb69fc546018..b9511dff8f247 100644
--- a/test/browser/test_manual_download_data.html
+++ b/test/browser/test_manual_download_data.html
@@ -77,8 +77,8 @@
print: (() => {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
- return function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ return (...args) => {
+ var text = args.join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/ {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.error(text);
- }
+ printErr(..args) {
+ var text = args.join(' ');
+ console.error(text);
},
canvas: (() => {
var canvas = document.getElementById('canvas');
diff --git a/test/browser/test_preallocated_heap_shell.html b/test/browser/test_preallocated_heap_shell.html
index ae19948017741..7a337209c5f2e 100644
--- a/test/browser/test_preallocated_heap_shell.html
+++ b/test/browser/test_preallocated_heap_shell.html
@@ -79,8 +79,8 @@
print: (function() {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
- return function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ return (...args) => {
+ var text = args.join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/ 1) text = Array.prototype.slice.call(arguments).join(' ');
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.error(text);
- }
+ printErr(..args) {
+ var text = args.join(' ');
+ console.error(text);
},
canvas: (function() {
var canvas = document.getElementById('canvas');
diff --git a/test/browser/test_preinitialized_webgl_context.html b/test/browser/test_preinitialized_webgl_context.html
index e76edb3ee589d..de282972fd6c8 100644
--- a/test/browser/test_preinitialized_webgl_context.html
+++ b/test/browser/test_preinitialized_webgl_context.html
@@ -77,8 +77,8 @@
print: (function() {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
- return function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ return (...args) => {
+ var text = args.join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/ 1) text = Array.prototype.slice.call(arguments).join(' ');
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.error(text);
- }
+ printErr(..args) {
+ var text = args.join(' ');
+ console.error(text);
},
canvas: (function() {
var canvas = document.getElementById('canvas');
diff --git a/test/browser/test_sdl_canvas_size.html b/test/browser/test_sdl_canvas_size.html
index 697259f223eb8..f56b4d5d77e4e 100644
--- a/test/browser/test_sdl_canvas_size.html
+++ b/test/browser/test_sdl_canvas_size.html
@@ -41,8 +41,8 @@
print: (function() {
var element = document.getElementById('output');
element.value = ''; // clear browser cache
- return function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ return (...args) => {
+ var text = args.join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/ 1) text = Array.prototype.slice.call(arguments).join(' ');
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.log(text);
- }
+ printErr(..args) {
+ var text = args.join(' ');
+ console.error(text);
},
canvas: document.getElementById('canvas'),
setStatus: function(text) {
diff --git a/test/browser/webgl_destroy_context_shell.html b/test/browser/webgl_destroy_context_shell.html
index 9433d358212c8..f815a0d082863 100644
--- a/test/browser/webgl_destroy_context_shell.html
+++ b/test/browser/webgl_destroy_context_shell.html
@@ -77,8 +77,8 @@
print: (function() {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
- return function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ return (...args) => {
+ var text = args.join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/ 1) text = Array.prototype.slice.call(arguments).join(' ');
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.error(text);
- }
+ printErr(..args) {
+ var text = args.join(' ');
+ console.error(text);
},
canvas: (function() {
var canvas = document.getElementById('canvas');
diff --git a/test/canvas_animate_resize_shell.html b/test/canvas_animate_resize_shell.html
index 438fa9cf171a5..0743b08af4805 100644
--- a/test/canvas_animate_resize_shell.html
+++ b/test/canvas_animate_resize_shell.html
@@ -12,16 +12,11 @@
{{{ SCRIPT }}}
diff --git a/test/embind/shell.html b/test/embind/shell.html
index 757d3d17de188..073f7052bea46 100644
--- a/test/embind/shell.html
+++ b/test/embind/shell.html
@@ -38,8 +38,8 @@
print: (function() {
var element = document.getElementById('output');
element.value = ''; // clear browser cache
- return function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ return (...args) => {
+ var text = args.join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/ 1) text = Array.prototype.slice.call(arguments).join(' ');
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.log(text);
- }
+ printErr(..args) {
+ var text = args.join(' ');
+ console.error(text);
},
canvas: document.getElementById('canvas'),
setStatus: function(text) {
diff --git a/test/pthread/main_js_with_loader.html b/test/pthread/main_js_with_loader.html
index 8f9d30a3acaf6..1cf192eea2d13 100644
--- a/test/pthread/main_js_with_loader.html
+++ b/test/pthread/main_js_with_loader.html
@@ -77,8 +77,8 @@
print: (function() {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
- return function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ return (...args) => {
+ var text = args.join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/ 1) text = Array.prototype.slice.call(arguments).join(' ');
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.error(text);
- }
+ printErr(..args) {
+ var text = args.join(' ');
+ console.error(text);
},
canvas: (function() {
var canvas = document.getElementById('canvas');
diff --git a/test/pthread/test_pthread_mandelbrot_shell.html b/test/pthread/test_pthread_mandelbrot_shell.html
index f5ae7921f9a52..a1b702a9035b3 100644
--- a/test/pthread/test_pthread_mandelbrot_shell.html
+++ b/test/pthread/test_pthread_mandelbrot_shell.html
@@ -1227,8 +1227,8 @@
print: (function() {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
- return function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ return (...args) => {
+ var text = args.join(' ');
// These replacements are necessary if you render to raw HTML
//text = text.replace(/&/g, "&");
//text = text.replace(/ 1) text = Array.prototype.slice.call(arguments).join(' ');
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.error(text);
- }
+ printErr(..args) {
+ var text = args.join(' ');
+ console.error(text);
},
canvas: (function() {
var canvas = document.getElementById('canvas');
diff --git a/test/test_fflush.html b/test/test_fflush.html
index 974759d80ad6b..9e5bc25199628 100644
--- a/test/test_fflush.html
+++ b/test/test_fflush.html
@@ -78,20 +78,15 @@
gotStderr: false,
gotStdCerr: false,
- reportSuccess: function() {
+ reportSuccess() {
fetch('/report_result?0').then(() => window.close());
},
- print: (function() {
+ print: (() => {
var element = document.getElementById('output');
if (element) element.value = ''; // clear browser cache
- return function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
- // These replacements are necessary if you render to raw HTML
- //text = text.replace(/&/g, "&");
- //text = text.replace(//g, ">");
- //text = text.replace('\n', '
', 'g');
+ return (...args) {
+ var text = args.join(' ');
console.log(text);
if (text == 'hello!') { Module.gotStdout = true; if (Module.gotStderr && Module.gotStdCerr) Module.reportSuccess(); }
if (element) {
@@ -100,17 +95,13 @@
}
};
})(),
- printErr: function(text) {
- if (arguments.length > 1) text = Array.prototype.slice.call(arguments).join(' ');
+ printErr(...args) {
+ var text = args.join(' ');
if (text == 'hello from stderr too!') { Module.gotStderr = true; if (Module.gotStdout && Module.gotStdCerr) Module.reportSuccess(); }
if (text == 'std::cerr in two parts.') { Module.gotStdCerr = true; if (Module.gotStdout && Module.gotStderr) Module.reportSuccess(); }
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.error(text);
- }
+ console.error(text);
},
- canvas: (function() {
+ canvas() {
var canvas = document.getElementById('canvas');
// As a default initial behavior, pop up an alert when webgl context is lost. To make your
@@ -119,40 +110,7 @@
canvas.addEventListener("webglcontextlost", function(e) { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
return canvas;
- })(),
- setStatus: function(text) {
- if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
- if (text === Module.setStatus.text) return;
- var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
- var now = Date.now();
- if (m && now - Date.now() < 30) return; // if this is a progress update, skip it if too soon
- if (m) {
- text = m[1];
- progressElement.value = parseInt(m[2])*100;
- progressElement.max = parseInt(m[4])*100;
- progressElement.hidden = false;
- spinnerElement.hidden = false;
- } else {
- progressElement.value = null;
- progressElement.max = null;
- progressElement.hidden = true;
- if (!text) spinnerElement.hidden = true;
- }
- statusElement.innerHTML = text;
},
- totalDependencies: 0,
- monitorRunDependencies: function(left) {
- this.totalDependencies = Math.max(this.totalDependencies, left);
- Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
- }
- };
- Module.setStatus('Downloading...');
- window.onerror = function() {
- Module.setStatus('Exception thrown, see JavaScript console');
- spinnerElement.style.display = 'none';
- Module.setStatus = function(text) {
- if (text) Module.printErr('[post-exception status] ' + text);
- };
};
{{{ SCRIPT }}}
diff --git a/test/test_manual_wasm_instantiate.html b/test/test_manual_wasm_instantiate.html
index 101d61c85ae95..e8930994d6586 100644
--- a/test/test_manual_wasm_instantiate.html
+++ b/test/test_manual_wasm_instantiate.html
@@ -79,11 +79,6 @@
if (element) element.value = ''; // clear browser cache
return (...args) => {
var text = args.join(' ');
- // These replacements are necessary if you render to raw HTML
- //text = text.replace(/&/g, "&");
- //text = text.replace(//g, ">");
- //text = text.replace('\n', '
', 'g');
console.log(text);
if (element) {
element.value += text + "\n";
@@ -91,57 +86,10 @@
}
};
})(),
- printErr: (...args) => {
+ printErr(...args) {
var text = args.join(' ');
- if (0) { // XXX disabled for safety typeof dump == 'function') {
- dump(text + '\n'); // fast, straight to the real console
- } else {
- console.error(text);
- }
+ console.error(text);
},
- canvas: (() => {
- var canvas = document.getElementById('canvas');
-
- // As a default initial behavior, pop up an alert when webgl context is lost. To make your
- // application robust, you may want to override this behavior before shipping!
- // See http://www.khronos.org/registry/webgl/specs/latest/1.0/#5.15.2
- canvas.addEventListener("webglcontextlost", (e) => { alert('WebGL context lost. You will need to reload the page.'); e.preventDefault(); }, false);
-
- return canvas;
- })(),
- setStatus: (text) => {
- if (!Module.setStatus.last) Module.setStatus.last = { time: Date.now(), text: '' };
- if (text === Module.setStatus.text) return;
- var m = text.match(/([^(]+)\((\d+(\.\d+)?)\/(\d+)\)/);
- var now = Date.now();
- if (m && now - Date.now() < 30) return; // if this is a progress update, skip it if too soon
- if (m) {
- text = m[1];
- progressElement.value = parseInt(m[2])*100;
- progressElement.max = parseInt(m[4])*100;
- progressElement.hidden = false;
- spinnerElement.hidden = false;
- } else {
- progressElement.value = null;
- progressElement.max = null;
- progressElement.hidden = true;
- if (!text) spinnerElement.hidden = true;
- }
- statusElement.innerHTML = text;
- },
- totalDependencies: 0,
- monitorRunDependencies: (left) => {
- this.totalDependencies = Math.max(this.totalDependencies, left);
- Module.setStatus(left ? 'Preparing... (' + (this.totalDependencies-left) + '/' + this.totalDependencies + ')' : 'All downloads complete.');
- }
- };
- Module.setStatus('Downloading...');
- window.onerror = () => {
- Module.setStatus('Exception thrown, see JavaScript console');
- spinnerElement.style.display = 'none';
- Module.setStatus = (text) => {
- if (text) Module.printErr('[post-exception status] ' + text);
- };
};
function downloadWasm(url) {
@@ -181,6 +129,6 @@
var script = document.createElement('script');
script.src = "manual_wasm_instantiate.js";
document.body.appendChild(script);
-
+