From b013ec6288796b96c91a14c873065ba4da7bffc7 Mon Sep 17 00:00:00 2001 From: Alex Crichton Date: Thu, 8 Nov 2018 11:46:52 -0800 Subject: [PATCH] Use splat instead of `arguments` in tests Previously `arguments` was used to pass around an array of arguments, but this wasn't actually a `js_sys::Array` but rather a somewhat esoteric internal object. When switching over `Array` methods to be `structural` this caused issues because the inherent methods on an `arguments` object were different than that of `js_sys::Array`. --- .../bin/wasm-bindgen-test-runner/index-headless.html | 12 ++++++------ crates/cli/src/bin/wasm-bindgen-test-runner/node.rs | 12 ++++++------ 2 files changed, 12 insertions(+), 12 deletions(-) diff --git a/crates/cli/src/bin/wasm-bindgen-test-runner/index-headless.html b/crates/cli/src/bin/wasm-bindgen-test-runner/index-headless.html index c7eed7bb..d671a205 100644 --- a/crates/cli/src/bin/wasm-bindgen-test-runner/index-headless.html +++ b/crates/cli/src/bin/wasm-bindgen-test-runner/index-headless.html @@ -19,17 +19,17 @@ logs.innerHTML += `${msg}\n`; } }; - console.log = function() { + console.log = function(...args) { if (window.console_log_redirect) - window.console_log_redirect(orig_console_log, arguments); + window.console_log_redirect(orig_console_log, args); else - orig_console_log.apply(this, arguments); + orig_console_log.apply(this, args); }; - console.error = function() { + console.error = function(...args) { if (window.console_error_redirect) - window.console_error_redirect(orig_console_error, arguments); + window.console_error_redirect(orig_console_error, args); else - orig_console_error.apply(this, arguments); + orig_console_error.apply(this, args); }; window.__wbg_test_invoke = f => f(); diff --git a/crates/cli/src/bin/wasm-bindgen-test-runner/node.rs b/crates/cli/src/bin/wasm-bindgen-test-runner/node.rs index 537b0481..d94d8e92 100644 --- a/crates/cli/src/bin/wasm-bindgen-test-runner/node.rs +++ b/crates/cli/src/bin/wasm-bindgen-test-runner/node.rs @@ -23,19 +23,19 @@ pub fn execute( // ensure they're bound correctly in wasm. This'll allow us to intercept // all these calls and capture the output of tests const prev_log = console.log; - console.log = function() {{ + console.log = function(...args) {{ if (console_log_redirect === null) {{ - prev_log.apply(null, arguments); + prev_log.apply(null, args); }} else {{ - console_log_redirect(prev_log, arguments); + console_log_redirect(prev_log, args); }} }}; const prev_error = console.error; - console.error = function() {{ + console.error = function(...args) {{ if (console_error_redirect === null) {{ - prev_error.apply(null, arguments); + prev_error.apply(null, args); }} else {{ - console_error_redirect(prev_error, arguments); + console_error_redirect(prev_error, args); }} }};